[antlr-interest] Problem with '.' character

Thomas Brandon tbrandonau at gmail.com
Wed Jan 23 08:22:11 PST 2008


It looks like your language may be ambiguous. Given:
a=b.c=d.e
how can you tell if this is 2 statements:
(ASSIGN (VAR a) (VAR b))
(ASSIGN (VAR c) (FIELD d e))
or 1 statement:
(ASSIGN (VAR a) (ASSIGN (FIELD b c) (FIELD d e)))
With just this information I can't see a way so I can't see any way to write
a grammar to do so.
Are variables declared? If it's pre-compiled, are tables\fields known at
compile time? If one of these is true you may be able to use a symbol table
to resolve this. But you still may end up with a very messy grammar,
especially if variable declarations need not precede use in the file.
If possible you really need to reconsider your language design.

Tom.
On Jan 24, 2008 1:30 AM, Dev Team <devteam at jubii.fr> wrote:

>  Hi there,
> I am currently trying to write a grammar with antlr.
> But the '.' character is used for both table/field separator and statement
> ending.
> here is an example :
>
>  method public void myMethod() :
> //...
> var1 = var2.
> var3 = myTable.myField.
> //...
> end method.
>
> So, the problem is that the grammar considers 'var2.var3' as a table/field
> expression.
> Does someone know how to resolve this problem ?
> thanks in advance
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080124/b96b1ccc/attachment.html 


More information about the antlr-interest mailing list