Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scanner: rewrite in C #50

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@

---
CompileFlags:
Add:
Add:
- -Wall
- -Wextra
- -Wpedantic
- -Wimplicit-fallthrough
- -std=c++14
- -Wwrite-strings
- -Wshadow
- -Wundef
- -Wformat=2
- -Wnull-dereference
- -Wno-gnu-zero-variadic-macro-arguments
- -fno-exceptions
- -xc
- -DTREE_SITTER_INTERNAL_BUILD

Diagnostics:
ClangTidy:
Expand All @@ -25,19 +34,16 @@ Diagnostics:
- performance-*
- readability-*
Remove: modernize-use-trailing-return-type
CheckOptions:
CheckOptions:
cppcoreguidelines-avoid-do-while.IgnoreMacros: true
readability-function-cognitive-complexity.IgnoreMacros: true
readability-implicit-bool-conversion.AllowPointerConditions: true
readability-identifier-naming.ClassCase: CamelCase
readability-identifier-naming.ClassMemberSuffix: _
readability-identifier-naming.ConstantCase: CamelCase
readability-identifier-naming.ConstantCase: UPPER_CASE
readability-identifier-naming.LocalConstantCase: lower_case
readability-identifier-naming.EnumConstantCase: CamelCase
readability-identifier-naming.EnumConstantCase: UPPER_CASE
readability-identifier-naming.FunctionCase: lower_case
readability-identifier-naming.MacroDefinitionCase: UPPER_CASE
readability-identifier-naming.VariableCase: lower_case
misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: true
UnusedIncludes: Strict

# vim: set ft=yaml et:
9 changes: 1 addition & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,7 @@ jobs:
cache: "npm"
- run: npm ci
- name: Run test suite
run: |
if [[ "$RUNNER_OS" == macOS ]]; then
# macOS default compiler defaults to C++03 for some reason.
# Force at least C++14 via an another compiler.
export CXX=$(brew --prefix llvm@15)/bin/clang++
fi

npm test
run: npm test
shell: bash
- name: Test parsing sample Nim files
run: npm exec -- tree-sitter parse -s -t -q 'samples/**/*.nim'
Expand Down
2 changes: 1 addition & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"sources": [
"bindings/node/binding.cc",
"src/parser.c",
"src/scanner.cc"
"src/scanner.c"
],
"cflags_c": [
"-std=c99",
Expand Down
21 changes: 5 additions & 16 deletions bindings/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,18 @@ 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")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
c_config.file(&parser_path);

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")
.flag_if_supported("-std=c++14");
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());
}
Loading
Loading