feat(lexer): parse equal signs

main
Jef Roosens 2024-03-04 19:13:51 +01:00
parent f6e034097d
commit dc3cfc5fbe
Signed by: Jef Roosens
GPG Key ID: 02D4C0997E74717B
2 changed files with 7 additions and 1 deletions

View File

@ -19,6 +19,7 @@ typedef enum mrk_token_type {
mrk_token_type_dashes,
mrk_token_type_underscores,
mrk_token_type_stars,
mrk_token_type_equals,
mrk_token_type_blank_line,
mrk_token_type_space,
mrk_token_type_line_break,

View File

@ -124,7 +124,8 @@ mrk_lexer_err mrk_lexer_next(mrk_token *out, mrk_lexer *lexer) {
char c = mrk_lexer_advance(lexer);
switch (c) {
// All these characters have multiple meanings depending on their location
// in the file and how many there are
// in the file and how many there are, so the lexer can only match them as
// one or more grouped characters
case '#':
mrk_lexer_advance_eq(lexer, c);
mrk_lexer_emit(out, lexer, mrk_token_type_pounds);
@ -145,6 +146,10 @@ mrk_lexer_err mrk_lexer_next(mrk_token *out, mrk_lexer *lexer) {
mrk_lexer_advance_eq(lexer, c);
mrk_lexer_emit(out, lexer, mrk_token_type_stars);
break;
case '=':
mrk_lexer_advance_eq(lexer, c);
mrk_lexer_emit(out, lexer, mrk_token_type_equals);
break;
// Two consecutive newlines constitute a blank line, otherwise they're
// ignored as whitespace
case '\n':