This reverts commit 24ed4fd565
.
This commit is contained in:
parent
24ed4fd565
commit
4e210a9ca6
|
@ -9,7 +9,7 @@
|
|||
"sources": [
|
||||
"bindings/node/binding.cc",
|
||||
"src/parser.c",
|
||||
"src/scanner.c",
|
||||
# If your language uses an external scanner, add it here.
|
||||
],
|
||||
"cflags_c": [
|
||||
"-std=c99",
|
||||
|
|
|
@ -2,7 +2,7 @@ fn main() {
|
|||
let src_dir = std::path::Path::new("src");
|
||||
|
||||
let mut c_config = cc::Build::new();
|
||||
c_config.include(src_dir);
|
||||
c_config.include(&src_dir);
|
||||
c_config
|
||||
.flag_if_supported("-Wno-unused-parameter")
|
||||
.flag_if_supported("-Wno-unused-but-set-variable")
|
||||
|
@ -10,10 +10,29 @@ fn main() {
|
|||
let parser_path = src_dir.join("parser.c");
|
||||
c_config.file(&parser_path);
|
||||
|
||||
// If your language uses an external scanner written in C,
|
||||
// then include this block of code:
|
||||
|
||||
/*
|
||||
let scanner_path = src_dir.join("scanner.c");
|
||||
c_config.file(&scanner_path);
|
||||
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
||||
*/
|
||||
|
||||
c_config.compile("parser");
|
||||
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
|
||||
|
||||
// If your language uses an external scanner written in C++,
|
||||
// then include this block of code:
|
||||
|
||||
let mut cpp_config = cc::Build::new();
|
||||
cpp_config.cpp(true);
|
||||
cpp_config.include(&src_dir);
|
||||
cpp_config
|
||||
.flag_if_supported("-Wno-unused-parameter")
|
||||
.flag_if_supported("-Wno-unused-but-set-variable");
|
||||
let scanner_path = src_dir.join("scanner.cc");
|
||||
cpp_config.file(&scanner_path);
|
||||
cpp_config.compile("scanner");
|
||||
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#include <cwctype>
|
||||
#include <tree_sitter/parser.h>
|
||||
#include <wctype.h>
|
||||
|
||||
namespace {
|
||||
enum TokenType { BRACKET_ARGUMENT, BRACKET_COMMENT, LINE_COMMENT };
|
||||
void skip(TSLexer *lexer) { lexer->advance(lexer, true); }
|
||||
void advance(TSLexer *lexer) { lexer->advance(lexer, false); }
|
||||
void skip_wspace(TSLexer *lexer) {
|
||||
while (iswspace(lexer->lookahead)) {
|
||||
while (std::iswspace(lexer->lookahead)) {
|
||||
skip(lexer);
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +72,8 @@ bool scan(void *payload, TSLexer *lexer, bool const *valid_symbols) {
|
|||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
extern "C" {
|
||||
void *tree_sitter_cmake_external_scanner_create() { return NULL; }
|
||||
void tree_sitter_cmake_external_scanner_destroy(void *payload) {}
|
||||
unsigned tree_sitter_cmake_external_scanner_serialize(void *payload,
|
||||
|
@ -84,3 +87,4 @@ bool tree_sitter_cmake_external_scanner_scan(void *payload, TSLexer *lexer,
|
|||
bool const *valid_symbols) {
|
||||
return scan(payload, lexer, valid_symbols);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue