keon-dev / monkey-interpreter

A language interpreter written in Go. (Reference: "Writing an Interpreter In Go" by Thorsten Ball)
0 stars 0 forks source link

Create Lexer w/ preliminary parsing logic #2

Closed keon-dev closed 1 month ago

keon-dev commented 1 month ago

Perform lexical analysis to turn plain text source code into tokens

The lexer will receive input that looks like:

"let x = 5 + 5;"

And what comes out looks something like:

[
    LET,
    IDENTIFIER("x"),
    EQUAL_SIGN,
    INTEGER(5),
    PLUS_SIGN,
    INTEGER(5),
    SEMICOLON
]

Initial lexer should be able to parse the following snippet:

let five = 5;
let ten = 10;

let add = fn(x, y) {
    x + y;
};

let result = add(five, ten);

The following must be implemented to evaluate the above code: