feat(lexer): match backticks
parent
7227e953ae
commit
2387461e21
|
@ -138,7 +138,7 @@ void mrk_lexer_emit(mrk_token *out, mrk_lexer *lexer, mrk_token_type type) {
|
|||
}
|
||||
|
||||
void mrk_lexer_advance_text(mrk_lexer *lexer) {
|
||||
const char *special_chars = "*\n[]()\\";
|
||||
const char *special_chars = "*\n[]()\\`";
|
||||
|
||||
while (!mrk_lexer_done(lexer)) {
|
||||
if (strchr(special_chars, mrk_lexer_peek(lexer)) == NULL) {
|
||||
|
@ -281,6 +281,15 @@ void mrk_lexer_lex_start_of_line(mrk_token *out, mrk_lexer *lexer) {
|
|||
case '\t':
|
||||
mrk_lexer_emit(out, lexer, mrk_token_type_indent);
|
||||
break;
|
||||
case '`':
|
||||
if (mrk_lexer_peek_str(lexer, "``")) {
|
||||
mrk_lexer_advance_n(lexer, 2);
|
||||
mrk_lexer_emit(out, lexer, mrk_token_type_triple_backtick);
|
||||
} else {
|
||||
mrk_lexer_advance(lexer);
|
||||
mrk_lexer_emit(out, lexer, mrk_token_type_backtick);
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
// Match ordered list headers
|
||||
if (isdigit(c)) {
|
||||
|
@ -363,6 +372,10 @@ void mrk_lexer_lex_middle_of_line(mrk_token *out, mrk_lexer *lexer) {
|
|||
mrk_lexer_emit(out, lexer, mrk_token_type_text);
|
||||
}
|
||||
} break;
|
||||
case '`':
|
||||
mrk_lexer_advance(lexer);
|
||||
mrk_lexer_emit(out, lexer, mrk_token_type_backtick);
|
||||
break;
|
||||
default:
|
||||
mrk_lexer_advance_text(lexer);
|
||||
mrk_lexer_emit(out, lexer, mrk_token_type_text);
|
||||
|
|
Loading…
Reference in New Issue