help-bison
[Top][All Lists]
Advanced

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

Re: Lexical feedback and lookahead


From: Hans Aberg
Subject: Re: Lexical feedback and lookahead
Date: Tue, 19 Jul 2005 18:11:56 +0200


On 19 Jul 2005, at 17:01, Evan Lavelle wrote:

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].

It seems me that you know that a function has been completed when the function body top level "{" ... "}" has completed. This can be kept track of by a bracket depth count in the lexer.

Any ideas? It seems to me that I need an 'unget' implementation.

In Bison, it is called %glr.

  Hans Aberg






reply via email to

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