[antlr-interest] virtual semicolons again: JavaScript, ECMAScript, ActionScript

Shmuel Siegel ssiegel at finjan.com
Thu Dec 28 03:32:05 PST 2006


Actually, if antlr is used to verify javascript syntax, using optional
semicolons would cause illegal programs to pass the verifier.

Consider:
	A=B  C=D

As opposed to
	A=B
	C=D

The first is illegal, the second is legal (at least as far as ie 6 is
concerned);

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Shmuel Siegel
Sent: Thursday, December 28, 2006 12:48 PM
To: ANTLR Interest
Subject: Re: [antlr-interest] virtual semicolons again:
JavaScript,ECMAScript, ActionScript

Gavin,

Working backwards through your suggestions:
1) I haven't come across a complete EBNF grammar of ECMAScript. They
seem to always leave out some definitions, especially in the tokenizer.
They also ignore the virtual semicolon issues and leave that to verbal
descriptions. I also haven't seen an EBNF grammar that took regular
expressions into account.

2) You are definitely right that you don't want to deal with newlines at
the parser level. Once you start to allow it, you have to deal with it
everywhere. It quickly gets out of hand.

3) There are certainly two categories of statements that need to deal
with the concept of virtual semicolons or newlines, whichever you prefer
	a) Control statements like break, return, throw, and continue
since the newline has semantic meaning.
	b) pre and post increment/decrement.

It is probably worth determining if the normal termination rules in
ANTLR3 can handle everything else by just using optional semicolons. It
is too hard of a question to answer without investigation.



More information about the antlr-interest mailing list