mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 10:31:03 +01:00
Rename lexer dir to lex (#3179)
Continuing with #3070. Just a dir and file rename (only prefix change is lexer_file_test). Everything in the lex dir should be marked as a move. Note, I think this closes #3070. There may still be further cleanup later, but the organizational changes suggested there are being completed. --------- Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
co-authored by
Chandler Carruth
parent
c555b39a2c
commit
ec182fb00d
@@ -0,0 +1,43 @@
|
||||
// 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 <cstring>
|
||||
|
||||
#include "common/check.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "toolchain/diagnostics/null_diagnostics.h"
|
||||
#include "toolchain/lex/string_literal.h"
|
||||
|
||||
namespace Carbon::Testing {
|
||||
|
||||
// NOLINTNEXTLINE: Match the documented fuzzer entry point declaration style.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data,
|
||||
std::size_t size) {
|
||||
auto token = Lex::StringLiteral::Lex(
|
||||
llvm::StringRef(reinterpret_cast<const char*>(data), size));
|
||||
if (!token) {
|
||||
// Lexically not a string literal.
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!token->is_terminated()) {
|
||||
// Found errors while parsing.
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stderr, "valid: %d\n", token->is_terminated());
|
||||
fprintf(stderr, "size: %lu\n", token->text().size());
|
||||
fprintf(stderr, "text: %s\n", token->text().str().c_str());
|
||||
|
||||
// Check multiline flag was computed correctly.
|
||||
CARBON_CHECK(token->is_multi_line() == token->text().contains('\n'));
|
||||
|
||||
volatile auto value =
|
||||
token->ComputeValue(NullDiagnosticEmitter<const char*>());
|
||||
(void)value;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace Carbon::Testing
|
||||
Reference in New Issue
Block a user