-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathast.ts
More file actions
67 lines (57 loc) · 1.56 KB
/
ast.ts
File metadata and controls
67 lines (57 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { Token } from "./token";
export type EdgeType = "--" | "->";
// TODO: I am not sure if this classification does even make
// any sense in case of graph declaration language.
export abstract class Node {}
export abstract class Statement extends Node {}
export abstract class Expression extends Node {}
export class Definition extends Node {
constructor(public graphs: Array<GraphStatement> = []) {
super();
}
}
export class GraphStatement extends Statement {
constructor(public token: Token, public statements: Array<Statement> = []) {
super();
}
}
export class NodeStatement extends Statement {
constructor(
public token: Token,
public id: Identifier,
public attributesList: Array<AttributeStatement>
) {
super();
}
}
export class EdgeStatement extends Statement {
constructor(
public token: Token,
public left: Identifier,
public right: Identifier,
public edgeType: EdgeType,
public attributeList: Array<AttributeStatement>
) {
super();
}
}
export class AttributeStatement extends Statement {
constructor(public readonly token: Token, public key: Identifier, public value: Expression) {
super();
}
}
export class NumberLiteral extends Expression {
constructor(public readonly token: Token, public value: number) {
super();
}
}
export class StringLiteral extends Expression {
constructor(public readonly token: Token, public value: string) {
super();
}
}
export class Identifier extends Expression {
constructor(public readonly token: Token, public value: string) {
super();
}
}