'Why does my $1 operation not work with Java Bison?
When I have an abstract syntax tree in the Java Bison (.y) file with this:
string_op:
SYMBOL_PLUS { $$ = $1; System.out.println("this should print + here: " + $$);}
| SYMBOL_DOUBLEEQ
| SYMBOL_NOTEQ;
I would expect it to print "this should print + here:+" whenever the parser comes across the + token (i.e. SYMBOL_PLUS). However, I always get "this should print + here:null".
I have already used the %type declarations and everything.
%nterm <String> string_op
%type<String> SYMBOL_PLUS
%type<String> RESERVED_BOOL
%type<String> RESERVED_STRING
%type<String> RESERVED_INT
%type<String> IDENTIFIER
%type<String> SYMBOL_DOUBLEEQ
%type<String> SYMBOL_NOTEQ
It still gives the error. There is a massive lack of good, understandable, and clear documentation for java bison so it's really frustrating. Please let me know if you can fix this issue. I've been on it for days.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
