0

I have some confusing question which make me run in a loop, please help me to understand them.

  1. if I have two file one is .y which is the parser file and the second is the .l lexical analyzer can I use the yytext in the parser file, should I define the yylex there to use it or not?

  2. there is a default yyerror function if I want to change it should I declare it in the parser file in the section of the declarations?

  3. if in the lex file I return a token to the parser something like this:

    [0-9] return DIGIT; what is passed to the parser the DIGIT with the digit found or just the digit itself without the DIGIT?

  4. how can I use yylineno in the parser file ,because I need the parser to use yylineno and tell where did the error happened and what token caused that?

  5. in the parser file when I write a rule like this:

    exp -> exp |/empty/

is it the same as

exp ->/*empty*/ |exp 

I appreciate anyone who could help me with those question because they had confused me,thanks in advance

4

1 に答える 1