Token_Type_Comment = 258,
+ Token_Type_Keyword_Start,
Token_Type_Keyword_Package,
Token_Type_Keyword_Struct,
Token_Type_Keyword_Enum,
Token_Type_Keyword_Macro,
Token_Type_Keyword_Interface,
Token_Type_Keyword_Where,
+ Token_Type_Keyword_End,
Token_Type_Right_Arrow,
Token_Type_Left_Arrow,
"TOKEN_TYPE_COMMENT",
+ "", // start
"package",
"struct",
"enum",
"macro",
"interface",
"where",
+ "", // end
"->",
"<-",
}
else {
OnyxToken* directive_token = expect_token(parser, '#');
- OnyxToken* symbol_token = expect_token(parser, Token_Type_Symbol);
+ OnyxToken* symbol_token = parser->curr;
+ consume_token(parser);
+
+ onyx_report_error(directive_token->pos, Error_Critical, "Unknown directive '#%b'.", symbol_token->text, symbol_token->length);
+
+ if (symbol_token->type > Token_Type_Keyword_Start && symbol_token->type < Token_Type_Keyword_End) {
+ onyx_report_error(directive_token->pos, Error_Critical, "Did you mean the keyword, '%s'?",
+ token_name(symbol_token->type));
+ }
- onyx_report_error(directive_token->pos, Error_Critical, "unknown directive '#%b'.", symbol_token->text, symbol_token->length);
return;
}
}
+//
+// Maybe at some point an alternate allocator would be good
+// for this? For now, I think the temporary allocator is sufficient.
+generator :: (ctx: ^$Ctx, gen: (^Ctx) -> ($T, bool)) -> Iterator(T) {
+ v := raw_alloc(context.temp_allocator, sizeof Ctx);
+ core.memory.copy(v, ctx, sizeof Ctx);
+
+ return .{
+ data = v,
+ next = gen
+ };
+}
+
+
#if runtime.Multi_Threading_Enabled {
#local sync :: core.sync