Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #28986

Re: <!--

Path csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: <!--
Date Mon, 07 Dec 2015 15:01:45 +0100
Organization PointedEars Software (PES)
Lines 44
Message-ID <5333913.KbEaQyBAFF@PointedEars.de> (permalink)
References <comment-20151207122517@ram.dialup.fu-berlin.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace solani.org 1449496907 28459 eJwNxskRwDAIBLCWDCxHyglX/yXYo49UjKwcpgbdp+OVJGU3ObyobRnDLXNOAv61W/zT2PSuCxhsEW0= (7 Dec 2015 14:01:47 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Mon, 7 Dec 2015 14:01:47 +0000 (UTC)
User-Agent KNode/4.14.2
X-User-ID eJwNyskRwEAIA7CWlsMwlEOcdf8lJHoLUVbsLFRC0B2+it5zLhGh4wXnfzaHbl0a7TX0tGmyOLbIIwB86PoATYQVPA==
Cancel-Lock sha1:7TJ+nNjvV2WDYYaKYn2egm8XgQI=
X-NNTP-Posting-Host eJwNx8ERwDAIA7CVwoEN6zhQ9h+h0U9wGjuDYGCx0imbxuR5+1bRJojFuXerUo0YZsA58v0BOFYR9A==
Xref csiph.com comp.lang.javascript:28986

Show key headers only | View raw


Stefan Ram wrote:

>   I tried the following with the Firefox console (one line of
>   input, one line of output, and one blank line is given below):
> 
> <
> SyntaxError: expected expression, got '<'
> 
> <!
> SyntaxError: expected expression, got '<'
> 
> <!-
> SyntaxError: expected expression, got '<'
> 
> <!--
> undefined
> 
>   So, when I input arbitrary symbols, it usually gives me a
>   syntax error.

Those are not arbitrary symbols; the first one is an operator that requires 
two operands.

>   But when I hit »<!--«, it does not say
>   »SyntaxError«, but »undefined«. Where is the production in
>   the grammar of JavaScript that allows this »<!--«?

I presume that “<!--”, at least at the beginning of a program, is parsed 
like “//” in Mozilla JavaScript was built into SpiderMonkey after people 
abused HTML comments to hide improperly escaped “script” element content 
from improperly working HTML parsers and the (properly working) W3C 
Validator.  That is one of the syntax extensions allowed by the 
“Conformance” section of ECMAScript Editions.

And so this program is empty; there is no remaining expression, the missing 
statement gets automatic semicolon insertion for the empty statement (ES 6, 
§ 13.4), and the program’s result is the “undefined” value.  See ES 5.1 for 
the /Program/ production; I could not find it in ES 6.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: <!-- Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-07 15:01 +0100
  Re: <!-- Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-07 20:33 +0100
  Re: <!-- John Harris <niam@jghnorth.org.uk.invalid> - 2015-12-08 11:02 +0000

csiph-web