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

Re: SableCC equivalent to %prec from yacc



On Sat, 2006-06-17 at 00:04 -0400, Etienne Gagnon wrote:
> FYI, SableCC 4 will introduce some operators to handle some common
> ambiguities.  These operators will not modify the parsed languages; they
> will only resolve these ambiguities according to the grammar designer's
> preference.
> 
> If you wish to attack C++ parsing with SableCC, I recommend that you
> look at James A. Roskind's grammar:
>  ftp://ftp.iecc.com/pub/file/c++grammar/
> 
> I would also highly recommend that you read Edward D. Willink's Ph.D.
> thesis:
>  http://www.computing.surrey.ac.uk/research/dsrg/fog/

I took a class last term which used Java for parsing a simple language
and we generated C# CIL files from it. We compiled those files with
ilasm and then ran them. What I learned was that it was nice to simply
create look up tables that would associate a Node with a Java Object. I
could then use things like instanceof to convert the object to the
correct type. So far I am looking at Willink's and Roskind's grammar
files lead me to believe that C++ can only be parsed with a parser that
is able to be helped when its facing an ambiguous grammar.

So at this time I am not sure how to move forward if I want to stay with
SableCC because I cannot use a %prec like command with version 3. Since
version 4 is not coming out until some untold time in the future I am
only left to read Willink's dissertation and wait.

I am just voicing my thoughts out here to see what people would advise
me to do. My main hurdle now is to get C++ into a AST in with a parser
written in C# (preferred) or Java (second choice).

Stephen