Inline grammar into spec source to fix link issue
This commit is contained in:
Родитель
0d9e383315
Коммит
009d15928a
|
@ -15,18 +15,14 @@
|
|||
"url": "git+https://github.com/Azure/adl.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run generate-grammar && npm run generate-spec",
|
||||
"watch": "watch \"node scripts/watch-spec-handler.js\" ./src",
|
||||
"generate-grammar": "mkdirp temp && grammarkdown --newLine LF src/language.grammar --out temp/grammar.emu.html --format ecmarkup",
|
||||
"generate-spec": "ecmarkup src/spec.emu.html ../../docs/spec.html"
|
||||
"build": "ecmarkup src/spec.emu.html ../../docs/spec.html",
|
||||
"watch": "watch \"node scripts/watch-spec-handler.js\" ./src"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@types/mkdirp": "~1.0.1",
|
||||
"@types/node": "14.0.27",
|
||||
"ecmarkup": "^7.0.3",
|
||||
"grammarkdown": "^3.1.2",
|
||||
"mkdirp": "~1.0.4",
|
||||
"prettier": "~2.2.1",
|
||||
"typescript": "~4.1.5",
|
||||
"watch": "^1.0.2"
|
||||
|
|
|
@ -1,296 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// Lexical Grammar
|
||||
|
||||
SourceCharacter :
|
||||
> any Unicode code point
|
||||
|
||||
InputElement :
|
||||
Token
|
||||
Trivia
|
||||
|
||||
Token:
|
||||
Keyword
|
||||
Identifier
|
||||
NumericLiteral
|
||||
StringLiteral
|
||||
Punctuator
|
||||
|
||||
Trivia :
|
||||
Comment
|
||||
WhiteSpace
|
||||
LineTerminator
|
||||
|
||||
Keyword :
|
||||
BooleanLiteral
|
||||
`import`
|
||||
`model`
|
||||
`namespace`
|
||||
`op`
|
||||
`extends`
|
||||
`using`
|
||||
|
||||
Identifier :
|
||||
IdentifierName but not Keyword
|
||||
|
||||
IdentifierName :
|
||||
IdentifierStart
|
||||
IdentifierName IdentifierContinue
|
||||
|
||||
IdentifierStart :
|
||||
> any Unicode code point with the Unicode property "ID_Start" or "Other_ID_Start"
|
||||
`$`
|
||||
`_`
|
||||
|
||||
IdentifierContinue :
|
||||
> any Unicode code point with the Unicode property "ID_Continue" or "Other_ID_Continue", or "Other_ID_Start"
|
||||
`$`
|
||||
`_`
|
||||
<ZWNJ>
|
||||
<ZWJ>
|
||||
|
||||
BooleanLiteral :
|
||||
`true`
|
||||
`false`
|
||||
|
||||
NumericLiteral :
|
||||
DecimalLiteral
|
||||
HexIntegerLiteral
|
||||
|
||||
DecimalLiteral :
|
||||
DecimalIntegerLiteral `.` DecimalDigits? ExponentPart?
|
||||
DecimalIntegerLiteral ExponentPart?
|
||||
|
||||
DecimalIntegerLiteral :
|
||||
DecimalDigits
|
||||
|
||||
DecimalDigits :
|
||||
DecimalDigit
|
||||
DecimalDigits DecimalDigit
|
||||
|
||||
DecimalDigit :
|
||||
one of `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
|
||||
|
||||
ExponentPart :
|
||||
`e` SignedInteger
|
||||
|
||||
SignedInteger :
|
||||
DecimalDigits
|
||||
`+` DecimalDigits
|
||||
`-` DecimalDigits
|
||||
|
||||
HexIntegerLiteral :
|
||||
`0x` HexDigits
|
||||
|
||||
HexDigits :
|
||||
HexDigit
|
||||
HexDigits HexDigit
|
||||
|
||||
HexDigit :
|
||||
one of `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` `a` `b` `c` `d` `e` `f` `A` `B` `C` `D` `E` `F`
|
||||
|
||||
BinaryIntegerLiteral :
|
||||
`0b` BinaryDigits
|
||||
|
||||
BinaryDigits :
|
||||
BinaryDigit
|
||||
BinaryDigits BinaryDigit
|
||||
|
||||
BinaryDigit :
|
||||
one of `0` `1`
|
||||
|
||||
// TODO: triple-quoted strings not specified yet, tricky to express.
|
||||
|
||||
StringLiteral :
|
||||
`"` StringCharacters? `"`
|
||||
|
||||
StringCharacters :
|
||||
StringCharacter StringCharacters?
|
||||
|
||||
StringCharacter :
|
||||
SourceCharacter but not one of `"` or `\`
|
||||
`\` EscapeCharacter
|
||||
|
||||
EscapeCharacter :
|
||||
one of `"` `r` `n` `t` `\`
|
||||
|
||||
Punctuator :
|
||||
one of `|` `?` `=` `&` `:` `,` `;` `.` `<` `>` `(` `)` `{` `}` `[` `]` `@` `...`
|
||||
|
||||
WhiteSpace :
|
||||
<TAB>
|
||||
<VT>
|
||||
<FF>
|
||||
<SP>
|
||||
<NBSP>
|
||||
<ZWNBSP>
|
||||
<USP>
|
||||
|
||||
LineTerminator :
|
||||
<LF>
|
||||
<CR>
|
||||
<LS>
|
||||
<PS>
|
||||
|
||||
Comment :
|
||||
MultiLineComment
|
||||
SingleLineComment
|
||||
|
||||
MultiLineComment :
|
||||
`/*` MultiLineCommentChars? `*/`
|
||||
|
||||
MultiLineCommentChars :
|
||||
MultiLineNotAsteriskChar MultiLineCommentChars?
|
||||
`*` PostAsteriskCommentChars?
|
||||
|
||||
PostAsteriskCommentChars :
|
||||
MultiLineNotForwardSlashOrAsteriskChar MultiLineCommentChars?
|
||||
`*` PostAsteriskCommentChars?
|
||||
|
||||
MultiLineNotAsteriskChar :
|
||||
SourceCharacter but not `*`
|
||||
|
||||
MultiLineNotForwardSlashOrAsteriskChar :
|
||||
SourceCharacter but not one of `/` or `*`
|
||||
|
||||
SingleLineComment :
|
||||
`//` SingleLineCommentChars?
|
||||
|
||||
SingleLineCommentChars :
|
||||
SingleLineCommentChar SingleLineCommentChars?
|
||||
|
||||
SingleLineCommentChar :
|
||||
SourceCharacter but not LineTerminator
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Syntactic Grammar
|
||||
|
||||
ADLScript :
|
||||
ADLScriptItemList?
|
||||
|
||||
ADLScriptItemList :
|
||||
ADLScriptItemList? ADLScriptItem
|
||||
|
||||
ADLScriptItem :
|
||||
BlocklessNamespaceStatement
|
||||
ImportStatement
|
||||
Statement
|
||||
|
||||
BlocklessNamespaceStatement :
|
||||
DecoratorList? `namespace` IdentifierOrMemberExpression `;`
|
||||
|
||||
ImportStatement :
|
||||
`import` StringLiteral `;`
|
||||
|
||||
StatementList :
|
||||
StatementList? Statement
|
||||
|
||||
Statement :
|
||||
ModelStatement
|
||||
NamespaceStatement
|
||||
OperationStatement
|
||||
UsingStatement
|
||||
`;`
|
||||
|
||||
UsingStatement :
|
||||
`using` IdentifierOrMemberExpression `;`
|
||||
|
||||
ModelStatement :
|
||||
DecoratorList? `model` Identifier TemplateParameters? ModelHeritage? `{` ModelBody? `}`
|
||||
DecoratorList? `model` Identifier TemplateParameters? `=` Expression `;`
|
||||
|
||||
ModelHeritage :
|
||||
`extends` ReferenceExpressionList
|
||||
|
||||
ReferenceExpressionList :
|
||||
ReferenceExpression
|
||||
ReferenceExpressionList `,` ReferenceExpression
|
||||
|
||||
TemplateParameters :
|
||||
`<` IdentifierList `>`
|
||||
|
||||
IdentifierList :
|
||||
Identifier
|
||||
IdentifierList `,` Identifier
|
||||
|
||||
ModelBody :
|
||||
ModelPropertyList `,`?
|
||||
ModelPropertyList `;`?
|
||||
|
||||
ModelPropertyList :
|
||||
ModelProperty
|
||||
ModelPropertyList `,` ModelProperty
|
||||
ModelPropertyList `;` ModelProperty
|
||||
|
||||
ModelProperty:
|
||||
ModelSpreadProperty
|
||||
DecoratorList? Identifier `?`? `:` Expression
|
||||
DecoratorList? StringLiteral `?`? `:` Expression
|
||||
|
||||
ModelSpreadProperty :
|
||||
`...` ReferenceExpression
|
||||
|
||||
NamespaceStatement:
|
||||
DecoratorList? `namespace` IdentifierOrMemberExpression `{` StatementList? `}`
|
||||
|
||||
OperationStatement :
|
||||
DecoratorList? `op` Identifier `(` ModelPropertyList? `)` `:` Expression `;`
|
||||
|
||||
Expression :
|
||||
UnionExpressionOrHigher
|
||||
|
||||
UnionExpressionOrHigher :
|
||||
IntersectionExpressionOrHigher
|
||||
UnionExpressionOrHigher `|` IntersectionExpressionOrHigher
|
||||
|
||||
IntersectionExpressionOrHigher :
|
||||
ArrayExpressionOrHigher
|
||||
IntersectionExpressionOrHigher `&` ArrayExpressionOrHigher
|
||||
|
||||
ArrayExpressionOrHigher :
|
||||
PrimaryExpression
|
||||
ArrayExpressionOrHigher `[` `]`
|
||||
|
||||
PrimaryExpression :
|
||||
Literal
|
||||
ReferenceExpression
|
||||
ParenthesizedExpression
|
||||
ModelExpression
|
||||
TupleExpression
|
||||
|
||||
Literal :
|
||||
StringLiteral
|
||||
BooleanLiteral
|
||||
NumericLiteral
|
||||
|
||||
ReferenceExpression :
|
||||
IdentifierOrMemberExpression TemplateArguments?
|
||||
|
||||
IdentifierOrMemberExpression :
|
||||
Identifier
|
||||
IdentifierOrMemberExpression `.` Identifier
|
||||
|
||||
TemplateArguments :
|
||||
`<` ExpressionList `>`
|
||||
|
||||
ParenthesizedExpression :
|
||||
`(` Expression `)`
|
||||
|
||||
ModelExpression :
|
||||
`{` ModelBody? `}`
|
||||
|
||||
TupleExpression :
|
||||
`[` ExpressionList `]`
|
||||
|
||||
ExpressionList :
|
||||
Expression
|
||||
ExpressionList `,` Expression
|
||||
|
||||
DecoratorList :
|
||||
DecoratorList? Decorator
|
||||
|
||||
Decorator :
|
||||
`@` IdentifierOrMemberExpression DecoratorArguments?
|
||||
|
||||
DecoratorArguments :
|
||||
`(` ExpressionList? `)`
|
|
@ -7,7 +7,306 @@ copyright: false
|
|||
<p>This document will eventually have a full specification for ADL. For now, it just has the grammar below.</p>
|
||||
</emu-intro>
|
||||
|
||||
<emu-clause id="grammar">
|
||||
<h1>Grammar</h1>
|
||||
<emu-import href="../temp/grammar.emu.html" />
|
||||
<emu-clause id="lexical-grammar">
|
||||
<h1>Lexical Grammar</h1>
|
||||
<emu-grammar type="definition">
|
||||
<![CDATA[
|
||||
SourceCharacter :
|
||||
> any Unicode code point
|
||||
|
||||
InputElement :
|
||||
Token
|
||||
Trivia
|
||||
|
||||
Token:
|
||||
Keyword
|
||||
Identifier
|
||||
NumericLiteral
|
||||
StringLiteral
|
||||
Punctuator
|
||||
|
||||
Trivia :
|
||||
Comment
|
||||
WhiteSpace
|
||||
LineTerminator
|
||||
|
||||
Keyword :
|
||||
BooleanLiteral
|
||||
`import`
|
||||
`model`
|
||||
`namespace`
|
||||
`op`
|
||||
`extends`
|
||||
`using`
|
||||
|
||||
Identifier :
|
||||
IdentifierName but not Keyword
|
||||
|
||||
IdentifierName :
|
||||
IdentifierStart
|
||||
IdentifierName IdentifierContinue
|
||||
|
||||
IdentifierStart :
|
||||
> any Unicode code point with the Unicode property "ID_Start" or "Other_ID_Start"
|
||||
`$`
|
||||
`_`
|
||||
|
||||
IdentifierContinue :
|
||||
> any Unicode code point with the Unicode property "ID_Continue" or "Other_ID_Continue", or "Other_ID_Start"
|
||||
`$`
|
||||
`_`
|
||||
<ZWNJ>
|
||||
<ZWJ>
|
||||
|
||||
BooleanLiteral :
|
||||
`true`
|
||||
`false`
|
||||
|
||||
NumericLiteral :
|
||||
DecimalLiteral
|
||||
HexIntegerLiteral
|
||||
|
||||
DecimalLiteral :
|
||||
DecimalIntegerLiteral `.` DecimalDigits? ExponentPart?
|
||||
DecimalIntegerLiteral ExponentPart?
|
||||
|
||||
DecimalIntegerLiteral :
|
||||
DecimalDigits
|
||||
|
||||
DecimalDigits :
|
||||
DecimalDigit
|
||||
DecimalDigits DecimalDigit
|
||||
|
||||
DecimalDigit :
|
||||
one of `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
|
||||
|
||||
ExponentPart :
|
||||
`e` SignedInteger
|
||||
|
||||
SignedInteger :
|
||||
DecimalDigits
|
||||
`+` DecimalDigits
|
||||
`-` DecimalDigits
|
||||
|
||||
HexIntegerLiteral :
|
||||
`0x` HexDigits
|
||||
|
||||
HexDigits :
|
||||
HexDigit
|
||||
HexDigits HexDigit
|
||||
|
||||
HexDigit :
|
||||
one of `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` `a` `b` `c` `d` `e` `f` `A` `B` `C` `D` `E` `F`
|
||||
|
||||
BinaryIntegerLiteral :
|
||||
`0b` BinaryDigits
|
||||
|
||||
BinaryDigits :
|
||||
BinaryDigit
|
||||
BinaryDigits BinaryDigit
|
||||
|
||||
BinaryDigit :
|
||||
one of `0` `1`
|
||||
|
||||
// TODO: triple-quoted strings not specified yet, tricky to express.
|
||||
|
||||
StringLiteral :
|
||||
`"` StringCharacters? `"`
|
||||
|
||||
StringCharacters :
|
||||
StringCharacter StringCharacters?
|
||||
|
||||
StringCharacter :
|
||||
SourceCharacter but not one of `"` or `\`
|
||||
`\` EscapeCharacter
|
||||
|
||||
EscapeCharacter :
|
||||
one of `"` `r` `n` `t` `\`
|
||||
|
||||
Punctuator :
|
||||
one of `|` `?` `=` `&` `:` `,` `;` `.` `<` `>` `(` `)` `{` `}` `[` `]` `@` `...`
|
||||
|
||||
WhiteSpace :
|
||||
<TAB>
|
||||
<VT>
|
||||
<FF>
|
||||
<SP>
|
||||
<NBSP>
|
||||
<ZWNBSP>
|
||||
<USP>
|
||||
|
||||
LineTerminator :
|
||||
<LF>
|
||||
<CR>
|
||||
<LS>
|
||||
<PS>
|
||||
|
||||
Comment :
|
||||
MultiLineComment
|
||||
SingleLineComment
|
||||
|
||||
MultiLineComment :
|
||||
`/*` MultiLineCommentChars? `*/`
|
||||
|
||||
MultiLineCommentChars :
|
||||
MultiLineNotAsteriskChar MultiLineCommentChars?
|
||||
`*` PostAsteriskCommentChars?
|
||||
|
||||
PostAsteriskCommentChars :
|
||||
MultiLineNotForwardSlashOrAsteriskChar MultiLineCommentChars?
|
||||
`*` PostAsteriskCommentChars?
|
||||
|
||||
MultiLineNotAsteriskChar :
|
||||
SourceCharacter but not `*`
|
||||
|
||||
MultiLineNotForwardSlashOrAsteriskChar :
|
||||
SourceCharacter but not one of `/` or `*`
|
||||
|
||||
SingleLineComment :
|
||||
`//` SingleLineCommentChars?
|
||||
|
||||
SingleLineCommentChars :
|
||||
SingleLineCommentChar SingleLineCommentChars?
|
||||
|
||||
SingleLineCommentChar :
|
||||
SourceCharacter but not LineTerminator
|
||||
]]>
|
||||
</emu-grammar>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="syntactic-grammar">
|
||||
<h1>Syntactic Grammar</h1>
|
||||
<emu-grammar type="definition">
|
||||
<![CDATA[
|
||||
ADLScript :
|
||||
ADLScriptItemList?
|
||||
|
||||
ADLScriptItemList :
|
||||
ADLScriptItemList? ADLScriptItem
|
||||
|
||||
ADLScriptItem :
|
||||
BlocklessNamespaceStatement
|
||||
ImportStatement
|
||||
Statement
|
||||
|
||||
BlocklessNamespaceStatement :
|
||||
DecoratorList? `namespace` IdentifierOrMemberExpression `;`
|
||||
|
||||
ImportStatement :
|
||||
`import` StringLiteral `;`
|
||||
|
||||
StatementList :
|
||||
StatementList? Statement
|
||||
|
||||
Statement :
|
||||
ModelStatement
|
||||
NamespaceStatement
|
||||
OperationStatement
|
||||
UsingStatement
|
||||
`;`
|
||||
|
||||
UsingStatement :
|
||||
`using` IdentifierOrMemberExpression `;`
|
||||
|
||||
ModelStatement :
|
||||
DecoratorList? `model` Identifier TemplateParameters? ModelHeritage? `{` ModelBody? `}`
|
||||
DecoratorList? `model` Identifier TemplateParameters? `=` Expression `;`
|
||||
|
||||
ModelHeritage :
|
||||
`extends` ReferenceExpressionList
|
||||
|
||||
ReferenceExpressionList :
|
||||
ReferenceExpression
|
||||
ReferenceExpressionList `,` ReferenceExpression
|
||||
|
||||
TemplateParameters :
|
||||
`<` IdentifierList `>`
|
||||
|
||||
IdentifierList :
|
||||
Identifier
|
||||
IdentifierList `,` Identifier
|
||||
|
||||
ModelBody :
|
||||
ModelPropertyList `,`?
|
||||
ModelPropertyList `;`?
|
||||
|
||||
ModelPropertyList :
|
||||
ModelProperty
|
||||
ModelPropertyList `,` ModelProperty
|
||||
ModelPropertyList `;` ModelProperty
|
||||
|
||||
ModelProperty:
|
||||
ModelSpreadProperty
|
||||
DecoratorList? Identifier `?`? `:` Expression
|
||||
DecoratorList? StringLiteral `?`? `:` Expression
|
||||
|
||||
ModelSpreadProperty :
|
||||
`...` ReferenceExpression
|
||||
|
||||
NamespaceStatement:
|
||||
DecoratorList? `namespace` IdentifierOrMemberExpression `{` StatementList? `}`
|
||||
|
||||
OperationStatement :
|
||||
DecoratorList? `op` Identifier `(` ModelPropertyList? `)` `:` Expression `;`
|
||||
|
||||
Expression :
|
||||
UnionExpressionOrHigher
|
||||
|
||||
UnionExpressionOrHigher :
|
||||
IntersectionExpressionOrHigher
|
||||
UnionExpressionOrHigher `|` IntersectionExpressionOrHigher
|
||||
|
||||
IntersectionExpressionOrHigher :
|
||||
ArrayExpressionOrHigher
|
||||
IntersectionExpressionOrHigher `&` ArrayExpressionOrHigher
|
||||
|
||||
ArrayExpressionOrHigher :
|
||||
PrimaryExpression
|
||||
ArrayExpressionOrHigher `[` `]`
|
||||
|
||||
PrimaryExpression :
|
||||
Literal
|
||||
ReferenceExpression
|
||||
ParenthesizedExpression
|
||||
ModelExpression
|
||||
TupleExpression
|
||||
|
||||
Literal :
|
||||
StringLiteral
|
||||
BooleanLiteral
|
||||
NumericLiteral
|
||||
|
||||
ReferenceExpression :
|
||||
IdentifierOrMemberExpression TemplateArguments?
|
||||
|
||||
IdentifierOrMemberExpression :
|
||||
Identifier
|
||||
IdentifierOrMemberExpression `.` Identifier
|
||||
|
||||
TemplateArguments :
|
||||
`<` ExpressionList `>`
|
||||
|
||||
ParenthesizedExpression :
|
||||
`(` Expression `)`
|
||||
|
||||
ModelExpression :
|
||||
`{` ModelBody? `}`
|
||||
|
||||
TupleExpression :
|
||||
`[` ExpressionList `]`
|
||||
|
||||
ExpressionList :
|
||||
Expression
|
||||
ExpressionList `,` Expression
|
||||
|
||||
DecoratorList :
|
||||
DecoratorList? Decorator
|
||||
|
||||
Decorator :
|
||||
`@` IdentifierOrMemberExpression DecoratorArguments?
|
||||
|
||||
DecoratorArguments :
|
||||
`(` ExpressionList? `)`
|
||||
]]>
|
||||
</emu-grammar>
|
||||
</emu-clause>
|
||||
|
|
Загрузка…
Ссылка в новой задаче