tags:

views:

64

answers:

1

Hi I have this grammar for now, but when I have after a service, a note. Antlr doesn't want to recognize that it's not the service, but note. And service and note have different structure. How to write this?

I'm trying to parse this. but NOTE bla bla; is in service

777014322;O2 Optimum Profi Promo;

Free sms;0:00;250:00;0:00;

NOTE bla bla;

STM;



thank you.

    grammar teste;

file : phoneNumber*;

phoneNumber
 : number SEPARATOR tariff SEPARATOR? newline

  service*  
  note? 
  stm SEPARATOR* newline

 ;


note : NOTE TEXT SEPARATOR? newline;

service
 : TEXT SEPARATOR TEXT SEPARATOR TEXT SEPARATOR TEXT SEPARATOR? newline;



stm : STM;

tariff : TEXT;

newline : NEWLINE*;

number : NUMBER;

separator : SEPARATOR;


NOTE : 'NOTE';

STM : 'STM';

NEWLINE : '\r'? '\n';

NUMBER : (DIGIT)+ ;

SEPARATOR : ';';

TEXT  : ~(';' | '\r' | '\n')+;


fragment DIGIT : '0'..'9' ;
A: 

I've finally solved very easy by modifying NOTE to:

NOTE : 'NOTE'TEXT;

even though I'm not sure if my grammar is really good.

But I'm not sure if am able to get text into java variable from this. hope yes.

blefesd