moniel-parser
Advanced tools
| [ | ||
| { | ||
| "message": "Expected end of input.", | ||
| "location": 0 | ||
| } | ||
| ] |
+1
-1
| { | ||
| "name": "moniel-parser", | ||
| "version": "0.0.3", | ||
| "version": "0.0.4", | ||
| "description": "Parser for Moniel notation", | ||
@@ -5,0 +5,0 @@ "main": "Parser.js", |
+13
-7
@@ -24,2 +24,5 @@ const fs = require("fs") | ||
| parse(source) { | ||
| let ast = null | ||
| let issues = [] | ||
| const matchResult = this.grammar.match(source) | ||
@@ -29,12 +32,15 @@ | ||
| const expected = matchResult.getExpectedText() | ||
| const position = matchResult.getRightmostFailurePosition() | ||
| return { | ||
| expected, | ||
| position | ||
| } | ||
| const location = matchResult.getRightmostFailurePosition() | ||
| issues.push({ | ||
| message: `Expected ${expected}.`, | ||
| location | ||
| }) | ||
| } else { | ||
| ast = this.semantics(matchResult).eval() | ||
| } | ||
| const ast = this.semantics(matchResult).eval() | ||
| return { | ||
| ast | ||
| ast, | ||
| issues | ||
| } | ||
@@ -41,0 +47,0 @@ } |
+2
-2
@@ -28,4 +28,4 @@ const fs = require("fs") | ||
| if (!parseResult.ast) { | ||
| const errorFilePath = path.join(testDirectory, "_error.json") | ||
| generated = parseResult | ||
| const errorFilePath = path.join(testDirectory, "issues.json") | ||
| generated = parseResult.issues | ||
| target = loadSnapshot(errorFilePath, generated) | ||
@@ -32,0 +32,0 @@ } else { |
| { | ||
| "expected": "end of input", | ||
| "position": 0 | ||
| } |
16709
0.86%580
1.05%