On Mon, 2 Apr 2001, hipster wrote: > ANTLR grammars are written in a kind of EBNF, which makes them very > readable: > > rule > : TOKEN > | nonterminal > | (optional)? > | (zero_or_more)* > | (one_or_more)? > ; > Yeah, its great. Do you know if it is general (ie. you can apply operators (?/+/*) to sequences of symbols and nest them or if they only applies to individual symbols? (rockit has the latter but not the former) > semantic_predicates > : { conditional_code; } => rule > | { conditional_code; } => rule > | foo > ; Ok, and you have access to parsing/lexing info when writing the conditional_code? What kind of info? Can you access the AST being built? > automatic Abstract Syntax Tree generation with grammar annotations (^): > > mult_expr > : add_expr ((STAR^ | SLASH^) add_expr) > ; > > add_expr > : atom ((PLUS^ | MINUS^) atom) > ; > > so 1 + 2 * 3 gives (+ 1 (* 2 3)) (LISPy representations) > Interesting. In rockit I've used a different but similar thing: mult_expr: add_expr STAR add_expr [Mult: left, _, right] | add_expr SLASH add_expr [Div: nom, _, denom] add_expr: atom PLUS atom [Plus: left, _, right] | atom MINUS atom [Minus: left, _, right] atom: NUMBER [^] but as you see it's not as terse even though its more flexible. Maybe should learn from ANTLR here... Thanks for the intro, Robert