corth-lang / Corth

A self-hosted stack based language like Forth
MIT License
7 stars 1 forks source link

Compilation of negative numbers #44

Closed HuseyinSimsek7904 closed 6 months ago

HuseyinSimsek7904 commented 6 months ago

When the lexer encounters a minus sign, it should try to convert the token to a number as it can be a negative number. Currently, lexer interprets the minus sign as a name.

A possible workaround right now is using the neg macro. For example:

// Instead of this which will be interpreted as a name:
-16

// This can be used which will be interpreted as an integer and the compiler will be able to push it as an immediate integer:
16 neg