Remove `alias` statement, prefer `model =`
This commit is contained in:
Родитель
cd6d3c2015
Коммит
354592fbb2
|
@ -41,11 +41,6 @@ export function parse(code: string) {
|
|||
return parseModelStatement(decorators);
|
||||
case Kind.InterfaceKeyword:
|
||||
return parseInterfaceStatement(decorators);
|
||||
case Kind.AliasKeyword:
|
||||
if (decorators.length > 0) {
|
||||
error('Cannot decorate an alias statement');
|
||||
}
|
||||
return parseAliasStatement();
|
||||
case Kind.Semicolon:
|
||||
if (decorators.length > 0) {
|
||||
error('Cannot decorate an empty statement');
|
||||
|
@ -550,23 +545,6 @@ export function parse(code: string) {
|
|||
}, pos);
|
||||
}
|
||||
|
||||
function parseAliasStatement(): Types.AliasStatementNode {
|
||||
const pos = tokenPos();
|
||||
parseExpected(Kind.AliasKeyword);
|
||||
|
||||
const id = parseIdentifier();
|
||||
parseExpected(Kind.Colon);
|
||||
|
||||
const target = parseExpression();
|
||||
parseExpected(Kind.Semicolon);
|
||||
|
||||
return finishNode({
|
||||
kind: Types.SyntaxKind.AliasStatement,
|
||||
id,
|
||||
target
|
||||
}, pos);
|
||||
}
|
||||
|
||||
// utility functions
|
||||
function token() {
|
||||
return scanner.token;
|
||||
|
@ -668,9 +646,6 @@ export function visitChildren<T>(node: Types.Node, cb: NodeCb<T>): T | undefined
|
|||
switch (node.kind) {
|
||||
case Types.SyntaxKind.ADLScript:
|
||||
return visitEach(cb, (<Types.ADLScriptNode>node).statements);
|
||||
case Types.SyntaxKind.AliasStatement:
|
||||
return visitNode(cb, (<Types.AliasStatementNode>node).id) ||
|
||||
visitNode(cb, (<Types.AliasStatementNode>node).target);
|
||||
case Types.SyntaxKind.ArrayExpression:
|
||||
return visitNode(cb, (<Types.ArrayExpressionNode>node).elementType);
|
||||
case Types.SyntaxKind.DecoratorExpression:
|
||||
|
|
|
@ -121,7 +121,6 @@ export enum Kind {
|
|||
ImportKeyword,
|
||||
ModelKeyword,
|
||||
InterfaceKeyword,
|
||||
AliasKeyword,
|
||||
TrueKeyword,
|
||||
FalseKeyword
|
||||
}
|
||||
|
@ -130,7 +129,6 @@ const keywords = new Map([
|
|||
['import', Kind.ImportKeyword],
|
||||
['model', Kind.ModelKeyword],
|
||||
['interface', Kind.InterfaceKeyword],
|
||||
['alias', Kind.AliasKeyword],
|
||||
['true', Kind.TrueKeyword],
|
||||
['false', Kind.FalseKeyword]
|
||||
]);
|
||||
|
|
|
@ -122,7 +122,6 @@ export enum SyntaxKind {
|
|||
StringLiteral,
|
||||
NumericLiteral,
|
||||
BooleanLiteral,
|
||||
AliasStatement,
|
||||
TemplateApplication,
|
||||
TemplateParameterDeclaration
|
||||
}
|
||||
|
@ -142,8 +141,7 @@ export interface ADLScriptNode extends Node {
|
|||
export type Statement =
|
||||
| ImportStatementNode
|
||||
| ModelStatementNode
|
||||
| InterfaceStatementNode
|
||||
| AliasStatementNode;
|
||||
| InterfaceStatementNode;
|
||||
|
||||
export interface ImportStatementNode extends Node {
|
||||
kind: SyntaxKind.ImportStatement;
|
||||
|
@ -271,12 +269,6 @@ export interface IntersectionExpressionNode extends Node {
|
|||
options: Array<Expression>;
|
||||
}
|
||||
|
||||
export interface AliasStatementNode extends Node {
|
||||
kind: SyntaxKind.AliasStatement;
|
||||
id: IdentifierNode;
|
||||
target: Expression;
|
||||
}
|
||||
|
||||
export interface TemplateApplicationNode extends Node {
|
||||
kind: SyntaxKind.TemplateApplication;
|
||||
target: Expression;
|
||||
|
|
|
@ -25,7 +25,6 @@ Keyword :
|
|||
`import`
|
||||
`model`
|
||||
`interface`
|
||||
`alias`
|
||||
|
||||
Identifier :
|
||||
IdentifierName but not Keyword
|
||||
|
@ -182,7 +181,6 @@ StatementList :
|
|||
|
||||
Statement :
|
||||
ImportStatement
|
||||
AliasStatement
|
||||
ModelStatement
|
||||
InterfaceStatement
|
||||
|
||||
|
@ -194,9 +192,6 @@ NamedImports :
|
|||
Identifier
|
||||
NamedImports `,` Identifier
|
||||
|
||||
AliasStatement :
|
||||
`alias` Identifier `:` Expression `;`
|
||||
|
||||
ModelStatement :
|
||||
DecoratorList? `model` Identifier `{` ModelBody? `}`
|
||||
DecoratorList? `model` Identifier `=` Expression `;`
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
   <a name="Keyword-0330acf5"></a>`` import ``
|
||||
   <a name="Keyword-fa60d604"></a>`` model ``
|
||||
   <a name="Keyword-ef54526d"></a>`` interface ``
|
||||
   <a name="Keyword-921cc095"></a>`` alias ``
|
||||
|
||||
  <a name="Identifier"></a>*Identifier* **:**
|
||||
   <a name="Identifier-11758399"></a>*[IdentifierName](#IdentifierName)* **but not** *[Keyword](#Keyword)*
|
||||
|
@ -168,7 +167,6 @@
|
|||
|
||||
  <a name="Statement"></a>*Statement* **:**
|
||||
   <a name="Statement-648ff91f"></a>*[ImportStatement](#ImportStatement)*
|
||||
   <a name="Statement-0d99421b"></a>*[AliasStatement](#AliasStatement)*
|
||||
   <a name="Statement-3606dce2"></a>*[ModelStatement](#ModelStatement)*
|
||||
   <a name="Statement-a875a11d"></a>*[InterfaceStatement](#InterfaceStatement)*
|
||||
|
||||
|
@ -180,9 +178,6 @@
|
|||
   <a name="NamedImports-06b6ace8"></a>*[Identifier](#Identifier)*
|
||||
   <a name="NamedImports-02b3b1dc"></a>*[NamedImports](#NamedImports)* `` , `` *[Identifier](#Identifier)*
|
||||
|
||||
  <a name="AliasStatement"></a>*AliasStatement* **:**
|
||||
   <a name="AliasStatement-d918b509"></a>`` alias `` *[Identifier](#Identifier)* `` : `` *[Expression](#Expression)* `` ; ``
|
||||
|
||||
  <a name="ModelStatement"></a>*ModelStatement* **:**
|
||||
   <a name="ModelStatement-b7b1d16b"></a>*[DecoratorList](#DecoratorList)*<sub>opt</sub> `` model `` *[Identifier](#Identifier)* `` { `` *[ModelBody](#ModelBody)*<sub>opt</sub> `` } ``
|
||||
   <a name="ModelStatement-a9aaf94c"></a>*[DecoratorList](#DecoratorList)*<sub>opt</sub> `` model `` *[Identifier](#Identifier)* `` = `` *[Expression](#Expression)* `` ; ``
|
||||
|
|
|
@ -155,14 +155,6 @@ describe('syntax', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
describe('alias statements', () => {
|
||||
parseEach([
|
||||
'alias MyAlias : SomethingElse;',
|
||||
'alias MyAlias : { constantProperty: 4 };',
|
||||
'alias MyAlias : [ string, number ];'
|
||||
]);
|
||||
});
|
||||
|
||||
describe('multiple statements', () => {
|
||||
parseEach([`
|
||||
model A { };
|
||||
|
|
Загрузка…
Ссылка в новой задаче