Skip to content

Branescript syntax does not support array indexing on identifiers. #29

@DanielVoogsgerd

Description

@DanielVoogsgerd

The documentation says Branescript allows array indexing in C style manner: foo[0].

However, looking at the formal definition, that seems to be not the case.

Expressions are defined as:

 Expr ::= LPAREN Expr RPAREN
        | Expr BinOp Expr
        | UnaOp Expr
        | Array | ArrayIndex | Call | IDENT | Instance | Literal
        | Projection

This does contain Array and ArrayIndex, but array is a definition of an array, not the usage of an identifier (variable) that points to / contains an array.

ArrayIndex suffers the same fate as it is prefixed with: Array itself: ArrayIndex ::= Array LBRACKET Expr RBRACKET

Proposed solutions:

We either have to change identifiers such that identifiers can be indexed by default, or we have to change ArrayIndex to be:

ArrayIndex ::= Array LBRACKET Expr RBRACKET | IDENT LBRACKET Expr RBRACKET\

The latter seems better to me in this case. @Lut99 Let me know what you think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions