[antlr-interest] need help writing a source code formatter
Adrian Sandor
aditsu at yahoo.com
Thu Jun 26 07:21:40 PDT 2003
Hello everybody
I'm a programmer and I'm very determined to write a source
beautifier/formatter for C++. First I wanted to do it by myself, and
started writing a grammar, but I had some difficulties when I wanted
to write the parser (I didn't want to use CYK, I wanted to try LL1
but I'm afraid C++ is not LL1).
Therefore I looked for help on the web, and I found antlr, which
seems to be far greater than my expectations. So I gave up the idea
of writing a parser/translator by myself, and I decided to write an
antlr grammar instead.
The problem is I really have no idea how to do it.. I have some fair
knowledge about formal languages but I'm a total newbie to antlr. I
learnt the hard way about the differences between the lexer and
parser rules, but I'm still confused.
Here are my questions:
- how do I decide which rules belong to the parser and which rules
are tokens that belong to the lexer?
- what is the meaning of "warning:nondeterminism upon k==1:SOME_TOKEN
between alt 1 and exit branch of block" ?
- could somebody have some mercy and write a simple example, like
parsing a string of correctly matched parentheses with spaces between
them and stripping all spaces and adding a '+' after each '(' and a '-
' before each ')' ? e.g. "( ()( ( )) )" -> "(+(+-)(+(+-)-)-)"
- where can I find some simple and helpful documentation for what I
want to do?
thanks a lot
Adrian
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list