m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-13 21:03:49 -0400
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-13 21:03:49 -0400
commitac62f2f52e0a656d60d2700937fdadabb221fcb3 (patch)
tree2e49f55e19d665b9169402532dbe956f085d55c3
parent2571bdc80a25b0137194bab58029765abe8870b2 (diff)
Rename lexeme
-rw-r--r--__tests__/lexer.test.js22
-rw-r--r--src/lexer.js2
2 files changed, 12 insertions, 12 deletions
diff --git a/__tests__/lexer.test.js b/__tests__/lexer.test.js
index e887e09..6434e17 100644
--- a/__tests__/lexer.test.js
+++ b/__tests__/lexer.test.js
@@ -26,17 +26,17 @@ describe('lex', () => {
describe('lexes basic dice', () => {
it('1d6', () => {
expect(lex('1d6')).toEqual([
- { type: 'number', value: 1 },
+ { type: 'constant', value: 1 },
{ type: 'd' },
- { type: 'number', value: 6 }
+ { type: 'constant', value: 6 }
])
})
it('42d172', () => {
expect(lex('42d172')).toEqual([
- { type: 'number', value: 42 },
+ { type: 'constant', value: 42 },
{ type: 'd' },
- { type: 'number', value: 172 }
+ { type: 'constant', value: 172 }
])
})
})
@@ -44,23 +44,23 @@ describe('lex', () => {
describe('lexes addition', () => {
it('1d6 + 1d4', () => {
expect(lex('1d6 + 1d4')).toEqual([
- { type: 'number', value: 1 },
+ { type: 'constant', value: 1 },
{ type: 'd' },
- { type: 'number', value: 6 },
+ { type: 'constant', value: 6 },
{ type: '+' },
- { type: 'number', value: 1 },
+ { type: 'constant', value: 1 },
{ type: 'd' },
- { type: 'number', value: 4 }
+ { type: 'constant', value: 4 }
])
})
it('2d17 + 4', () => {
expect(lex('2d17 + 4')).toEqual([
- { type: 'number', value: 2 },
+ { type: 'constant', value: 2 },
{ type: 'd' },
- { type: 'number', value: 17 },
+ { type: 'constant', value: 17 },
{ type: '+' },
- { type: 'number', value: 4 }
+ { type: 'constant', value: 4 }
])
})
})
diff --git a/src/lexer.js b/src/lexer.js
index eedabd7..97130d8 100644
--- a/src/lexer.js
+++ b/src/lexer.js
@@ -18,7 +18,7 @@ const newSkippableLexeme = (type, regex) => {
newLexemeType(type, regex, () => {})
}
-newValueLexeme('number', '\\d+', Number)
+newValueLexeme('constant', '\\d+', Number)
newLexemeType('d', 'd')
newLexemeType('+', '\\+')
newSkippableLexeme('whitespace', '\\s+')