On the syntax edge

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alexis Nikichine

    #1

    On the syntax edge

    I have mistakenly left in my code an uncommented url:



    function theFunction()
    {
    // do something.
    }

    Fortunately, everything went fine:

    * The ugly part, with many undeclared identifiers, was commented out
    by the //.
    * http: was interpreted as something, strange.

    Actually, it may have something to do with the syntax with which object
    literals can be declared in javascript, but I can't understand why. It
    seems that I can prefix most, if not all, lines of code, with any
    prefix, followed by a colon, without any noticeable effect.

    Any insight on this welcome; anyway, this had to be shared :-)


    Alexis

    --
    somedomain is free.
  • Martin Honnen

    #2
    Re: On the syntax edge



    Alexis Nikichine wrote:
    [color=blue]
    > I have mistakenly left in my code an uncommented url:
    >
    >
    > http://site.for.this.function.domain/folder/file.html[/color]

    [color=blue]
    > Fortunately, everything went fine:
    >
    > * The ugly part, with many undeclared identifiers, was commented out
    > by the //.
    > * http: was interpreted as something, strange.[/color]

    It is a label, see
    <http://web.archive.org/web/20031209125559/devedge.netscap e.com/library/manuals/2000/javascript/1.5/reference/stmt.html#10180 88>

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    • Michael Winter

      #3
      Re: On the syntax edge

      On Thu, 13 Jan 2005 16:52:18 +0100, Alexis Nikichine
      <alexis.nikichi ne@somedomain.f r> wrote:
      [color=blue]
      > http://site.for.this.function.domain/folder/file.html
      > function theFunction()
      > {
      > // do something.
      > }[/color]

      [snip]
      [color=blue]
      > Any insight on this welcome; anyway, this had to be shared :-)[/color]

      As Martin said, the "http:" will be (initially) interpreted as a labelled
      statement. The syntax is simple:

      LabelledStateme nt:
      Identifier : Statement

      where "Identifier " is any name that conforms to identifier rules, and
      "Statement" is any legal statement.

      However, a function declaration is not a legal statement so a strict
      parser would raise an error when it encountered the theFunction
      declaration.

      Mike

      --
      Michael Winter
      Replace ".invalid" with ".uk" to reply by e-mail.

      Comment

      Working...