krl-parser
Advanced tools
Comparing version 0.22.0 to 0.23.0
{ | ||
"name": "krl-parser", | ||
"version": "0.22.0", | ||
"version": "0.23.0", | ||
"description": "Parse KRL source code into an AST", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -103,7 +103,7 @@ // Generated automatically by nearley | ||
var ruleActionBlock = function(condition_path, type_path, actions_path){ | ||
var actionBlock = function(condition_path, type_path, actions_path){ | ||
return function(data){ | ||
return { | ||
loc: mkLoc(data), | ||
type: 'RuleActionBlock', | ||
type: "ActionBlock", | ||
condition: get(data, condition_path, null), | ||
@@ -367,4 +367,7 @@ block_type: get(data, type_path, "every"), | ||
var tok_repeat = tok("SYMBOL", "repeat"); | ||
var tok_return = tok("SYMBOL", "return"); | ||
var tok_returns = tok("SYMBOL", "returns"); | ||
var tok_ruleset = tok("SYMBOL", "ruleset"); | ||
var tok_rule = tok("SYMBOL", "rule"); | ||
var tok_sample = tok("SYMBOL", "sample"); | ||
var tok_schedule = tok("SYMBOL", "schedule"); | ||
@@ -567,3 +570,3 @@ var tok_share = tok("SYMBOL", "share"); | ||
{"name": "rule$ebnf$4", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "rule$ebnf$5", "symbols": ["RuleActionBlock"], "postprocess": id}, | ||
{"name": "rule$ebnf$5", "symbols": ["ActionBlock"], "postprocess": id}, | ||
{"name": "rule$ebnf$5", "symbols": [], "postprocess": function(d) {return null;}}, | ||
@@ -710,20 +713,22 @@ {"name": "rule$ebnf$6", "symbols": ["RulePostlude"], "postprocess": id}, | ||
}, | ||
{"name": "RuleActionBlock", "symbols": ["RuleAction"], "postprocess": ruleActionBlock([], [], [0])}, | ||
{"name": "RuleActionBlock$ebnf$1", "symbols": [tok_SEMI], "postprocess": id}, | ||
{"name": "RuleActionBlock$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "RuleActionBlock", "symbols": [tok_if, "Expression", tok_then, "RuleAction", "RuleActionBlock$ebnf$1"], "postprocess": ruleActionBlock([1], [], [3])}, | ||
{"name": "RuleActionBlock$ebnf$2", "symbols": [tok_every], "postprocess": id}, | ||
{"name": "RuleActionBlock$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "RuleActionBlock", "symbols": [tok_if, "Expression", tok_then, "RuleActionBlock$ebnf$2", "RuleAction_in_curlies"], "postprocess": ruleActionBlock([1], [3, "src"], [4])}, | ||
{"name": "RuleActionBlock", "symbols": [tok_every, "RuleAction_in_curlies"], "postprocess": ruleActionBlock([], [0, "src"], [1])}, | ||
{"name": "RuleActionBlock", "symbols": [tok_choose, "Expression", "RuleAction_in_curlies"], "postprocess": ruleActionBlock([1], [0, "src"], [2])}, | ||
{"name": "RuleAction_in_curlies$ebnf$1$subexpression$1$ebnf$1", "symbols": [tok_SEMI], "postprocess": id}, | ||
{"name": "RuleAction_in_curlies$ebnf$1$subexpression$1$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "RuleAction_in_curlies$ebnf$1$subexpression$1", "symbols": ["RuleAction", "RuleAction_in_curlies$ebnf$1$subexpression$1$ebnf$1"]}, | ||
{"name": "RuleAction_in_curlies$ebnf$1", "symbols": ["RuleAction_in_curlies$ebnf$1$subexpression$1"]}, | ||
{"name": "RuleAction_in_curlies$ebnf$1$subexpression$2$ebnf$1", "symbols": [tok_SEMI], "postprocess": id}, | ||
{"name": "RuleAction_in_curlies$ebnf$1$subexpression$2$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "RuleAction_in_curlies$ebnf$1$subexpression$2", "symbols": ["RuleAction", "RuleAction_in_curlies$ebnf$1$subexpression$2$ebnf$1"]}, | ||
{"name": "RuleAction_in_curlies$ebnf$1", "symbols": ["RuleAction_in_curlies$ebnf$1", "RuleAction_in_curlies$ebnf$1$subexpression$2"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}}, | ||
{"name": "RuleAction_in_curlies", "symbols": [tok_OPEN_CURLY, "RuleAction_in_curlies$ebnf$1", tok_CLSE_CURLY], "postprocess": | ||
{"name": "ActionBlock$ebnf$1", "symbols": [tok_SEMI], "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": "Actions_in_curlies$ebnf$1$subexpression$1$ebnf$1", "symbols": [tok_SEMI], "postprocess": id}, | ||
{"name": "Actions_in_curlies$ebnf$1$subexpression$1$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "Actions_in_curlies$ebnf$1$subexpression$1", "symbols": ["Action", "Actions_in_curlies$ebnf$1$subexpression$1$ebnf$1"]}, | ||
{"name": "Actions_in_curlies$ebnf$1", "symbols": ["Actions_in_curlies$ebnf$1$subexpression$1"]}, | ||
{"name": "Actions_in_curlies$ebnf$1$subexpression$2$ebnf$1", "symbols": [tok_SEMI], "postprocess": id}, | ||
{"name": "Actions_in_curlies$ebnf$1$subexpression$2$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "Actions_in_curlies$ebnf$1$subexpression$2", "symbols": ["Action", "Actions_in_curlies$ebnf$1$subexpression$2$ebnf$1"]}, | ||
{"name": "Actions_in_curlies$ebnf$1", "symbols": ["Actions_in_curlies$ebnf$1", "Actions_in_curlies$ebnf$1$subexpression$2"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}}, | ||
{"name": "Actions_in_curlies", "symbols": [tok_OPEN_CURLY, "Actions_in_curlies$ebnf$1", tok_CLSE_CURLY], "postprocess": | ||
function(data){ | ||
@@ -733,20 +738,17 @@ return data[1].map(function(d){return d[0];}) | ||
}, | ||
{"name": "RuleAction$ebnf$1$subexpression$1", "symbols": ["Identifier", tok_FAT_ARROW_RIGHT]}, | ||
{"name": "RuleAction$ebnf$1", "symbols": ["RuleAction$ebnf$1$subexpression$1"], "postprocess": id}, | ||
{"name": "RuleAction$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "RuleAction$ebnf$2$subexpression$1", "symbols": [tok_setting, tok_OPEN_PAREN, "Identifier", tok_CLSE_PAREN]}, | ||
{"name": "RuleAction$ebnf$2", "symbols": ["RuleAction$ebnf$2$subexpression$1"], "postprocess": id}, | ||
{"name": "RuleAction$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "RuleAction$ebnf$3", "symbols": ["WithArguments"], "postprocess": id}, | ||
{"name": "RuleAction$ebnf$3", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "RuleAction", "symbols": ["RuleAction$ebnf$1", "Identifier_or_DomainIdentifier", tok_OPEN_PAREN, "Expression_list", tok_CLSE_PAREN, "RuleAction$ebnf$2", "RuleAction$ebnf$3"], "postprocess": | ||
{"name": "Action$ebnf$1$subexpression$1", "symbols": ["Identifier", tok_FAT_ARROW_RIGHT]}, | ||
{"name": "Action$ebnf$1", "symbols": ["Action$ebnf$1$subexpression$1"], "postprocess": id}, | ||
{"name": "Action$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "Action$ebnf$2$subexpression$1", "symbols": [tok_setting, tok_OPEN_PAREN, "Identifier_list", tok_CLSE_PAREN]}, | ||
{"name": "Action$ebnf$2", "symbols": ["Action$ebnf$2$subexpression$1"], "postprocess": id}, | ||
{"name": "Action$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "Action", "symbols": ["Action$ebnf$1", "Identifier_or_DomainIdentifier", "Arguments", "Action$ebnf$2"], "postprocess": | ||
function(data){ | ||
return { | ||
loc: mkLoc(data), | ||
type: 'RuleAction', | ||
type: "Action", | ||
label: data[0] && data[0][0], | ||
action: data[1], | ||
args: data[3], | ||
setting: (data[5] && data[5][2]) || null, | ||
"with": data[6] || [] | ||
args: data[2], | ||
setting: (data[3] && data[3][2]) || [], | ||
}; | ||
@@ -854,3 +856,4 @@ } | ||
{"name": "RaiseEventStatement$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "RaiseEventStatement$ebnf$2", "symbols": ["RaiseEventAttributes"], "postprocess": id}, | ||
{"name": "RaiseEventStatement$ebnf$2$subexpression$1", "symbols": [tok_attributes, "Expression"]}, | ||
{"name": "RaiseEventStatement$ebnf$2", "symbols": ["RaiseEventStatement$ebnf$2$subexpression$1"], "postprocess": id}, | ||
{"name": "RaiseEventStatement$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}}, | ||
@@ -861,6 +864,6 @@ {"name": "RaiseEventStatement", "symbols": [tok_raise, "Identifier", tok_event, "Expression", "RaiseEventStatement$ebnf$1", "RaiseEventStatement$ebnf$2"], "postprocess": | ||
loc: mkLoc(data), | ||
type: 'RaiseEventStatement', | ||
type: "RaiseEventStatement", | ||
event_domain: data[1], | ||
event_type: data[3], | ||
event_attrs: data[5], | ||
event_attrs: (data[5] && data[5][1]) || null, | ||
@@ -873,3 +876,4 @@ for_rid: data[4] ? data[4][1] : null, | ||
{"name": "ScheduleEventStatement", "symbols": ["ScheduleEventStatement_repeat"], "postprocess": id}, | ||
{"name": "ScheduleEventStatement_at$ebnf$1", "symbols": ["RaiseEventAttributes"], "postprocess": id}, | ||
{"name": "ScheduleEventStatement_at$ebnf$1$subexpression$1", "symbols": [tok_attributes, "Expression"]}, | ||
{"name": "ScheduleEventStatement_at$ebnf$1", "symbols": ["ScheduleEventStatement_at$ebnf$1$subexpression$1"], "postprocess": id}, | ||
{"name": "ScheduleEventStatement_at$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
@@ -889,3 +893,3 @@ {"name": "ScheduleEventStatement_at$ebnf$2$subexpression$1", "symbols": [tok_setting, tok_OPEN_PAREN, "Identifier", tok_CLSE_PAREN]}, | ||
event_type: data[3], | ||
event_attrs: data[6], | ||
event_attrs: (data[6] && data[6][1]) || null, | ||
@@ -896,3 +900,4 @@ setting: (data[7] && data[7][2]) || null, | ||
}, | ||
{"name": "ScheduleEventStatement_repeat$ebnf$1", "symbols": ["RaiseEventAttributes"], "postprocess": id}, | ||
{"name": "ScheduleEventStatement_repeat$ebnf$1$subexpression$1", "symbols": [tok_attributes, "Expression"]}, | ||
{"name": "ScheduleEventStatement_repeat$ebnf$1", "symbols": ["ScheduleEventStatement_repeat$ebnf$1$subexpression$1"], "postprocess": id}, | ||
{"name": "ScheduleEventStatement_repeat$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
@@ -912,3 +917,3 @@ {"name": "ScheduleEventStatement_repeat$ebnf$2$subexpression$1", "symbols": [tok_setting, tok_OPEN_PAREN, "Identifier", tok_CLSE_PAREN]}, | ||
event_type: data[3], | ||
event_attrs: data[6], | ||
event_attrs: (data[6] && data[6][1]) || null, | ||
@@ -919,20 +924,2 @@ setting: (data[7] && data[7][2]) || null, | ||
}, | ||
{"name": "RaiseEventAttributes", "symbols": ["WithArguments"], "postprocess": | ||
function(data){ | ||
return { | ||
loc: mkLoc(data), | ||
type: "RaiseEventAttributes", | ||
with: data[0] | ||
}; | ||
} | ||
}, | ||
{"name": "RaiseEventAttributes", "symbols": [tok_attributes, "Expression"], "postprocess": | ||
function(data){ | ||
return { | ||
loc: mkLoc(data), | ||
type: "RaiseEventAttributes", | ||
expression: data[1] | ||
}; | ||
} | ||
}, | ||
{"name": "LogStatement", "symbols": [tok_log, tok_LOG_or_ERROR_LEVEL_ENUM, "Expression"], "postprocess": | ||
@@ -1019,11 +1006,17 @@ function(data){ | ||
{"name": "DeclarationOrDefAction", "symbols": ["DefAction"], "postprocess": id}, | ||
{"name": "DefAction", "symbols": ["Identifier", tok_EQ, tok_defaction, tok_OPEN_PAREN, "Parameter_list", tok_CLSE_PAREN, tok_OPEN_CURLY, "DeclarationList", "RuleActionBlock", tok_CLSE_CURLY], "postprocess": | ||
{"name": "DefAction$ebnf$1$subexpression$1$subexpression$1", "symbols": [tok_return]}, | ||
{"name": "DefAction$ebnf$1$subexpression$1$subexpression$1", "symbols": [tok_returns]}, | ||
{"name": "DefAction$ebnf$1$subexpression$1", "symbols": ["DefAction$ebnf$1$subexpression$1$subexpression$1", "Expression_list_body"]}, | ||
{"name": "DefAction$ebnf$1", "symbols": ["DefAction$ebnf$1$subexpression$1"], "postprocess": id}, | ||
{"name": "DefAction$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "DefAction", "symbols": ["Identifier", tok_EQ, tok_defaction, "Parameters", tok_OPEN_CURLY, "DeclarationList", "ActionBlock", "DefAction$ebnf$1", tok_CLSE_CURLY], "postprocess": | ||
function(data){ | ||
return { | ||
loc: mkLoc(data), | ||
type: 'DefAction', | ||
type: "DefAction", | ||
id: data[0], | ||
params: data[4], | ||
body: data[7], | ||
action_block: data[8] | ||
params: data[3], | ||
body: data[5], | ||
action_block: data[6], | ||
returns: (data[7] && data[7][1]) || [], | ||
}; | ||
@@ -1033,2 +1026,3 @@ } | ||
{"name": "left_side_of_declaration", "symbols": ["MemberExpression"], "postprocess": id}, | ||
{"name": "Statement_list", "symbols": [], "postprocess": noopArr}, | ||
{"name": "Statement_list$ebnf$1", "symbols": [tok_SEMI], "postprocess": id}, | ||
@@ -1115,3 +1109,3 @@ {"name": "Statement_list$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "Identifier_list_body", "symbols": ["Identifier_list_body", tok_COMMA, "Identifier"], "postprocess": concatArr(2)}, | ||
{"name": "Function", "symbols": [tok_function, tok_OPEN_PAREN, "Parameter_list", tok_CLSE_PAREN, tok_OPEN_CURLY, "function_body", tok_CLSE_CURLY], "postprocess": | ||
{"name": "Function", "symbols": [tok_function, "Parameters", tok_OPEN_CURLY, "Statement_list", tok_CLSE_CURLY], "postprocess": | ||
function(data){ | ||
@@ -1121,4 +1115,4 @@ return { | ||
type: "Function", | ||
params: data[2], | ||
body: data[5] | ||
params: data[1], | ||
body: data[3] | ||
}; | ||
@@ -1140,2 +1134,11 @@ } | ||
}, | ||
{"name": "Parameters", "symbols": [tok_OPEN_PAREN, "Parameter_list", tok_CLSE_PAREN], "postprocess": | ||
function(data){ | ||
return { | ||
loc: mkLoc(data), | ||
type: "Parameters", | ||
params: data[1], | ||
}; | ||
} | ||
}, | ||
{"name": "Parameter_list", "symbols": [], "postprocess": noopArr}, | ||
@@ -1147,23 +1150,38 @@ {"name": "Parameter_list$ebnf$1", "symbols": [tok_COMMA], "postprocess": id}, | ||
{"name": "Parameter_list_body", "symbols": ["Parameter_list_body", tok_COMMA, "Parameter"], "postprocess": concatArr(2)}, | ||
{"name": "function_body", "symbols": [], "postprocess": noopArr}, | ||
{"name": "function_body$ebnf$1", "symbols": [tok_SEMI], "postprocess": id}, | ||
{"name": "function_body$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "function_body", "symbols": ["function_body_parts", "function_body$ebnf$1"], "postprocess": id}, | ||
{"name": "function_body_parts", "symbols": ["ExpressionStatement"], "postprocess": idArr}, | ||
{"name": "function_body_parts", "symbols": ["Statement", tok_SEMI, "function_body_parts"], "postprocess": function(data){ | ||
return [data[0]].concat(data[2]); | ||
} }, | ||
{"name": "Application$ebnf$1", "symbols": ["WithArguments"], "postprocess": id}, | ||
{"name": "Application$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "Application", "symbols": ["MemberExpression", tok_OPEN_PAREN, "Expression_list", tok_CLSE_PAREN, "Application$ebnf$1"], "postprocess": | ||
{"name": "Application", "symbols": ["MemberExpression", "Arguments"], "postprocess": | ||
function(data){ | ||
return { | ||
loc: mkLoc(data), | ||
type: 'Application', | ||
type: "Application", | ||
callee: data[0], | ||
args: data[2], | ||
"with": data[4] || [] | ||
args: data[1], | ||
}; | ||
} | ||
}, | ||
{"name": "Arguments", "symbols": [tok_OPEN_PAREN, "Argument_list", tok_CLSE_PAREN], "postprocess": | ||
function(data){ | ||
return { | ||
loc: mkLoc(data), | ||
type: "Arguments", | ||
args: data[1], | ||
}; | ||
} | ||
}, | ||
{"name": "Argument", "symbols": ["Expression"], "postprocess": id}, | ||
{"name": "Argument", "symbols": ["Identifier", tok_EQ, "Expression"], "postprocess": | ||
function(data){ | ||
return { | ||
loc: mkLoc(data), | ||
type: "NamedArgument", | ||
id: data[0], | ||
value: data[2], | ||
}; | ||
} | ||
}, | ||
{"name": "Argument_list", "symbols": [], "postprocess": noopArr}, | ||
{"name": "Argument_list$ebnf$1", "symbols": [tok_COMMA], "postprocess": id}, | ||
{"name": "Argument_list$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "Argument_list", "symbols": ["Argument_list_body", "Argument_list$ebnf$1"], "postprocess": id}, | ||
{"name": "Argument_list_body", "symbols": ["Argument"], "postprocess": idArr}, | ||
{"name": "Argument_list_body", "symbols": ["Argument_list_body", tok_COMMA, "Argument"], "postprocess": concatArr(2)}, | ||
{"name": "Array", "symbols": [tok_OPEN_SQARE, "Expression_list", tok_CLSE_SQARE], "postprocess": | ||
@@ -1170,0 +1188,0 @@ function(data){ |
Sorry, the diff of this file is not supported yet
109703
1548