Support parsing of class expressions, see #161

This commit is contained in:
dcodeIO
2018-07-10 03:03:59 +02:00
parent 27dbbd1d75
commit c4199673ef
8 changed files with 162 additions and 44 deletions

View File

@ -41,6 +41,7 @@ export enum NodeKind {
ASSERTION,
BINARY,
CALL,
CLASS,
COMMA,
ELEMENTACCESS,
FALSE,
@ -320,6 +321,15 @@ export abstract class Node {
return expr;
}
static createClassExpression(
declaration: ClassDeclaration
): ClassExpression {
var expr = new ClassExpression();
expr.range = declaration.range;
expr.declaration = declaration;
return expr;
}
static createCommaExpression(
expressions: Expression[],
range: Range
@ -1276,6 +1286,14 @@ export class CallExpression extends Expression {
arguments: Expression[];
}
/** Represents a class expression using the 'class' keyword. */
export class ClassExpression extends Expression {
kind = NodeKind.CLASS;
/** Inline class declaration. */
declaration: ClassDeclaration;
}
/** Represents a comma expression composed of multiple expressions. */
export class CommaExpression extends Expression {
kind = NodeKind.COMMA;