Open kevinbarabash opened 7 years ago
Given the following AST:
{
type: 'Apply',
op: 'add',
args: [
{ type: 'number', value: '1' },
{ type: 'identifier', value: 'a', subscript: { type: 'number', value: '0' },
{ type: 'Apply', op: 'mul', args: [ 5, 10, 20, 35, 50 ] },
],
}
The path ['args', '1', 'subscript']
corresponds to { type: 'number', value: '0' }
.
The path ['args', '2', 'args', ['1', '2', '3']]
corresponds to nodes 10
, 20
, 35
. (full node form omitted to save space.
There should be some sort of function to get the node at path. Calling it on an AST will return the node (or nodes) for the path in the given AST. If no nodes are found for the given path then it should return null
.
applyRule
should be updated to return a struct containing the following data:
A path is an array of object keys/array index.