-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtoken.js
More file actions
29 lines (26 loc) · 704 Bytes
/
Copy pathtoken.js
File metadata and controls
29 lines (26 loc) · 704 Bytes
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
export default class Token {
constructor (t, v, index, indexEnd) {
this.type = t
this.value = v
this.index = index ? index.copy() : null
this.indexEnd = indexEnd ? indexEnd.copy() : null
if (this.index && !this.indexEnd) {
this.indexEnd = this.index.copy()
this.indexEnd.advance()
}
}
getFormattedText () {
return this.value ? `${this.type}:${this.value}` : `${this.type}`
}
static types = {
INT: 'INT',
FLOAT: 'FLOAT',
PLUS: 'PLUS',
MINUS: 'MINUS',
MUL: 'MUL',
DIV: 'DIV',
LPAREN: 'LPAREN',
RPAREN: 'RPAREN',
EOF: 'EOF',
}
}