Skip to content

Better lexing(and scanning) and parsing #4

@lestherll

Description

@lestherll

There is currently an issue with the lexing strategy for unary operators. Because i have only partially implemented it, constructs that uses unary operators are note exactly recognised. For example

> -(1)
1  # should be -1 

This is problematic because it affects expressions such as to give wrong the answer

> -1^2
1  # should be -1
> -(1^2)
1  # should be -1

The main reason for this is that unary operators are not actually lexed themselves, when an expression such as -1 is passed, the program checks if the immediately succeeding character is a number and immediately binds the sign to the number after it, a bracket/parentheses is not a number and thus the operator doesn't get lexed independently at all disabling the parser to not recognise have any knowledge of it.

Also note that + and - are always initially tokenised as Token.BINARY_OPs and I believe this should change.

see this line

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions