Files
carbon-lang/explorer/syntax/parse_and_lex_context.cpp
T
Richard Smith 7a67715ac5 Error: track message and prefix/location separately. (#1529)
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.
2022-07-26 15:08:19 -07:00

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