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

Implement increments/decrements, as well as assign operators. #8

Open
NotJustAnna opened this issue Nov 14, 2021 · 0 comments
Open
Labels
component:compiler This issue is related to the Compiler and/or Bytecode. component:parser This issue is related to the Parser, Grammar and/or Parselets. enhancement New feature or request
Milestone

Comments

@NotJustAnna
Copy link
Owner

This issue refers to the not yet implemented operations: i++, ++i, i += 1.

i++/++i

At parser level: The respective prefix/infix parselets check if the right/left expression is an property accessor, and replaces the expression with a AST that signals the operation.

At AST level: Specialized versions of PropertyAccessExpr/IdentifierExpr/SubscriptAccessExpr are created to handle this increment/decrement operations. Use prefix: Boolean, decrement: Boolean to hold the required values.

At compiler level: It is quite simple to implement all but the subscript one:

  • Identifier is a simple GetVariable(identifier), Increment; SetVariable(identifier) operation.
  • PropertyAccess is a bit more complicated: +parent, Dup. GetMember(target), Increment, SetMember(target).
  • SubscriptAccess might require some scope quickmagic to work, since all subscript arguments should be called only once.

i += 1

At parser level: Handle it at the same place as the assign operations.

At AST level: Once again, specialized versions of PropertyAccessExpr/IdentifierExpr/SubscriptAccessExpr, but with an enum signifying which assign operations.

At compiler level: Same hassle as increment/decrement.

@NotJustAnna NotJustAnna added this to the Version 1.0 milestone Nov 14, 2021
@NotJustAnna NotJustAnna added component:compiler This issue is related to the Compiler and/or Bytecode. component:parser This issue is related to the Parser, Grammar and/or Parselets. enhancement New feature or request labels Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:compiler This issue is related to the Compiler and/or Bytecode. component:parser This issue is related to the Parser, Grammar and/or Parselets. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant