Named function args
This commit is contained in:
18
new_lex.c
18
new_lex.c
@@ -2,7 +2,8 @@ global Intern_String keyword_if;
|
||||
global Intern_String keyword_for;
|
||||
global Intern_String keyword_cast;
|
||||
global Intern_String keyword_else;
|
||||
global Intern_String keyword_sizeof;
|
||||
global Intern_String keyword_size_type;
|
||||
global Intern_String keyword_size_expr;
|
||||
global Intern_String keyword_typeof;
|
||||
global Intern_String keyword_while;
|
||||
global Intern_String keyword_switch;
|
||||
@@ -21,7 +22,8 @@ init_default_keywords(Intern_Table *t){
|
||||
keyword_cast = intern_string(t, lit("cast"));
|
||||
keyword_for = intern_string(t, lit("for"));
|
||||
keyword_else = intern_string(t, lit("else"));
|
||||
keyword_sizeof = intern_string(t, lit("sizeof"));
|
||||
keyword_size_type = intern_string(t, lit("size_type"));
|
||||
keyword_size_expr = intern_string(t, lit("size_expr"));
|
||||
keyword_typeof = intern_string(t, lit("typeof"));
|
||||
keyword_while = intern_string(t, lit("while"));
|
||||
keyword_switch = intern_string(t, lit("switch"));
|
||||
@@ -89,6 +91,7 @@ typedef enum Token_Kind{
|
||||
|
||||
TK_Colon,
|
||||
TK_Assign,
|
||||
TK_ColonAssign,
|
||||
TK_DivAssign,
|
||||
TK_MulAssign,
|
||||
TK_ModAssign,
|
||||
@@ -370,6 +373,10 @@ lex__stream(Token_Array *array, Lex_Stream *s){
|
||||
lex_advance(s);
|
||||
t.kind = TK_DoubleColon;
|
||||
}
|
||||
else if(lexc(s) == '='){
|
||||
lex_advance(s);
|
||||
t.kind = TK_ColonAssign;
|
||||
}
|
||||
else {
|
||||
t.kind = TK_Colon;
|
||||
}
|
||||
@@ -496,7 +503,7 @@ lex_test(){
|
||||
Arena *scratch = arena_begin_scratch();
|
||||
String test = lit("18446744073709551616{})(@?&+-;....->,:::/**/\"Thing\"//R\n Thingy"
|
||||
"\"Test_Meme\"+=-===42524 4294967295 18446744073709551615"
|
||||
"for if while switch");
|
||||
"for if while switch :=");
|
||||
Token_Array array = lex_stream(scratch, test, lit("Test1"));
|
||||
|
||||
Token_Kind kind[] = {
|
||||
@@ -505,7 +512,7 @@ lex_test(){
|
||||
TK_ThreeDots, TK_Dot, TK_Arrow, TK_Comma, TK_DoubleColon, TK_Colon,
|
||||
TK_StringLit, TK_Identifier, TK_StringLit, TK_AddAssign, TK_SubAssign,
|
||||
TK_Equals, TK_Int, TK_Int, TK_Int, TK_Keyword, TK_Keyword,
|
||||
TK_Keyword, TK_Keyword, TK_End
|
||||
TK_Keyword, TK_Keyword, TK_ColonAssign, TK_End
|
||||
};
|
||||
String strs[] = {
|
||||
lit("18446744073709551616"),lit("{"),lit("}"),lit(")"),lit("("),
|
||||
@@ -513,7 +520,7 @@ lex_test(){
|
||||
lit("..."),lit("."),lit("->"),lit(","),lit("::"),lit(":"),
|
||||
lit("Thing"),lit("Thingy"),lit("Test_Meme"), lit("+="),lit("-="),
|
||||
lit("=="),lit("42524"),lit("4294967295"),lit("18446744073709551615"),
|
||||
lit("for"), lit("if"), lit("while"), lit("switch"), lit(""),
|
||||
lit("for"), lit("if"), lit("while"), lit("switch"), lit(":="), lit(""),
|
||||
};
|
||||
U64 vals[] = {
|
||||
42524, 4294967295, 18446744073709551615llu
|
||||
@@ -563,6 +570,7 @@ global const char *token_kind_string[] = {
|
||||
[TK_GreaterThen] = ">",
|
||||
[TK_Colon] = ":",
|
||||
[TK_Assign] = "=",
|
||||
[TK_ColonAssign] = ":=",
|
||||
[TK_DivAssign] = "/=",
|
||||
[TK_MulAssign] = "*=",
|
||||
[TK_ModAssign] = "%=",
|
||||
|
||||
Reference in New Issue
Block a user