Loading ...
Sorry, an error occurred while loading the content.

Posssible to handle MismatchedToken at the rule level by pushing tokens onto the stream?

Expand Messages
  • Millaway, John
    Is it possible to handle ALL MismatchedToken by pushing token(s) into the input stream, then retrying at that same point? By ALL , I mean anywhere during the
    Message 1 of 2 , Jun 30, 2000
    • 0 Attachment
      Is it possible to handle ALL MismatchedToken by pushing token(s) into the
      input stream, then retrying at that same point? By "ALL", I mean "anywhere
      during the parse". Would I have to specify this behavior for EVERY rule?
      (There are more than one hundred of them)


      Here;s why I ask...
      The ECMAScript spec calls for some very interesting behavior:

      If an "offending token" is found during parsing right after an EOL, [...]
      then a semi-colon is inserted into the token stream before the "offending
      token" and the parsing continues. Semicolons are not inserted if they would
      be parsed as an empty statement, or one of the two semicolons in a for()
      statement (and a few other conditions).


      What this means is that a ';' is not optional in the language specification,
      but the parser is responsible for correcting missing ';'s!

      Thanks.
    • dan.stanger@ieee.org
      this should be easy to do with a token stream filter. just maintain a 1 token queue in the filter, and assign a token type to EOL. when you encounter EOL in
      Message 2 of 2 , Jul 5, 2000
      • 0 Attachment
        this should be easy to do with a token stream filter. just maintain
        a 1 token queue in the filter, and assign a token type to EOL.
        when you encounter EOL in the filter, check if the token before it was
        a SEMI, if not send it out.

        --- In antlr-interest@egroups.com, "Millaway, John" <john@i...> wrote:
        >
        > Is it possible to handle ALL MismatchedToken by pushing token(s)
        into the
        > input stream, then retrying at that same point? By "ALL", I mean
        "anywhere
        > during the parse". Would I have to specify this behavior for EVERY
        rule?
        > (There are more than one hundred of them)
        >
        >
        > Here;s why I ask...
        > The ECMAScript spec calls for some very interesting behavior:
        >
        > If an "offending token" is found during parsing right after an EOL,
        [...]
        > then a semi-colon is inserted into the token stream before the
        "offending
        > token" and the parsing continues. Semicolons are not inserted if
        they would
        > be parsed as an empty statement, or one of the two semicolons in a
        for()
        > statement (and a few other conditions).
        >
        >
        > What this means is that a ';' is not optional in the language
        specification,
        > but the parser is responsible for correcting missing ';'s!
        >
        > Thanks.
      Your message has been successfully submitted and would be delivered to recipients shortly.