I am working on a Parser using Bison, and I am trying to parse something like
void Example() {}
When running, with debug, the output is:
Starting parse
Entering state 0
Reading a token: void A()
Next token is token VOID ()
Shifting token VOID ()
Entering state 1
Reducing stack by rule 98 (line 146):
$1 = token VOID ()
-> $$ = nterm return_options ()
Stack now 0
Entering state 32
Reading a token: Next token is token IDENTIFIER ()
Error detected on line 1.
Last token read: 'Example'
Error: popping nterm return_options ()
Stack now 0
Cleanup: discarding lookahead token IDENTIFIER ()
Stack now 0
This is the important part of the grammar productions:
program : function END_OF_FILE {return 0;}
function : return_options identifier formal_parameters block
return_options : identifier | VOID
identifier : letter list_E_letters
list_E_letters : list_E_letters algarism |
algarism : letter | digit
letter : 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z'
digit : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
Can you help me on the reason the error is happening? I can't see why.
Thank you!