help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lexical feedback and lookahead


From: Evan Lavelle
Subject: Re: Lexical feedback and lookahead
Date: Tue, 19 Jul 2005 16:01:33 +0100
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]