Thanks Tim. At first sight, this fix should be exactly what I need;
however, in my case, it doesn't work... :(
The problem is that COBOL has a real keyword - FUNCTION - to 'lock on'
to. So, in your production:
xxx
: { recognize_function_names = true; } FUNCTION valid_function
;
the lexer can recognise FUNCTION, independently of context. The problem
is, in my input, there aren't *any* context-independent keywords (not in
this case, anyway). This is equivalent to the COBOL problem where
FUNCTION is optional. The grammar looks like this:
program : function_list ;
function_list
: /* nothing */
| function_list function ;
function : { recognise_function_names = true; }
valid_function '{' function_body '}' ;
valid_function : FOO | BAR ;
The only way that I know a new function is coming up is that an existing
function has just completed: there's no convenient keyword to give me
warning. [If my grammar really was this simple, then I could probably
use another token to recognise the end of a function, but the real input
is pretty complex].
Any ideas? It seems to me that I need an 'unget' implementation.
Thanks -
Evan
_______________________________________________
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison