[antlr-interest] processing not binary tree in antlr 2.7
Kamil Demecki
skajotde at gmail.com
Thu Mar 1 12:44:28 PST 2012
Hi All,
I'm using antrlr 2.7 and parsing my data to tree is working for me but
it is binary tree and in my case I would prefer tree with many
siblings.
For input {[a1:1;a2:2;a3:3;a4:4];b} program prints tree ( ; ( ; ( ; (
; a1 1 a2 2 ) a3 3 ) a4 4 ) b )
Final effect should look like result (in java but for clean I use
python notation):
a = StructAtr({a1:Attr(1), a2:Attr(2), a3:Attr(3), a4:Attr(4)})
result = SeqAttr([a, Attr(b)])
What is preffered way to do it in antrlr 2.7?
class AttrLexer extends Lexer;
WS : (' ' | '\t' | '\n' | '\r') { _ttype = Token.SKIP; }
;
SEP
: ';'
;
STRUCT_SEP
: ':'
;
SEQ_START
: '{'
;
SEQ_END
: '}'
;
STRUCT_START
: '['
;
STRUCT_END
: ']'
;
VALUE
: (('0'..'9') | ('a'..'z') | ('A'..'Z'))+
;
Thanks in advance.
BR//Kamil Demecki
More information about the antlr-interest
mailing list