|Parsing / Lexing question & P-code email@example.com (Nicolás) (2000-04-14)|
|Re: Parsing / Lexing question & P-code Herwig.Huener@pgtm0035.mch.sni.de (Herwig Huener) (2000-04-21)|
|Re: Parsing / Lexing question & P-code firstname.lastname@example.org (Keith Thompson) (2000-04-25)|
|Re: Parsing / Lexing question & P-code email@example.com (Sebastian Moleski) (2000-04-25)|
|Date:||14 Apr 2000 23:43:14 -0400|
|Keywords:||Pascal, question, comment|
I am writing a translator/interpreter for the Pascal lang in C++/Bison.
First of all, I don't know how to differentiate when an identifier is
acting as a variable in an assignment, or it is just a func call with
no params. What I was doing up to now was to recognize something like
assignment: ID = expr;
expr = variable opt_parameter_list
variable: ID | variable '.' ID | variable '[' expr ']' ;
And then I did error checking after parsing (since this allows for
things like foo [ bar ](1) and foo.bar(1)).
But recently I came up with another idea: instead of returning an ID
for any identifier, I looked up the identifier in the lexer, and
returned ID_UNKNOWN, ID_FUNCTION, etc ... This allowed me to have much
less error checking and no conflicts in the bison grammar.
I would appreciate any opinions as to which one is better.
Second, I am considering the option of emitting P-code for the
programs ... Does anybody know where can I get info on anything
related to this ?
Thanks a lot,
[I've seen compilers that work either way. I prefer the lexer lookup
since it permits earlier error reporting. -John]
Return to the
Search the comp.compilers archives again.