Fixed parser to allow $ and x.0.thing in variable references
This commit is contained in:
@@ -3,7 +3,7 @@ import recalculateCalculation from './recalculateCalculation.js'
|
||||
|
||||
export default function recalculateInlineCalculations(inlineCalcObj, scope, log){
|
||||
// Skip if there are no calculations
|
||||
if (!inlineCalcObj?.calculations?.length) return;
|
||||
if (!inlineCalcObj?.inlineCalculations?.length) return;
|
||||
// Recalculate each calculation with the current scope
|
||||
inlineCalcObj.inlineCalculations.forEach(calc => {
|
||||
recalculateCalculation(calc, scope, log);
|
||||
|
||||
@@ -13,7 +13,7 @@ function id(x) { return x[0]; }
|
||||
value: s => s.slice(1, -1),
|
||||
},
|
||||
name: {
|
||||
match: /[a-zA-Z_#]*[a-ce-zA-Z_#][a-zA-Z0-9_#]*/,
|
||||
match: /[a-zA-Z_#$]*[a-ce-zA-Z_#$][a-zA-Z0-9_#$]*/,
|
||||
type: moo.keywords({
|
||||
'keywords': ['true', 'false'],
|
||||
}),
|
||||
@@ -109,14 +109,16 @@ let ParserRules = [
|
||||
{"name": "parenthesizedExpression", "symbols": [{"literal":"("}, "_", "expression", "_", {"literal":")"}], "postprocess": d => node.parenthesis.create({content: d[2]})},
|
||||
{"name": "parenthesizedExpression", "symbols": ["accessorExpression"], "postprocess": id},
|
||||
{"name": "accessorExpression$subexpression$1", "symbols": [(lexer.has("name") ? {type: "name"} : name)], "postprocess": d => d[0].value},
|
||||
{"name": "accessorExpression$ebnf$1$subexpression$1", "symbols": [{"literal":"."}, (lexer.has("name") ? {type: "name"} : name)], "postprocess": d => d[1].value},
|
||||
{"name": "accessorExpression$ebnf$1$subexpression$1", "symbols": [{"literal":"."}, "keyExpression"], "postprocess": d => d[1]},
|
||||
{"name": "accessorExpression$ebnf$1", "symbols": ["accessorExpression$ebnf$1$subexpression$1"]},
|
||||
{"name": "accessorExpression$ebnf$1$subexpression$2", "symbols": [{"literal":"."}, (lexer.has("name") ? {type: "name"} : name)], "postprocess": d => d[1].value},
|
||||
{"name": "accessorExpression$ebnf$1$subexpression$2", "symbols": [{"literal":"."}, "keyExpression"], "postprocess": d => d[1]},
|
||||
{"name": "accessorExpression$ebnf$1", "symbols": ["accessorExpression$ebnf$1", "accessorExpression$ebnf$1$subexpression$2"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
||||
{"name": "accessorExpression", "symbols": ["accessorExpression$subexpression$1", "accessorExpression$ebnf$1"], "postprocess":
|
||||
d=> node.accessor.create({name: d[0], path: d[1]})
|
||||
},
|
||||
{"name": "accessorExpression", "symbols": ["valueExpression"], "postprocess": id},
|
||||
{"name": "keyExpression", "symbols": ["name"], "postprocess": d => d[0].name},
|
||||
{"name": "keyExpression", "symbols": ["number"], "postprocess": d => d[0].value},
|
||||
{"name": "valueExpression", "symbols": ["name"], "postprocess": id},
|
||||
{"name": "valueExpression", "symbols": ["number"], "postprocess": id},
|
||||
{"name": "valueExpression", "symbols": ["string"], "postprocess": id},
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
value: s => s.slice(1, -1),
|
||||
},
|
||||
name: {
|
||||
match: /[a-zA-Z_#]*[a-ce-zA-Z_#][a-zA-Z0-9_#]*/,
|
||||
match: /[a-zA-Z_#$]*[a-ce-zA-Z_#$][a-zA-Z0-9_#$]*/,
|
||||
type: moo.keywords({
|
||||
'keywords': ['true', 'false'],
|
||||
}),
|
||||
@@ -138,11 +138,14 @@ parenthesizedExpression ->
|
||||
| accessorExpression {% id %}
|
||||
|
||||
accessorExpression ->
|
||||
(%name {% d => d[0].value %}) ( "." %name {% d => d[1].value %} ):+ {%
|
||||
(%name {% d => d[0].value %}) ( "." keyExpression {% d => d[1] %} ):+ {%
|
||||
d=> node.accessor.create({name: d[0], path: d[1]})
|
||||
%}
|
||||
| valueExpression {% id %}
|
||||
|
||||
keyExpression -> name {% d => d[0].name %}
|
||||
| number {% d => d[0].value %}
|
||||
|
||||
valueExpression ->
|
||||
name {% id %}
|
||||
| number {% id %}
|
||||
|
||||
28
app/package-lock.json
generated
28
app/package-lock.json
generated
@@ -2410,9 +2410,12 @@
|
||||
"integrity": "sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw=="
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
||||
"version": "2.6.7",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
|
||||
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
|
||||
"requires": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"nopt": {
|
||||
"version": "5.0.0",
|
||||
@@ -3046,6 +3049,11 @@
|
||||
"punycode": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
|
||||
},
|
||||
"tunnel-agent": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
||||
@@ -3221,6 +3229,20 @@
|
||||
"resolved": "https://registry.npmjs.org/vuex/-/vuex-3.6.2.tgz",
|
||||
"integrity": "sha512-ETW44IqCgBpVomy520DT5jf8n0zoCac+sxWnn+hMe/CzaSejb/eVw2YToiXYX+Ex/AuHHia28vWTq4goAexFbw=="
|
||||
},
|
||||
"webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
|
||||
},
|
||||
"whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
|
||||
"requires": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
|
||||
Reference in New Issue
Block a user