Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the path of updated nodes in input and output ASTs #40

Open
kevinbarabash opened this issue May 31, 2017 · 2 comments
Open

Return the path of updated nodes in input and output ASTs #40

kevinbarabash opened this issue May 31, 2017 · 2 comments
Assignees

Comments

@kevinbarabash
Copy link
Member

A path is an array of object keys/array index.

@kevinbarabash
Copy link
Member Author

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.

@kevinbarabash
Copy link
Member Author

applyRule should be updated to return a struct containing the following data:

  • inputPath
  • outputPath
  • outputAST

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants