ONYX_MESSAGE_TYPE_NOT_LVAL,
ONYX_MESSAGE_TYPE_ASSIGN_CONST,
ONYX_MESSAGE_TYPE_UNKNOWN_SYMBOL,
+ ONYX_MESSAGE_TYPE_UNKNOWN_DIRECTIVE,
+
ONYX_MESSAGE_TYPE_CONFLICTING_GLOBALS,
ONYX_MESSAGE_TYPE_BINOP_MISMATCH_TYPE,
ONYX_MESSAGE_TYPE_ASSIGNMENT_TYPE_MISMATCH,
if (formal_param->base.type != actual_param->base.type) {
onyx_message_add(state->msgs,
ONYX_MESSAGE_TYPE_FUNCTION_PARAM_TYPE_MISMATCH,
- call->base.token->pos,
+ actual_param->value->token->pos,
callee->base.token->text, callee->base.token->length,
formal_param->base.type->name, arg_pos,
actual_param->base.type->name);
"expected lval '%b'",
"attempt to assign to constant '%b'",
"unknown symbol '%s'",
+ "unknown directive '%b'",
+
"conflicting declarations of global '%s'",
"mismatched types for binary operator, '%s', '%s'",
"mismatched types on assignment, expected '%s', got '%s'",
OnyxMessage* msg = msgs->first;
i32 msg_count = 3;
- while (msg && msg_count--) {
+ while (msg && msg_count-- > 0) {
if (msg->pos.filename) {
bh_file_contents* fc = &bh_table_get(bh_file_contents, *msgs->file_contents, (char *) msg->pos.filename);
expect(parser, '#');
OnyxToken* sym = expect(parser, TOKEN_TYPE_SYMBOL);
- return strncmp(dir, sym->text, sym->length) == 0;
+ b32 match = (strlen(dir) == sym->length) && (strncmp(dir, sym->text, sym->length) == 0);
+ if (!match) {
+ parser_prev_token(parser);
+ parser_prev_token(parser);
+ }
+ return match;
}
static AstNodeFunction* parse_function_definition(OnyxParser* parser) {
else if (parse_possible_directive(parser, "inline")) {
func_def->base.flags |= ONYX_AST_FLAG_INLINE;
}
+
+ else {
+ OnyxToken* directive_token = expect(parser, '#');
+ OnyxToken* symbol_token = expect(parser, TOKEN_TYPE_SYMBOL);
+
+ onyx_message_add(parser->msgs,
+ ONYX_MESSAGE_TYPE_UNKNOWN_DIRECTIVE,
+ directive_token->pos,
+ symbol_token->text, symbol_token->length);
+ }
}
AstNodeLocal* params = parse_function_params(parser);