[antlr-interest] C++ beginner questions
Matthew Tedder
teddemc at yahoo.com
Fri Sep 30 10:26:49 PDT 2005
These are owesome.. I am printing them out for my own
exploits, as soon as I have time again.
Once I finally got a basic java based antlr thingy
running, I started looking at c++ and I am still
trembling a little at the thought. But I know I'll
have to learn to make any practical use of antlr.
It sure would be nice if somebody could write-up a
step-by-step tutorial for antlr in C++ on a simple
language like say:
---
stmt:
declare { IDENT } as { number | string }
IDENT = input
output IDENT
IDENT = string_expression
IDENT = number_expression
If condition Then stmt [ Els stmt ]
string_expression:
STR_LIT | string_expression + string_expression
number_expression:
NUM_LIT | number_expression + number_expression
---
I also keep scratching my head thinking, "What's the
point of compilers implemented in Java?". It's neat
but pretty much in the same way that the ASCII client
for Doom was neat. I guess they must be using it for
business rules engines where the data processing
workloads are light.. That's the only thing I can
think of..
Matthew
--- Peggy Fieland <madcapmaggie at yahoo.com> wrote:
> C++ Lexer its $getText. For example:
>
> IDENT: (ID_START_LETTER) (ID_LETTER)*
> {
> std::string s = $getText;
> $setText( LowerCase(s) ); }
> resolving ambiguities: syntactic or semantic
> predicates
>
> in lexer:
>
> IDENT:
> (BOOLEAN!) => BOOLEAN { $setType(BOOLEAN); }
> ...
>
>
> ML_COMMENT
> : '/' '*'
>
> options {
> generateAmbigWarnings=false;
> }
> :
> { LA(2)!='/' }? '*'
> | '\r' '\n' {newline();}
> | '\r' {newline();}
> | '\n' {newline();}
> | ~('*'|'\n'|'\r')
> )*
> '*' '/'
> { _ttype = ANTLR_USE_NAMESPACE(antlr)Token::SKIP;
> }
>
>
> ...
>
> in parser similarly. More gory details upon
> request.
>
> Peggy
>
>
>
>
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
More information about the antlr-interest
mailing list