Remove `alias` statement, prefer `model =`

This commit is contained in:
Nick Guerrera 2021-01-25 10:46:34 -08:00
Родитель cd6d3c2015
Коммит 354592fbb2
6 изменённых файлов: 1 добавлений и 54 удалений

Просмотреть файл

@ -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 @@
&emsp;&emsp;&emsp;<a name="Keyword-0330acf5"></a>`` import ``
&emsp;&emsp;&emsp;<a name="Keyword-fa60d604"></a>`` model ``
&emsp;&emsp;&emsp;<a name="Keyword-ef54526d"></a>`` interface ``
&emsp;&emsp;&emsp;<a name="Keyword-921cc095"></a>`` alias ``
&emsp;&emsp;<a name="Identifier"></a>*Identifier* **:**
&emsp;&emsp;&emsp;<a name="Identifier-11758399"></a>*[IdentifierName](#IdentifierName)* **but not** *[Keyword](#Keyword)*
@ -168,7 +167,6 @@
&emsp;&emsp;<a name="Statement"></a>*Statement* **:**
&emsp;&emsp;&emsp;<a name="Statement-648ff91f"></a>*[ImportStatement](#ImportStatement)*
&emsp;&emsp;&emsp;<a name="Statement-0d99421b"></a>*[AliasStatement](#AliasStatement)*
&emsp;&emsp;&emsp;<a name="Statement-3606dce2"></a>*[ModelStatement](#ModelStatement)*
&emsp;&emsp;&emsp;<a name="Statement-a875a11d"></a>*[InterfaceStatement](#InterfaceStatement)*
@ -180,9 +178,6 @@
&emsp;&emsp;&emsp;<a name="NamedImports-06b6ace8"></a>*[Identifier](#Identifier)*
&emsp;&emsp;&emsp;<a name="NamedImports-02b3b1dc"></a>*[NamedImports](#NamedImports)*&emsp;`` , ``&emsp;*[Identifier](#Identifier)*
&emsp;&emsp;<a name="AliasStatement"></a>*AliasStatement* **:**
&emsp;&emsp;&emsp;<a name="AliasStatement-d918b509"></a>`` alias ``&emsp;*[Identifier](#Identifier)*&emsp;`` : ``&emsp;*[Expression](#Expression)*&emsp;`` ; ``
&emsp;&emsp;<a name="ModelStatement"></a>*ModelStatement* **:**
&emsp;&emsp;&emsp;<a name="ModelStatement-b7b1d16b"></a>*[DecoratorList](#DecoratorList)*<sub>opt</sub>&emsp;`` model ``&emsp;*[Identifier](#Identifier)*&emsp;`` { ``&emsp;*[ModelBody](#ModelBody)*<sub>opt</sub>&emsp;`` } ``
&emsp;&emsp;&emsp;<a name="ModelStatement-a9aaf94c"></a>*[DecoratorList](#DecoratorList)*<sub>opt</sub>&emsp;`` model ``&emsp;*[Identifier](#Identifier)*&emsp;`` = ``&emsp;*[Expression](#Expression)*&emsp;`` ; ``

Просмотреть файл

@ -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 { };