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

Re: Java 1.4 grammar extension



You don't specify the error reported by SableCC, but I expect it is a
conflct on the '<' character (the 'lt' token). This character is used
elsewhere in the expression grammar as the less-then operator.

Generic Java has a very similar construct though, so you may be able to
peruse that grammar and make it work for you. You can find this in the
Generic Java Specification at:

    http://www.cis.unisa.edu.au/~pizza/gj/Documents/#gj-specification

You will probably need a copy of the the Java Specifcation in order to
understand where the new GJ constructs should end up in your modified
grammar.

As a final note, I notice that GJ uses the following construct:

    a.<edu.uci.IA, edu.uci.IB>foo();

    int x = a.<edu.uci.IA, edu.uci.IB>foo();

instead or your:

    a.foo() <edu.uci.IA, edu.uci.IB>;

    int x = a.foo() <edu.uci.IA, edu.uci.IB>;

The specification says that this is due to "parsing constraints" (section
5.5, just after example 14), so you may want to chuck your construct and use
the one from GJ instead.

On Sat, Mar 27, 2004 at 08:54:32PM +0100, darek wrote:
> Hello,
> 
> i'm trying to extend java 1.4 grammar
> (http://www.sablecc.org/grammars/j14.sablecc.html) for SableCC to allow
> following constructions:
> 
> A a = new A();
> ...
> a.foo() <edu.uci.IA, edu.uci.IB>;
> 
> int x = a.foo() <edu.uci.IA, edu.uci.IB>;
> 
> etc.
> 
> i've tried to add something like this:
> 
> method_messages =
> 	lt interface_type_list gt;
> 
> to:
> 
> method_invocation =
>      {name}
>          name l_parenthese argument_list? r_parenthese method_messages? |
> 
>      {primary}
>          primary dot identifier l_parenthese argument_list? r_parenthese
> method_messages? |
> 
>      {super}
>          T.super dot identifier l_parenthese argument_list? r_parenthese
> method_messages? ;
> 
> but it doesn't work. SableCC throws errors while creating output files.
> 
> when i remove '?' char from the end of method_messages it is ok and works
> correctly but i need normal methods invocation ("a.foo();") either.
> 
> i cannot ask the grammar author, because his email address i have is not
> valid :-(
> 
> Could someone explain me, what i'm doing wrong?
> 
> thanks in advance
> 
> Darek

-- 
Jon Shapcott <eden@xibalba.demon.co.uk>
"This is the Space Age, and we are Here To Go" - Wlliam S. Burroughs