LytixDev / slash

The Slash Scripting Language
GNU General Public License v3.0
7 stars 0 forks source link

refactor/lexer #11

Closed LytixDev closed 1 year ago

LytixDev commented 1 year ago

Changes:

In Short:

Less jank. Less lines.

X macro for TokenType

Saves ~75 lines of code and makes it a lot easier to add a new token. Previously, adding a new token could mean you'd have to make changes three places in the code: enum definition, string representation table and keyword hashmap (in addition to any lexing and parsing rules). Now its only a matter of adding it to the appropriate X macro list. The downsides is this relies heavily on the preprocessor and makes the code more complicated to read and understand if you are not familiar with X macros.

New TokenType values

@[, ', ;, dt_list, dt_tuple, dt_map, t_break, t_continue

Added line and column information to lexer and individual Token

Fixed the lexing of:

optional '_' as a visual separator for large numbers

Updated the map and tuple syntax

@[ "key": "value" ] '1, 2, 3'

And some minor bug fixes