mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
This allows us to combine multiple Errors together without repeating the prefix information. Also fixes several cases where two "COMPILATION ERROR" prefixes would be prepended to the same message when errors with prefixes and locations were produced by the lexer and parser.
24 lines
761 B
C++
24 lines
761 B
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "explorer/syntax/parse_and_lex_context.h"
|
|
|
|
#include "explorer/common/error_builders.h"
|
|
|
|
namespace Carbon {
|
|
|
|
auto ParseAndLexContext::RecordSyntaxError(Error error) -> Parser::symbol_type {
|
|
errors_.push_back(std::move(error));
|
|
|
|
// TODO: use `YYerror` token once bison is upgraded to at least 3.5.
|
|
return Parser::make_END_OF_FILE(current_token_position);
|
|
}
|
|
|
|
auto ParseAndLexContext::RecordSyntaxError(const std::string& message)
|
|
-> Parser::symbol_type {
|
|
return RecordSyntaxError(CompilationError(source_loc()) << message);
|
|
}
|
|
|
|
} // namespace Carbon
|