krl-parser
Advanced tools
Comparing version 0.18.1 to 0.18.2
{ | ||
"name": "krl-parser", | ||
"version": "0.18.1", | ||
"version": "0.18.2", | ||
"description": "Parse KRL source code into an AST", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -198,4 +198,16 @@ // Generated automatically by nearley | ||
var defEnum = function(vals){ | ||
return { | ||
unparse_hint_enum: vals,//hint for KaRL42 "unparsing" | ||
test: function(x){ | ||
if(!x || x.type !== "SYMBOL"){ | ||
return false; | ||
} | ||
return vals.indexOf(x.src) >= 0; | ||
} | ||
}; | ||
}; | ||
var time_period_enum = [ | ||
var tok_TIME_PERIOD_ENUM = defEnum([ | ||
"years", | ||
@@ -215,20 +227,25 @@ "months", | ||
"second", | ||
]; | ||
var tok_TIME_PERIOD_ENUM = {test: function(x){ | ||
if(!x || x.type !== "SYMBOL"){ | ||
return false; | ||
} | ||
return time_period_enum.indexOf(x.src) >= 0; | ||
}}; | ||
]); | ||
var tok_LOG_LEVEL_ENUM = defEnum([ | ||
"error", | ||
"warn", | ||
"info", | ||
"debug", | ||
]); | ||
var tok = function(type, value){ | ||
return {test: function(x){ | ||
if(!x || x.type !== type){ | ||
return false; | ||
return { | ||
unparse_hint_type: type,//hint for KaRL42 "unparsing" | ||
unparse_hint_value: value,//hint for KaRL42 "unparsing" | ||
test: function(x){ | ||
if(!x || x.type !== type){ | ||
return false; | ||
} | ||
if(value){ | ||
return x.src === value; | ||
} | ||
return true; | ||
} | ||
if(value){ | ||
return x.src === value; | ||
} | ||
return true; | ||
}}; | ||
}; | ||
}; | ||
@@ -312,4 +329,6 @@ | ||
var tok_is = tok("SYMBOL", "is"); | ||
var tok_key = tok("SYMBOL", "key"); | ||
var tok_keys = tok("SYMBOL", "keys"); | ||
var tok_like = tok("SYMBOL", "like"); | ||
var tok_log = tok("SYMBOL", "log"); | ||
var tok_logging = tok("SYMBOL", "logging"); | ||
@@ -419,3 +438,3 @@ var tok_max = tok("SYMBOL", "max"); | ||
{"name": "ruleset_meta_prop$subexpression$1", "symbols": ["Map"]}, | ||
{"name": "ruleset_meta_prop", "symbols": [tok_keys, "Keyword", "ruleset_meta_prop$subexpression$1"], "postprocess": metaProp(function(data){return [data[1], data[2][0]]})}, | ||
{"name": "ruleset_meta_prop", "symbols": ["KEYs", "Keyword", "ruleset_meta_prop$subexpression$1"], "postprocess": metaProp(function(data){return [data[1], data[2][0]]})}, | ||
{"name": "ruleset_meta_prop$ebnf$1$subexpression$1", "symbols": [tok_version, "String"]}, | ||
@@ -477,2 +496,14 @@ {"name": "ruleset_meta_prop$ebnf$1", "symbols": ["ruleset_meta_prop$ebnf$1$subexpression$1"], "postprocess": id}, | ||
}, | ||
{"name": "KEYs$subexpression$1", "symbols": [tok_key]}, | ||
{"name": "KEYs$subexpression$1", "symbols": [tok_keys]}, | ||
{"name": "KEYs", "symbols": ["KEYs$subexpression$1"], "postprocess": | ||
function(data){ | ||
var d = data[0][0]; | ||
return { | ||
loc: d.loc, | ||
type: "Keyword", | ||
value: "keys" | ||
}; | ||
} | ||
}, | ||
{"name": "PROVIDEs$subexpression$1", "symbols": [tok_provides]}, | ||
@@ -742,2 +773,3 @@ {"name": "PROVIDEs$subexpression$1", "symbols": [tok_provide]}, | ||
{"name": "PostludeStatement_core", "symbols": ["RaiseEventStatement"], "postprocess": id}, | ||
{"name": "PostludeStatement_core", "symbols": ["LogStatement"], "postprocess": id}, | ||
{"name": "PersistentVariableAssignment$ebnf$1$subexpression$1", "symbols": [tok_OPEN_CURLY, "Expression", tok_CLSE_CURLY]}, | ||
@@ -793,2 +825,14 @@ {"name": "PersistentVariableAssignment$ebnf$1", "symbols": ["PersistentVariableAssignment$ebnf$1$subexpression$1"], "postprocess": id}, | ||
}, | ||
{"name": "LogStatement$ebnf$1", "symbols": [tok_LOG_LEVEL_ENUM], "postprocess": id}, | ||
{"name": "LogStatement$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "LogStatement", "symbols": [tok_log, "LogStatement$ebnf$1", "Expression"], "postprocess": | ||
function(data){ | ||
return { | ||
loc: mkLoc(data), | ||
type: "LogStatement", | ||
level: data[1] ? data[1].src : null, | ||
expression: data[2] | ||
}; | ||
} | ||
}, | ||
{"name": "Statement", "symbols": ["ExpressionStatement"], "postprocess": id}, | ||
@@ -851,5 +895,12 @@ {"name": "Statement", "symbols": ["Declaration"], "postprocess": id}, | ||
{"name": "declaration_list", "symbols": ["declaration_list", "Declaration"], "postprocess": concatArr(1)}, | ||
{"name": "WithArguments$ebnf$1", "symbols": ["IdentifierDeclaration"]}, | ||
{"name": "WithArguments$ebnf$1", "symbols": ["IdentifierDeclaration", "WithArguments$ebnf$1"], "postprocess": function arrconcat(d) {return [d[0]].concat(d[1]);}}, | ||
{"name": "WithArguments", "symbols": [tok_with, "WithArguments$ebnf$1"], "postprocess": getN(1)}, | ||
{"name": "WithArguments", "symbols": [tok_with, "With_body"], "postprocess": getN(1)}, | ||
{"name": "With_body", "symbols": ["IdentifierDeclaration"], "postprocess": idArr}, | ||
{"name": "With_body$subexpression$1", "symbols": ["IdentifierDeclaration"]}, | ||
{"name": "With_body$ebnf$1", "symbols": ["IdentifierDeclaration"]}, | ||
{"name": "With_body$ebnf$1", "symbols": ["IdentifierDeclaration", "With_body$ebnf$1"], "postprocess": function arrconcat(d) {return [d[0]].concat(d[1]);}}, | ||
{"name": "With_body", "symbols": ["With_body$subexpression$1", "With_body$ebnf$1"], "postprocess": concatArr(1)}, | ||
{"name": "With_body$subexpression$2", "symbols": ["IdentifierDeclaration"]}, | ||
{"name": "With_body", "symbols": ["With_body$subexpression$2", tok_and, "With_and_body"], "postprocess": concatArr(2)}, | ||
{"name": "With_and_body", "symbols": ["IdentifierDeclaration"], "postprocess": idArr}, | ||
{"name": "With_and_body", "symbols": ["With_and_body", tok_and, "IdentifierDeclaration"], "postprocess": concatArr(2)}, | ||
{"name": "Expression", "symbols": ["exp_conditional"], "postprocess": id}, | ||
@@ -856,0 +907,0 @@ {"name": "exp_conditional", "symbols": ["exp_or"], "postprocess": id}, |
Sorry, the diff of this file is not supported yet
91722
1378