Thursday 15 July 2010

java - antlr3 - ignore a token / parse it only once -


At this time I try to parse

" play such text The band by

to parse an order for a mediation, by the way play and by the name of a song or artist is a token, I have problems, how can I ignore multiple tokens in song names and artists, or can I parse the token once in the instructions?

My .g file is:

  Text Returns [String Value]: Speech = Exxp (Space s1 = name)? (Bartist Space A1 = Name)? {Command = $ speech.text ; Match = $ s1.text; artist = $ a1.text;}; name: s1 = (WORD (space s2 = WORD) *); Bartivi: Space BY; WordExp: PLAY | Pause; // Lexer Play: 'Play' ; Wait: 'BY': '' Location: ''; WORD: ('a' .. 'z' | 'A' .. 'Z') *; // points here: WS: ('\ t '|' \ R '|' \ n ') {$ channel = HIDDEN;};  


No comments:

Post a Comment