on the way to better errors
This commit is contained in:
+20
-15
@@ -166,15 +166,15 @@ namespace Parser {
|
||||
// we found the end of the string
|
||||
text[*index_in_text+string_length] = '\0';
|
||||
|
||||
String* string = Memory::create_string("", string_length);
|
||||
|
||||
if (!unescape_string(text+(*index_in_text))) {
|
||||
create_error(
|
||||
Error_Type::Unknown_Error,
|
||||
create_source_code_location(parser_file, parser_line, parser_col));
|
||||
create_parsing_error(
|
||||
"The string '%s' at %s:%d:%d could not be unescaped.",
|
||||
text+(*index_in_text), parser_file, parser_line, parser_col);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
String* string = Memory::create_string("", string_length);
|
||||
|
||||
// TODO(Felix): manually copy to parse control sequences
|
||||
// correctly without the need to unescape the string, also
|
||||
// better for keeping track of the encountered new lines and
|
||||
@@ -314,7 +314,9 @@ namespace Parser {
|
||||
|
||||
eat_until_code(text, index_in_text);
|
||||
if (text[(*index_in_text)] == '\0') {
|
||||
create_error(Error_Type::Unexpected_Eof, create_source_code_location(parser_file, parser_line, parser_col));
|
||||
create_parsing_error(
|
||||
"Unexpected EOF in %s:%d:%d",
|
||||
parser_file, parser_line, parser_col);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -337,7 +339,9 @@ namespace Parser {
|
||||
eat_until_code(text, index_in_text);
|
||||
|
||||
if (text[(*index_in_text)] != ')')
|
||||
create_error(Error_Type::Syntax_Error, create_source_code_location(parser_file, parser_line, parser_col));
|
||||
create_parsing_error(
|
||||
"Expected ')' after the element after the '.' in %s:%d:%d",
|
||||
create_source_code_location(parser_file, parser_line, parser_col));
|
||||
++parser_col;
|
||||
++(*index_in_text);
|
||||
break;
|
||||
@@ -362,14 +366,11 @@ namespace Parser {
|
||||
|
||||
// (define-syntax defun (name args :rest body) (...))
|
||||
if (arguments_length < 2) {
|
||||
create_error(Error_Type::Wrong_Number_Of_Arguments, expression->sourceCodeLocation);
|
||||
create_wrong_number_of_arguments_error(3, arguments_length);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (arguments->value.pair.first->type != Lisp_Object_Type::Symbol) {
|
||||
create_error(Error_Type::Type_Missmatch, expression->sourceCodeLocation);
|
||||
return nullptr;
|
||||
}
|
||||
assert_type(arguments->value.pair.first, Lisp_Object_Type::Symbol);
|
||||
|
||||
// extract the name
|
||||
Lisp_Object* symbol_for_macro = arguments->value.pair.first;
|
||||
@@ -429,7 +430,8 @@ namespace Parser {
|
||||
// that, when an entry is not found immidiately, we
|
||||
// know for sure that it does not exist in the table.
|
||||
|
||||
create_error(Error_Type::Not_Yet_Implemented, expression->sourceCodeLocation);
|
||||
create_generic_error("deleting macros has not yet be implemented,"
|
||||
"and I don't know if it is a good idea to do so.");
|
||||
return nullptr;
|
||||
} else {
|
||||
// if threre is a macro named like this, then macroexpand
|
||||
@@ -478,7 +480,9 @@ namespace Parser {
|
||||
eat_until_code(text, &index_in_text);
|
||||
if (text[(index_in_text)] == '\0')
|
||||
return result;
|
||||
create_error(Error_Type::Trailing_Garbage, create_source_code_location(parser_file, parser_line, parser_col));
|
||||
|
||||
create_parsing_error("Trainling garbage after expression at %s:%d:%d",
|
||||
parser_file, parser_line, parser_col);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -573,7 +577,8 @@ namespace Parser {
|
||||
} break;
|
||||
default:
|
||||
/* syntax error */
|
||||
create_error(Error_Type::Syntax_Error, create_source_code_location(parser_file, parser_line, parser_col));
|
||||
create_parsing_error("Garbage in file scope at %s:%d:%d",
|
||||
parser_file, parser_line, parser_col);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user