Skip to content

Commit 64cfbc2

Browse files
authored
feat: rewrite the scanner in C (#40)
* feat: rewrite the scanner in C * chore: update manifests & docs
1 parent 081179c commit 64cfbc2

File tree

5 files changed

+348
-317
lines changed

5 files changed

+348
-317
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Like in many regex systems, `*/+` is read as "0/1 or more", and `?` is 0 or 1.
2323

2424
## Example
2525

26-
``` org
26+
```org
2727
#+TITLE: Example
2828
2929
Some *marked up* words
@@ -43,6 +43,7 @@ Text
4343
```
4444

4545
Parses as:
46+
4647
```
4748
(document [0, 0] - [16, 0]
4849
body: (body [0, 0] - [4, 0]
@@ -117,13 +118,13 @@ For manual install, use `make`.
117118

118119
For neovim, using `nvim-treesitter/nvim-treesitter`, add to your configuration:
119120

120-
``` lua
121+
```lua
121122
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
122123
parser_config.org = {
123124
install_info = {
124125
url = 'https://github.com/milisims/tree-sitter-org',
125126
revision = 'main',
126-
files = { 'src/parser.c', 'src/scanner.cc' },
127+
files = { 'src/parser.c', 'src/scanner.c' },
127128
},
128129
filetype = 'org',
129130
}

binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"sources": [
1010
"src/parser.c",
1111
"bindings/node/binding.cc",
12-
"src/scanner.cc"
12+
"src/scanner.c"
1313
],
1414
"cflags_c": [
1515
"-std=c99",

bindings/rust/build.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,18 @@ fn main() {
22
let src_dir = std::path::Path::new("src");
33

44
let mut c_config = cc::Build::new();
5-
c_config.include(&src_dir);
5+
c_config.include(src_dir);
66
c_config
77
.flag_if_supported("-Wno-unused-parameter")
88
.flag_if_supported("-Wno-unused-but-set-variable")
99
.flag_if_supported("-Wno-trigraphs");
1010
let parser_path = src_dir.join("parser.c");
1111
c_config.file(&parser_path);
1212

13-
// If your language uses an external scanner written in C,
14-
// then include this block of code:
15-
16-
/*
1713
let scanner_path = src_dir.join("scanner.c");
1814
c_config.file(&scanner_path);
1915
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
20-
*/
2116

2217
c_config.compile("parser");
2318
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
24-
25-
// If your language uses an external scanner written in C++,
26-
// then include this block of code:
27-
28-
let mut cpp_config = cc::Build::new();
29-
cpp_config.cpp(true);
30-
cpp_config.include(&src_dir);
31-
cpp_config
32-
.flag_if_supported("-Wno-unused-parameter")
33-
.flag_if_supported("-Wno-unused-but-set-variable");
34-
let scanner_path = src_dir.join("scanner.cc");
35-
cpp_config.file(&scanner_path);
36-
cpp_config.compile("scanner");
37-
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
3819
}

0 commit comments

Comments
 (0)