How do I recognize tokens defined as "from here to end of line" such as in a "print" command where the argument is everything after the "print" to end of line?

Terence Parr

You should be able to do a "while not end-of-line" loop like:

/** Match print then anything until eol */
PRINT : "print" (~'
')* '
'! ;

Note that the PRINT token returned to the parser will contain the entire PRINT command including all text until end of line, but not end of line (since I put a ! suffix on it). To return just the print argument, put a ! on the "print" reference in the rule.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact