Allowed effects and calculations to target nearest ancestors of #type
This commit is contained in:
@@ -24,7 +24,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'],
|
||||
}),
|
||||
|
||||
@@ -22,7 +22,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'],
|
||||
}),
|
||||
|
||||
@@ -7,7 +7,7 @@ export default class AccessorNode extends ParseNode {
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
}
|
||||
compile(scope){
|
||||
compile(scope, context){
|
||||
let value = scope && scope[this.name];
|
||||
// For objects, get their value
|
||||
this.path.forEach(name => {
|
||||
@@ -16,14 +16,21 @@ export default class AccessorNode extends ParseNode {
|
||||
});
|
||||
let type = typeof value;
|
||||
if (type === 'string' || type === 'number' || type === 'boolean'){
|
||||
return new ConstantNode({value, type, previousNodes: [this]});
|
||||
return new ConstantNode({value, type});
|
||||
} else if (type === 'undefined'){
|
||||
return new AccessorNode({
|
||||
name: this.name,
|
||||
path: this.path,
|
||||
});
|
||||
} else {
|
||||
throw new Meteor.Error(`Unexpected case: ${this.name} resolved to ${value}`);
|
||||
if (context) context.storeError({
|
||||
type: 'error',
|
||||
message: `${this.name} returned an unexpected type`
|
||||
});
|
||||
return new AccessorNode({
|
||||
name: this.name,
|
||||
path: this.path,
|
||||
});
|
||||
}
|
||||
}
|
||||
reduce(scope, context){
|
||||
|
||||
Reference in New Issue
Block a user