Should "Literal" in syntactical grammar instead of lexical grammar?

# 程劭非 (14 years ago)

everyone,

I'm working a on ES parser recently and noticed something might be wrong about the symbol “Literal”.

Since “Literal” and “StringLiteral" "NumericLiteral" appears in lexical grammar , I believe “Literal” should be a non-terminal symbol. Also there is no other rule using “Literal” in lexical grammar. As all above I think the following description is a syntactical grammar rule instead of a lexical grammar rule: *Literal **:: ** *NullLiteral

BooleanLiteral NumericLiteral StringLiteral RegularExpressionLiteral So my suggest is moving the description from Annex A.1 to Annex A.3

Thanks, Shaofei Cheng

# Brendan Eich (14 years ago)

Indeed this has come up before:

mail.mozilla.org/pipermail/es5-discuss/2011-January/003900.html

No one replied then, alas.

There's no normative significance, as Michael Dyck conjectured. It seems we could move Literal. Perhaps Waldemar or Allen has a preference. At this point I am ok with letting the traditional location of Literal stand.

# Allen Wirfs-Brock (14 years ago)

Yes, Literal could be moved to the syntactic grammar. There is already some grammar refactoring like this going on in the Es6 draft.

The best way to capture these sorts of editorial issues is to file a bug using bugs.ecmascript.org against the current Es6 draft.

# 程劭非 (14 years ago)

Thank you for the comments.

There might be no normative significance but I mean there is no way to put the "Literal" production in a lexer. If a lexer produce token with type ”Literal“, syntactical parser will not be able to decide to use it as a ”Literal“ or a ”StringLiteral“.

So I think keeping this rule in current location might confuse the ones who want to implement this spec.

Thanks, Shaofei Cheng

2012/2/28 Brendan Eich <brendan at mozilla.org>

# 程劭非 (14 years ago)

Thank you, Allen.

I've checked ES6 draft and reported a bug. see ecmascript#281

2012/2/29 Allen Wirfs-Brock <allen at wirfs-brock.com>

# Brendan Eich (14 years ago)

程劭非 wrote:

Thank you for the comments.

There might be no normative significance but I mean there is no way to put the "Literal" production in a lexer. If a lexer produce token with type ”Literal“, syntactical parser will not be able to decide to use it as a ”Literal“ or a ”StringLiteral“.

Good point.

So I think keeping this rule in current location might confuse the ones who want to implement this spec.

Agreed.