Add polymorph token

This commit is contained in:
Krzosa Karol
2023-03-29 11:42:40 +02:00
parent 710fbf431b
commit d8c80fb7a3
5 changed files with 14 additions and 2 deletions

View File

@@ -127,6 +127,7 @@ for i in meta.token_kinds:
TK_DoubleColon, TK_DoubleColon,
TK_At, TK_At,
TK_Arrow, TK_Arrow,
TK_Polymorph,
TK_ExprSizeof, TK_ExprSizeof,
TK_DocComment, TK_DocComment,
TK_Comment, TK_Comment,

View File

@@ -410,6 +410,15 @@ lex__stream(Core_Ctx *lexer) {
CASE3('&', TK_BitAnd, TK_AndAssign, TK_And); CASE3('&', TK_BitAnd, TK_AndAssign, TK_And);
CASE3('|', TK_BitOr, TK_OrAssign, TK_Or); CASE3('|', TK_BitOr, TK_OrAssign, TK_Or);
case '$': {
t.kind = TK_Polymorph;
lex_parse_ident(table, s, &t);
t.str += 1;
t.len -= 1;
t.intern_val = intern_string(table, t.string);
if (t.len == 0) token_error(&t, "Polymorph token without content"_s);
} break;
case '#': { case '#': {
t.kind = TK_Pound; t.kind = TK_Pound;
lex_parse_ident(table, s, &t); lex_parse_ident(table, s, &t);
@@ -758,6 +767,7 @@ for i in meta.token_kinds:
case TK_DoubleColon: return "::"; case TK_DoubleColon: return "::";
case TK_At: return "@"; case TK_At: return "@";
case TK_Arrow: return "->"; case TK_Arrow: return "->";
case TK_Polymorph: return "$";
case TK_ExprSizeof: return "[SizeOf]"; case TK_ExprSizeof: return "[SizeOf]";
case TK_DocComment: return "[///]"; case TK_DocComment: return "[///]";
case TK_Comment: return "//"; case TK_Comment: return "//";

View File

@@ -1,7 +1,7 @@
MA :: #import "Arena.core" MA :: #import "Arena.core"
/* /*
PushStruct :: (a: *MA.Arena, $Type): *Type PushStruct :: (a: *MA.Arena, $T: Type): *$T
size := size_of(Type) size := size_of(Type)
result := PushSize(a, size) result := PushSize(a, size)
return result return result

View File

@@ -83,6 +83,7 @@ token_rest = [
["DoubleColon", "::"], ["DoubleColon", "::"],
["At", "@"], ["At", "@"],
["Arrow", "->"], ["Arrow", "->"],
["Polymorph", "$"],
["ExprSizeof", "[SizeOf]"], ["ExprSizeof", "[SizeOf]"],
["DocComment", "[///]"], ["DocComment", "[///]"],
["Comment", "//"], ["Comment", "//"],