rokucommunity / rokucommunity/brighterscript
Support finding lower and upper bounds of an expression chain
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 208
- Forks
- 68
- Avg merge
- 8h 39m
- Merged PRs (30d)
- 39
Description
We need a way to find the lower bounds and upper bounds (leftmost edge and rightmost edge) of an expression chain. Consider the following example:
delta["echo"]@.foxtrot( alpha.beta.charlie)
For alpha.beta.charlie we want to find:
expressionStart->alpha(VariableExpression)expressionEnd->charlie(DottedGetExpression)
For delta["echo"]@.foxtrot( alpha.beta.charlie) we want to find:
expressionStart- >delta(VariableExpression)expressionEnd->.foxtrot(...)(CallExpression)
I envision this being implemented by adding two new abstract methods to AstNode (or perhaps just on Expression since Statements make no sense in this context):
/**
* Get the subject of a given expression (the leftmost expression). (i.e. from `a.b.c` this returns `a`)
*/
findExpressionStart();
/**
* Get the rightmost expression from a given expression. (i.e. from `a.b.c` this returns `c`)
*/
findExpressionEnd()
-
findExpressionStartcould probably have a hardcodedreturn trueforVariableExpression,LiteralExpression, and any other expression types that are exclusively used to "start" an expression chain -
findExpressionEndwill be a little more complicated, but might be solved by checking parents are theIndexedGetExpression,DottedGetExpressionandCallExpressionwith the right calleeif expr.parent instanceof CallExpression && expr === parent.callee
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating AstNode, Expression, VariableExpression, LiteralExpression, IndexedGetExpression, DottedGetExpression, and CallExpression in the TypeScript source. Trace how the example expression chains are represented, then define the expected start and end results for both examples and add tests covering those cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100