[antlr-interest] Read multiple times
Hiten R
antlr3 at gmail.com
Fri Mar 18 15:24:22 PDT 2011
Hi everyone,
I have a very simple problem described below and I don`t have a best way to
solve it. The idea is to parse values in each Basket and populate POJO
representing the Basket.
Basket 200
state California 246
employee 678
phone 555-9000 ext 90009
zip 0909090
Basket 300
state NY 787
emp.....
phone .......
zip......
My parser parses the first line 'state California 246' and then moves to
another basket. I want to recursively parse each line under basket and at
the end populate POJO and then move to another basket.
So any help would be appreciated.
Thx
H
Grammar below
basket
@init {
Basket basket;
String state= "";
String employee= "";
String phone= "";
String zip= "";
}
@after {
basket= new Basket(state, employee);
basket.setPhone(phone);
this.somelist.addBakets(basket);
print(basket.toString());
//start again
parse(); --------? Is this right approach
}
: 'state' st=TOKEN { state= $st.text; }
| 'employee' et=TOKEN { employee= $et.text; }
| 'phone' pt=TOKEN { phone= $pt.text; }
| 'zip'
;
More information about the antlr-interest
mailing list