New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suffix "opt" are missing in one line grammar (ex. 13.7.4.5) #908

Open
kotarondo opened this Issue May 2, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@kotarondo

kotarondo commented May 2, 2017

Summary

For example, in 13.7.4.5
current draft and ES7 displays one line grammar as

IterationStatement : for ( LexicalDeclaration Expression ; Expression ) Statement
    Return the VarDeclaredNames of Statement.

If it is read literally, it does not define anything on the following grammar.

IterationStatement : for ( LexicalDeclaration ; ) Statement
IterationStatement : for ( LexicalDeclaration Expression ; ) Statement
IterationStatement : for ( LexicalDeclaration ; Expression ) Statement

This is not what we intend.

On the other hand, ES6 displays:

IterationStatement : for ( LexicalDeclaration Expression opt ; Expression opt ) Statement
    Return the VarDeclaredNames of Statement.

This is more comprehensive because "opt" is expanded as shown in "5.1.5 Grammar Notation".

NOTE1: How are "opt" suffixes dropped ?

Actually, in the raw html document, these Expressions are given opt suffix,
but they are not displayed because of "ecmarkup.css" line 249:

emu-production[collapsed] emu-mods {
  display: none;
}

Here "collapsed" attributes on "emu-production" are given in the build process.
Precisely, they are given in grammarkdown/out/lib/emitter/ecmarkup.js line 36:

    else if (node.body.kind === tokens_1.SyntaxKind.RightHandSide) {
        this.writer.write(" collapsed");
    }

where grammarkdown is a npm module called from ecmarkup build tool.

By the way, opt suffixes are DISPLAYED in multiline grammars (ex. 13.7.4.4)
because node.body.kind === tokens_1.SyntaxKind.RightHandSideList.

Anyway, I think the specification contents must be self-contained except for its displaying formats (fonts, etc). Outside format tools must not change the specification contents.

Note2

You can not say "opt suffix is automatically inserted when the corresponding Syntax has it."
because expanded grammars may be referred separately.

For example, In 13.3.2.4

VariableDeclaration : BindingIdentifier
    Return NormalCompletion(empty).

VariableDeclaration : BindingIdentifier Initializer
    Let bindingId be StringValue of BindingIdentifier.
    Let lhs be ? ResolveBinding(bindingId).
    ...

Here we can not insert opt suffix after Initializer
although the corresponding Syntax has it.

@kotarondo

This comment has been minimized.

Show comment
Hide comment
@kotarondo

kotarondo May 4, 2017

Another example for Note2

In 13.3.3.2 Static Semantics: ContainsExpression

BindingElement: BindingPattern Initializer
    Return true.

Here you can insert 'opt' suffix after 'Initializer' without any formal contradiction on the spec, but it produces an unexpected specification.

kotarondo commented May 4, 2017

Another example for Note2

In 13.3.3.2 Static Semantics: ContainsExpression

BindingElement: BindingPattern Initializer
    Return true.

Here you can insert 'opt' suffix after 'Initializer' without any formal contradiction on the spec, but it produces an unexpected specification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment