Add polymorph token
This commit is contained in:
@@ -127,6 +127,7 @@ for i in meta.token_kinds:
|
||||
TK_DoubleColon,
|
||||
TK_At,
|
||||
TK_Arrow,
|
||||
TK_Polymorph,
|
||||
TK_ExprSizeof,
|
||||
TK_DocComment,
|
||||
TK_Comment,
|
||||
|
||||
@@ -410,6 +410,15 @@ lex__stream(Core_Ctx *lexer) {
|
||||
CASE3('&', TK_BitAnd, TK_AndAssign, TK_And);
|
||||
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 '#': {
|
||||
t.kind = TK_Pound;
|
||||
lex_parse_ident(table, s, &t);
|
||||
@@ -758,6 +767,7 @@ for i in meta.token_kinds:
|
||||
case TK_DoubleColon: return "::";
|
||||
case TK_At: return "@";
|
||||
case TK_Arrow: return "->";
|
||||
case TK_Polymorph: return "$";
|
||||
case TK_ExprSizeof: return "[SizeOf]";
|
||||
case TK_DocComment: return "[///]";
|
||||
case TK_Comment: return "//";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
MA :: #import "Arena.core"
|
||||
|
||||
/*
|
||||
PushStruct :: (a: *MA.Arena, $Type): *Type
|
||||
PushStruct :: (a: *MA.Arena, $T: Type): *$T
|
||||
size := size_of(Type)
|
||||
result := PushSize(a, size)
|
||||
return result
|
||||
|
||||
@@ -37,4 +37,4 @@ examples/unions.core - Error! Couldn't infer type of compound expression
|
||||
c = {10}
|
||||
*/
|
||||
|
||||
return 0
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user