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) {
|
void mrk_lexer_advance_text(mrk_lexer *lexer) {
|
||||||
const char *special_chars = "*\n[]()\\";
|
const char *special_chars = "*\n[]()\\`";
|
||||||
|
|
||||||
while (!mrk_lexer_done(lexer)) {
|
while (!mrk_lexer_done(lexer)) {
|
||||||
if (strchr(special_chars, mrk_lexer_peek(lexer)) == NULL) {
|
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':
|
case '\t':
|
||||||
mrk_lexer_emit(out, lexer, mrk_token_type_indent);
|
mrk_lexer_emit(out, lexer, mrk_token_type_indent);
|
||||||
break;
|
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: {
|
default: {
|
||||||
// Match ordered list headers
|
// Match ordered list headers
|
||||||
if (isdigit(c)) {
|
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);
|
mrk_lexer_emit(out, lexer, mrk_token_type_text);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case '`':
|
||||||
|
mrk_lexer_advance(lexer);
|
||||||
|
mrk_lexer_emit(out, lexer, mrk_token_type_backtick);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
mrk_lexer_advance_text(lexer);
|
mrk_lexer_advance_text(lexer);
|
||||||
mrk_lexer_emit(out, lexer, mrk_token_type_text);
|
mrk_lexer_emit(out, lexer, mrk_token_type_text);
|
||||||
|
|
Loading…
Reference in New Issue