|
@@ -5,30 +5,30 @@ module.exports = class Lexer {
|
5
|
5
|
scan(source) {
|
6
|
6
|
let pos = 0
|
7
|
7
|
let line = 1
|
8
|
|
- let tokens = new TokenStream()
|
|
8
|
+ let tokenStream = new TokenStream()
|
9
|
9
|
|
10
|
10
|
while (pos < source.length) {
|
11
|
11
|
if (source[pos].match(/\(/)) {
|
12
|
|
- tokens.push({
|
|
12
|
+ tokenStream.tokens.push({
|
13
|
13
|
type: tokenTypes.OPAREN,
|
14
|
14
|
line: line,
|
15
|
15
|
})
|
16
|
16
|
pos++
|
17
|
17
|
} else if (source[pos].match(/\)/)) {
|
18
|
|
- tokens.push({
|
|
18
|
+ tokenStream.tokens.push({
|
19
|
19
|
type: tokenTypes.CPAREN,
|
20
|
20
|
line: line,
|
21
|
21
|
})
|
22
|
22
|
pos++
|
23
|
23
|
} else if (source[pos].match(/['"]/)) {
|
24
|
|
- tokens.push({
|
|
24
|
+ tokenStream.tokens.push({
|
25
|
25
|
type: tokenTypes.QUOTE,
|
26
|
26
|
line: line,
|
27
|
27
|
})
|
28
|
28
|
pos++
|
29
|
29
|
} else if (source[pos].match(/:/)) {
|
30
|
30
|
let value = /:([^()'"\s]+)/.exec(source.slice(pos))[1].trim()
|
31
|
|
- tokens.push({
|
|
31
|
+ tokenStream.tokens.push({
|
32
|
32
|
type: tokenTypes.ATTRIBUTE,
|
33
|
33
|
line: line,
|
34
|
34
|
value: value,
|
|
@@ -41,7 +41,7 @@ module.exports = class Lexer {
|
41
|
41
|
pos++
|
42
|
42
|
} else {
|
43
|
43
|
let value = /[^()"':]+/.exec(source.slice(pos))[0]
|
44
|
|
- tokens.push({
|
|
44
|
+ tokenStream.tokens.push({
|
45
|
45
|
type: tokenTypes.LITERAL,
|
46
|
46
|
line: line,
|
47
|
47
|
value: value.trim(),
|
|
@@ -50,10 +50,10 @@ module.exports = class Lexer {
|
50
|
50
|
}
|
51
|
51
|
}
|
52
|
52
|
|
53
|
|
- tokens.push({
|
|
53
|
+ tokenStream.tokens.push({
|
54
|
54
|
type: tokenTypes.EOF,
|
55
|
55
|
line: line,
|
56
|
56
|
})
|
57
|
|
- return tokens
|
|
57
|
+ return tokenStream
|
58
|
58
|
}
|
59
|
59
|
}
|