help-bison
[Top][All Lists]
Advanced

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

help, bison grammar conflicts


From: Axel Kittenberger
Subject: help, bison grammar conflicts
Date: Sat, 11 Aug 2001 16:08:23 +0200

Hi!

I'm writting this, because I think it can't hurt, maybe someone can give an 
idea:

While designing a grammar I encountered a hard limit with the parser, the 
grammar is rather C++ like, but in contrast to C++ I want to allow 
construction of field classes directly in the master class like:

class Integer {
    int32 value;
    int32 max;

    A(int32 setme, int32 max) {
        value = setme;
        this.max = max;
    }
}

class B {
    int32 some_function(String someparm, int32 parm2);

    Integer a_field(0, 5);
}

---
a_field would be automatically constructed in the memory area of B, as soon 
the user instances a B.

Now the problem is it seems I'm not able to write a bison grammar for this.
The problem is after the '(' token for the function or the field, I would 
need to look two tokens into the future to determine if this an expression so 
this is a function call, or if this is variable type so a it's a function 
import. Like if after the opening bracket '(' comes an identifier this can be 
either a variable name, or a type name, if the next token is an operator or a 
',' I would know it's a variable, but if the next token is again an 
Identifier I would know that it is a type with var-name like String someparm.

So I guess the problem I'm facing is the LA of LALR, one lookahead seems not 
enough. Does anybody maybe have an idea how this can be solved? Can this 
problem maybe be workarounded with bison? Or doesn't conflict if written 
correctly?

Or is it only possible with other parser technics? Are there maybe generators 
aviable with at least as easy to use as bison? However I would hate to have 
to change/rewrite my whole grammar :o(, just because this one conflict. Or is 
the only hope to change the language so a grammar can be constructed for it?

Greetings,

- Axel



reply via email to

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