[antlr-interest] Checking for expression end in Javascript parser
Tech
tech at swingkid.fsnet.co.uk
Wed Oct 26 13:29:43 PDT 2005
Absolutely, poor wording on my part. I guess I should have said
'Javascript statements end at either a semi colon, or the earliest new
line that makes a valid statement.'
Given this, should
a=3
count as a complete statement on it's own line? My parser won't treat is
as such because the expressions are nested, so I hope not!
Mark
shmuel siegel wrote:
> Tech wrote:
>
>> 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.
>
>
> As far as I know, this is not a valid definition for javascript
> statements. It is true for control statements like "return" or "break"
> but not for arithmetic statements.
>
> Consider,
> <script>
> a=3
> +4
> alert(a);
> </script>
>
> It is legal and will result in an alert with the value 7. In general,
> a new line only marks the end of a statement if the next token cannot
> be part of the previous pattern.
>
>
More information about the antlr-interest
mailing list