[prev in list] [next in list] [prev in thread] [next in thread]
List: antlr-interest
Subject: [antlr-interest] node construction proposed upgrade
From: Terence Parr <parrt () cs ! usfca ! edu>
Date: 2011-02-26 21:45:54
Message-ID: 3905B53A-0C9D-4CEC-ACAD-14C8EBA24281 () cs ! usfca ! edu
[Download RAW message or body]
At moment you can set hetero node type with token option:
type : ID<TypeNode> ;
var : ID<VarNode> ;
Sometimes you want to set token type / text of node. can use -> now
type : ID -> TYPENAME[$ID] ; // sets new token type for ID; copies text, line, col
a : lc='{' ... '}' -> BLOCK[$lc, "BLOCK"] ; // sets new token type and text
Inline i'm proposing two new token option names: text, ttype to join current options node and assoc.
type : ID<ttype=TYPENAME> ;
a : '{'<ttype=BLOCK, text="BLOCK"> ... '}' ;
My motivation is this
| e '?'^ e ':' e
following is gross but would work:
| e '?'<type=TERNARY, text="?:">^ e ':' e
we could also mimic rewrite stuff by allowing args on tokens in parser rules:
| e '?'[TERNARY, "?:"]^ e ':' e
what say ye? 2nd option is appealing but slightly diff fom how rewrite element args work.
Ter
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic