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

Assignables #5

Open
jchitel opened this issue Nov 9, 2017 · 1 comment
Open

Assignables #5

jchitel opened this issue Nov 9, 2017 · 1 comment
Assignees
Projects

Comments

@jchitel
Copy link
Owner

jchitel commented Nov 9, 2017

Assignables

Dependencies: Import/Export Additions

Description:

As of now, the only way to assign things is to use local variables. Obviously, other things are assignable:

  • fields/properties of structs/classes
  • array indices
  • this variable in class constructors
    Eventually:
  • destructuring
    • array destructuring
    • array rest
    • struct destructuring
    • struct rest

To support these things, we need assignable expressions.
Assignable expressions are a subset of expressions that can appear on the left side of an assignment statement.

New syntactic features:

New Tokens:

none

New NonTerminals:

Assignment ::= AssignableExpression EQUALS Expression
AssignableExpression ::= THIS
                       | IDENT
                       | FieldAccess
                       | ArrayAccess

Extended NonTerminals:

Expression ::= INTEGER_LITERAL |
               FLOATING_POINT_LITERAL |
               STRING_LITERAL |
               CHARACTER_LITERAL |
               VALUE |
               ArrayLiteral |
               StructLiteral |
               TupleLiteral |
               FunctionApplication |
               UnaryOperation |
               BinaryOperation |
               Assignment |           -- replaces VarDeclaration
               AssignableExpression | -- replaces FieldAccess, ArrayAccess, IDENT, and THIS
               LambdaExpression |
               IfElseExpression |
               MethodInvocation |
               MethodReference |
               NewObject |
               SuperCall |
               SuperMethodCall |
               LPAREN Expression RPAREN

New semantic features:

  • Assignments behave the same way as VarDeclarations
  • But this time there are things on the left side that already have a type, and are not inferred
  • The right side needs to be assignable to the left side

Transformation:

  • Assignable expressions will almost certainly require some sort of reference resolution logic
@jchitel jchitel self-assigned this Nov 9, 2017
@jchitel jchitel added this to To Do in Ren v0.1 via automation Nov 9, 2017
@jchitel
Copy link
Owner Author

jchitel commented Dec 4, 2017

#4 has been completed, so this is now open for development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Ren v0.1
  
To Do
Development

No branches or pull requests

1 participant