[antlr-interest] Checking for expression end in Javascript parser

Tech tech at swingkid.fsnet.co.uk
Tue Oct 25 00:11:53 PDT 2005


Hi all,
       I am new to ANTLR, and am writing a (basic) Javascript grammer, 
based on Todd King's C# grammer (mostly because it was very clean and 
easy to understand, thanks Todd).
One aspect that is different is that Javascript expressions end either 
at a semi colon, or at the earliest new line that makes a valid 
expression. However, I don't really want to include newline characters 
in the parser, as you'd have to add them in everywhere. I was thinking 
of trying to use a semantic predicate that checked the line number of 
the current token against the line number of the next token just for 
expression statements. How do you programatically reference the current 
token being checked? Is it always effectively LT(1)?
If there is a better approach, I would be interested to know it. This is 
only really out of academic interest, currently my solution is to assume 
the input file is well written javascript ;-)

Thanks,

Mark


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.361 / Virus Database: 267.12.5/147 - Release Date: 24/10/2005




More information about the antlr-interest mailing list