[antlr-interest] Multiplication and pointers in C-style language
David Olsson
vonolsson at gmail.com
Thu Apr 10 06:06:56 PDT 2008
Stuart Watt wrote:
>
> if you need pointers and multiplication, in C syntax, I suspect you're
> going to need to build a (scoped) type symbol table and semantic
> predicates. Then if the first identifier is a type, you can treat it
> is a pointer, if not, multiplication. As Jim said, the code to do this
> is in the C ANTLR example.
>
Unfortunately, my language is not like C in all cases. Specifically, my
language is a two pass language. In the first pass, all the parsing is
done. In the second, type checks and such is done. This means that I
don't need a preprocessor nor includes. This, however, also means that
there is no easy way of telling if an identifier is a type or a variable
during parsing; that information isn't available until the second pass.
I've looked at Terence Parr's example Java grammar but since there are
no pointers in Java it is of little help. Maybe the only solution is to
change the pointer syntax so that there are no conflicts with other
operators (the benefit of inventing your own language ;-))... Or can
anyone think of a better solution?
David Olsson
More information about the antlr-interest
mailing list