jserv / amacc

Small C Compiler generating ELF executable Arm architecture, supporting JIT execution
Other
1.01k stars 161 forks source link

Separate parser and lexer? #45

Closed splasky closed 5 years ago

splasky commented 6 years ago

May I separate the lexer and parser? It will be more easy to generate ast tree if I can separate the lexer and parser.

jserv commented 6 years ago

Related: #37

jserv commented 6 years ago

@splasky, you can follow the changes proposed by #37 and think of the further AST refactoring.

splasky commented 6 years ago

@jserv ,In my experience the compiler will generate tokens for parser. And use the tokens to generate ast tree. The work can be found at https://github.com/splasky/amacc/commit/3db51cb5bd062a546204c8fa668273b328471e72. Is my current practice correct?

jserv commented 6 years ago

Why do we need separate lexer program? If we can ensure the simplicity, we can put them into single file.

splasky commented 6 years ago

The current version is for testing, I will refactor before merge it into amacc.c. Is the tokenized phase(lexer function) I wrote is correct(or needed)? Or I have to keep using the next phase?

jserv commented 6 years ago

The current version is for testing, I will refactor before merge it into amacc.c. Is the tokenized phase(lexer function) I wrote is correct(or needed)? Or I have to keep using the next phase?

Anything facilitating what c5-AST branch did can be considered as functionally correct at first glance.

jserv commented 5 years ago

Defer to #37