krl-parser
Advanced tools
Comparing version 0.23.1 to 0.24.0
{ | ||
"name": "krl-parser", | ||
"version": "0.23.1", | ||
"version": "0.24.0", | ||
"description": "Parse KRL source code into an AST", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -103,3 +103,3 @@ // Generated automatically by nearley | ||
var actionBlock = function(condition_path, type_path, actions_path){ | ||
var actionBlock = function(condition_path, type_path, actions_path, discriminant_path){ | ||
return function(data){ | ||
@@ -111,2 +111,3 @@ return { | ||
block_type: get(data, type_path, "every"), | ||
discriminant: get(data, discriminant_path, null),//i.e. `choose <expr> {...}` | ||
actions: flatten([get(data, actions_path, null)]), | ||
@@ -732,13 +733,17 @@ }; | ||
}, | ||
{"name": "ActionBlock$ebnf$1", "symbols": [tok_SEMI], "postprocess": id}, | ||
{"name": "ActionBlock$ebnf$1", "symbols": ["ActionBlock_cond"], "postprocess": id}, | ||
{"name": "ActionBlock$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "ActionBlock", "symbols": ["Action", "ActionBlock$ebnf$1"], "postprocess": actionBlock(null, null, [0])}, | ||
{"name": "ActionBlock$ebnf$2", "symbols": [tok_SEMI], "postprocess": id}, | ||
{"name": "ActionBlock$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "ActionBlock", "symbols": [tok_if, "Expression", tok_then, "Action", "ActionBlock$ebnf$2"], "postprocess": actionBlock([1], null, [3])}, | ||
{"name": "ActionBlock", "symbols": [tok_if, "Expression", tok_then, tok_every, "Actions_in_curlies"], "postprocess": actionBlock([1], [3, "src"], [4])}, | ||
{"name": "ActionBlock", "symbols": [tok_if, "Expression", tok_then, tok_sample, "Actions_in_curlies"], "postprocess": actionBlock([1], [3, "src"], [4])}, | ||
{"name": "ActionBlock", "symbols": [tok_every, "Actions_in_curlies"], "postprocess": actionBlock(null, [0, "src"], [1])}, | ||
{"name": "ActionBlock", "symbols": [tok_sample, "Actions_in_curlies"], "postprocess": actionBlock(null, [0, "src"], [1])}, | ||
{"name": "ActionBlock", "symbols": [tok_choose, "Expression", "Actions_in_curlies"], "postprocess": actionBlock([1], [0, "src"], [2])}, | ||
{"name": "ActionBlock", "symbols": ["ActionBlock$ebnf$1", "Action", "ActionBlock$ebnf$2"], "postprocess": actionBlock([0, 1], null, [1])}, | ||
{"name": "ActionBlock$ebnf$3", "symbols": ["ActionBlock_cond"], "postprocess": id}, | ||
{"name": "ActionBlock$ebnf$3", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "ActionBlock", "symbols": ["ActionBlock$ebnf$3", tok_every, "Actions_in_curlies"], "postprocess": actionBlock([0, 1], [1, "src"], [2])}, | ||
{"name": "ActionBlock$ebnf$4", "symbols": ["ActionBlock_cond"], "postprocess": id}, | ||
{"name": "ActionBlock$ebnf$4", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "ActionBlock", "symbols": ["ActionBlock$ebnf$4", tok_sample, "Actions_in_curlies"], "postprocess": actionBlock([0, 1], [1, "src"], [2])}, | ||
{"name": "ActionBlock$ebnf$5", "symbols": ["ActionBlock_cond"], "postprocess": id}, | ||
{"name": "ActionBlock$ebnf$5", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "ActionBlock", "symbols": ["ActionBlock$ebnf$5", tok_choose, "Expression", "Actions_in_curlies"], "postprocess": actionBlock([0, 1], [1, "src"], [3], [2])}, | ||
{"name": "ActionBlock_cond", "symbols": [tok_if, "Expression", tok_then]}, | ||
{"name": "Actions_in_curlies$ebnf$1$subexpression$1$ebnf$1", "symbols": [tok_SEMI], "postprocess": id}, | ||
@@ -745,0 +750,0 @@ {"name": "Actions_in_curlies$ebnf$1$subexpression$1$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, |
@@ -53,7 +53,13 @@ var nearley = require("nearley"); | ||
if(p.results.length !== 1){ | ||
throw new Error( | ||
"Parsing Ambiguity: " + p.results.length + " parsings found" | ||
); | ||
var msg = "Parsing Ambiguity: " + p.results.length + " parsings found"; | ||
if(opts.filename){ | ||
msg += "\n" + opts.filename; | ||
} | ||
var err = new Error(msg); | ||
err.where = { | ||
filename: opts.filename, | ||
}; | ||
throw err; | ||
} | ||
return p.results[0]; | ||
}; |
Sorry, the diff of this file is not supported yet
111723
1576