m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lexer.js1
-rw-r--r--src/parser.js8
2 files changed, 9 insertions, 0 deletions
diff --git a/src/lexer.js b/src/lexer.js
index 5e29e42..85579fb 100644
--- a/src/lexer.js
+++ b/src/lexer.js
@@ -24,6 +24,7 @@ newLexemeType('+', '\\+')
newLexemeType('-', '-')
newLexemeType('(', '\\(')
newLexemeType(')', '\\)')
+newLexemeType('E', 'E')
newSkippableLexeme('whitespace', '\\s+')
const lex = (expressionString) => {
diff --git a/src/parser.js b/src/parser.js
index 3437f1a..9479abc 100644
--- a/src/parser.js
+++ b/src/parser.js
@@ -47,6 +47,14 @@ newSymbol('d', (parser) => {
}
})
+newSymbol('E', null, 30, (left, parser) => {
+ return {
+ type: 'E',
+ left: left,
+ right: parser.expression(29)
+ }
+})
+
newSymbol('+', null, 20, (left, parser) => {
return {
type: 'add',