-
Notifications
You must be signed in to change notification settings - Fork 38
feat(acrorn-parser): adding support for binary expression #26
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||
| import { NodeClass, NodeClassConstructor } from './Node.abstract'; | ||||||||||
|
|
||||||||||
| export class BinaryExpressionClass extends NodeClass { | ||||||||||
| constructor(params: NodeClassConstructor) { | ||||||||||
| super(params); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| serialize = () => { | ||||||||||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||||||||||
| const binaryExpression = this.node as any; | ||||||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| const left = binaryExpression.left.value; | ||||||||||
| const right = binaryExpression.right.value; | ||||||||||
| const operator = binaryExpression.operator; | ||||||||||
| switch (operator) { | ||||||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 suggestion: |
||||||||||
| case '+': | ||||||||||
| return left + right; | ||||||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||
| case '-': | ||||||||||
| return left - right; | ||||||||||
| case '/': | ||||||||||
| return left / right; | ||||||||||
| case '*': | ||||||||||
| return left * right; | ||||||||||
| case '%': | ||||||||||
| return left % right; | ||||||||||
| default: | ||||||||||
| return 'operator not supported'; | ||||||||||
| } | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| traverse = () => {}; | ||||||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 suggestion(blocking): |
||||||||||
| } | ||||||||||

Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 suggestion:
Adding 5 additional binary expression examples to the "microtasks" example may create confusion as they are not related to microtasks.
What do you think about adding some of them to "everything" instead?