Skip to content

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

@NotJustAnna

Description

@NotJustAnna

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component:compilerThis issue is related to the Compiler and/or Bytecode.component:parserThis issue is related to the Parser, Grammar and/or Parselets.enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions