diff options
| author | Ginger Bill <bill@gingerbill.org> | 2016-08-25 00:23:04 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2016-08-25 00:23:04 +0100 |
| commit | f93cf3827ba5cde4f054db99b9815cb2a18ba861 (patch) | |
| tree | e40e0ee29127b21e473ca2139cc102d08e86d4b3 /src/parser.cpp | |
| parent | d2c64be85ca15117b1745b254b1806ea739aef43 (diff) | |
Change rune literals to #rune "C"
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index ca090a9c7..1691e76de 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1144,7 +1144,22 @@ AstNode *parse_operand(AstFile *f, b32 lhs) { case Token_Hash: { operand = parse_tag_expr(f, NULL); - operand->TagExpr.expr = parse_expr(f, false); + String name = operand->TagExpr.name.string; + if (are_strings_equal(name, make_string("rune"))) { + if (f->cursor[0].kind == Token_String) { + Token *s = &f->cursor[0]; + + if (gb_utf8_strnlen(s->string.text, s->string.len) != 1) { + ast_file_err(f, *s, "Invalid rune literal %.*s", LIT(s->string)); + } + s->kind = Token_Rune; // NOTE(bill): Change it + } else { + expect_token(f, Token_String); + } + operand = parse_operand(f, lhs); + } else { + operand->TagExpr.expr = parse_expr(f, false); + } return operand; } |