beancount-format 0.1.16__tar.gz → 0.1.18__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. {beancount_format-0.1.16 → beancount_format-0.1.18}/Cargo.lock +29 -33
  2. {beancount_format-0.1.16 → beancount_format-0.1.18}/Cargo.toml +3 -3
  3. {beancount_format-0.1.16 → beancount_format-0.1.18}/PKG-INFO +1 -1
  4. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/Cargo.toml +0 -1
  5. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter-cli/Cargo.toml +1 -1
  6. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter-py/Cargo.toml +1 -1
  7. beancount_format-0.1.18/patches/tree-sitter-language/Cargo.toml +19 -0
  8. beancount_format-0.1.18/patches/tree-sitter-language/LICENSE +21 -0
  9. beancount_format-0.1.18/patches/tree-sitter-language/README.md +4 -0
  10. beancount_format-0.1.18/patches/tree-sitter-language/build.rs +13 -0
  11. beancount_format-0.1.18/patches/tree-sitter-language/src/language.rs +23 -0
  12. beancount_format-0.1.18/patches/tree-sitter-language/wasm/include/assert.h +14 -0
  13. beancount_format-0.1.18/patches/tree-sitter-language/wasm/include/ctype.h +8 -0
  14. beancount_format-0.1.18/patches/tree-sitter-language/wasm/include/endian.h +12 -0
  15. beancount_format-0.1.18/patches/tree-sitter-language/wasm/include/inttypes.h +8 -0
  16. beancount_format-0.1.18/patches/tree-sitter-language/wasm/include/stdint.h +46 -0
  17. beancount_format-0.1.18/patches/tree-sitter-language/wasm/include/stdio.h +36 -0
  18. beancount_format-0.1.18/patches/tree-sitter-language/wasm/include/stdlib.h +15 -0
  19. beancount_format-0.1.18/patches/tree-sitter-language/wasm/include/string.h +18 -0
  20. beancount_format-0.1.18/patches/tree-sitter-language/wasm/include/wctype.h +168 -0
  21. beancount_format-0.1.18/patches/tree-sitter-language/wasm/src/stdio.c +299 -0
  22. beancount_format-0.1.18/patches/tree-sitter-language/wasm/src/stdlib.c +161 -0
  23. beancount_format-0.1.18/patches/tree-sitter-language/wasm/src/string.c +66 -0
  24. {beancount_format-0.1.16 → beancount_format-0.1.18}/pyproject.toml +2 -1
  25. {beancount_format-0.1.16 → beancount_format-0.1.18}/LICENSE +0 -0
  26. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/src/configuration/configuration.rs +0 -0
  27. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/src/configuration/mod.rs +0 -0
  28. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/src/configuration/new_line_kind.rs +0 -0
  29. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/src/format.rs +0 -0
  30. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/src/lib.rs +0 -0
  31. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/src/parse.rs +0 -0
  32. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/applies_configured_crlf_newlines.config.json +0 -0
  33. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/applies_configured_crlf_newlines.expected.bean +0 -0
  34. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/applies_configured_crlf_newlines.input.bean +0 -0
  35. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/caps_blank_lines_between_directives.expected.bean +0 -0
  36. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/caps_blank_lines_between_directives.input.bean +0 -0
  37. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/formats_all_directives.config.json +0 -0
  38. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/formats_all_directives.expected.bean +0 -0
  39. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/formats_all_directives.input.bean +0 -0
  40. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/formats_transaction_preserves_postings.expected.bean +0 -0
  41. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/formats_transaction_preserves_postings.input.bean +0 -0
  42. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/formats_without_changes_returns_none.expected.bean +0 -0
  43. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/formats_without_changes_returns_none.input.bean +0 -0
  44. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/normalizes_tabs_and_trailing_spaces.expected.bean +0 -0
  45. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/normalizes_tabs_and_trailing_spaces.input.bean +0 -0
  46. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/preserve-meta.expected.bean +0 -0
  47. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/preserve-meta.input.bean +0 -0
  48. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/preserve_comments.expected.bean +0 -0
  49. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/preserve_comments.input.bean +0 -0
  50. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/preserve_file_path_header.expected.bean +0 -0
  51. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/preserve_file_path_header.input.bean +0 -0
  52. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/support_input_without_eol.expected.bean +0 -0
  53. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format-and-check/support_input_without_eol.input.bean +0 -0
  54. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter/tests/format_cases.rs +0 -0
  55. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter-cli/src/lib.rs +0 -0
  56. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter-cli/src/main.rs +0 -0
  57. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter-cli/tests/cli_e2e.rs +0 -0
  58. {beancount_format-0.1.16 → beancount_format-0.1.18}/crates/beancount-formatter-py/src/lib.rs +0 -0
  59. {beancount_format-0.1.16 → beancount_format-0.1.18}/python/README.md +0 -0
  60. {beancount_format-0.1.16 → beancount_format-0.1.18}/python/src/beancount_format/__init__.py +0 -0
  61. {beancount_format-0.1.16 → beancount_format-0.1.18}/python/src/beancount_format/beancount_format.pyi +0 -0
@@ -128,11 +128,10 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
128
128
 
129
129
  [[package]]
130
130
  name = "beancount-formatter"
131
- version = "0.1.16"
131
+ version = "0.1.18"
132
132
  dependencies = [
133
133
  "anyhow",
134
134
  "beancount-parser",
135
- "ropey",
136
135
  "serde",
137
136
  "serde_json",
138
137
  "similar",
@@ -141,7 +140,7 @@ dependencies = [
141
140
 
142
141
  [[package]]
143
142
  name = "beancount-formatter-cli"
144
- version = "0.1.16"
143
+ version = "0.1.18"
145
144
  dependencies = [
146
145
  "anyhow",
147
146
  "assert_cmd",
@@ -155,7 +154,7 @@ dependencies = [
155
154
 
156
155
  [[package]]
157
156
  name = "beancount-formatter-py"
158
- version = "0.1.16"
157
+ version = "0.1.18"
159
158
  dependencies = [
160
159
  "beancount-formatter",
161
160
  "beancount-formatter-cli",
@@ -279,9 +278,9 @@ checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3"
279
278
 
280
279
  [[package]]
281
280
  name = "cc"
282
- version = "1.2.54"
281
+ version = "1.2.55"
283
282
  source = "registry+https://github.com/rust-lang/crates.io-index"
284
- checksum = "6354c81bbfd62d9cfa9cb3c773c2b7b2a3a482d569de977fd0e961f6e7c00583"
283
+ checksum = "47b26a0954ae34af09b50f0de26458fa95369a0d478d8236d3f93082b219bd29"
285
284
  dependencies = [
286
285
  "find-msvc-tools",
287
286
  "shlex",
@@ -310,9 +309,9 @@ dependencies = [
310
309
 
311
310
  [[package]]
312
311
  name = "clap"
313
- version = "4.5.54"
312
+ version = "4.5.56"
314
313
  source = "registry+https://github.com/rust-lang/crates.io-index"
315
- checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394"
314
+ checksum = "a75ca66430e33a14957acc24c5077b503e7d374151b2b4b3a10c83b4ceb4be0e"
316
315
  dependencies = [
317
316
  "clap_builder",
318
317
  "clap_derive",
@@ -320,9 +319,9 @@ dependencies = [
320
319
 
321
320
  [[package]]
322
321
  name = "clap_builder"
323
- version = "4.5.54"
322
+ version = "4.5.56"
324
323
  source = "registry+https://github.com/rust-lang/crates.io-index"
325
- checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00"
324
+ checksum = "793207c7fa6300a0608d1080b858e5fdbe713cdc1c8db9fb17777d8a13e63df0"
326
325
  dependencies = [
327
326
  "anstream",
328
327
  "anstyle",
@@ -332,9 +331,9 @@ dependencies = [
332
331
 
333
332
  [[package]]
334
333
  name = "clap_derive"
335
- version = "4.5.49"
334
+ version = "4.5.55"
336
335
  source = "registry+https://github.com/rust-lang/crates.io-index"
337
- checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671"
336
+ checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5"
338
337
  dependencies = [
339
338
  "heck",
340
339
  "proc-macro2",
@@ -385,17 +384,6 @@ version = "0.4.0"
385
384
  source = "registry+https://github.com/rust-lang/crates.io-index"
386
385
  checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
387
386
 
388
- [[package]]
389
- name = "dlmalloc"
390
- version = "0.2.12"
391
- source = "registry+https://github.com/rust-lang/crates.io-index"
392
- checksum = "6738d2e996274e499bc7b0d693c858b7720b9cd2543a0643a3087e6cb0a4fa16"
393
- dependencies = [
394
- "cfg-if",
395
- "libc",
396
- "windows-sys",
397
- ]
398
-
399
387
  [[package]]
400
388
  name = "doc-comment"
401
389
  version = "0.3.4"
@@ -420,11 +408,10 @@ dependencies = [
420
408
 
421
409
  [[package]]
422
410
  name = "dprint-plugin-beancount"
423
- version = "0.1.16"
411
+ version = "0.1.18"
424
412
  dependencies = [
425
413
  "anyhow",
426
414
  "beancount-formatter",
427
- "dlmalloc",
428
415
  "dprint-core",
429
416
  "serde_json",
430
417
  ]
@@ -453,9 +440,9 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
453
440
 
454
441
  [[package]]
455
442
  name = "find-msvc-tools"
456
- version = "0.1.8"
443
+ version = "0.1.9"
457
444
  source = "registry+https://github.com/rust-lang/crates.io-index"
458
- checksum = "8591b0bcc8a98a64310a2fae1bb3e9b8564dd10e381e6e28010fde8e8e8568db"
445
+ checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
459
446
 
460
447
  [[package]]
461
448
  name = "float-cmp"
@@ -788,6 +775,7 @@ version = "0.27.2"
788
775
  source = "registry+https://github.com/rust-lang/crates.io-index"
789
776
  checksum = "b455933107de8642b4487ed26d912c2d899dec6114884214a0b3bb3be9261ea6"
790
777
  dependencies = [
778
+ "python3-dll-a",
791
779
  "target-lexicon",
792
780
  ]
793
781
 
@@ -826,6 +814,15 @@ dependencies = [
826
814
  "syn 2.0.114",
827
815
  ]
828
816
 
817
+ [[package]]
818
+ name = "python3-dll-a"
819
+ version = "0.2.14"
820
+ source = "registry+https://github.com/rust-lang/crates.io-index"
821
+ checksum = "d381ef313ae70b4da5f95f8a4de773c6aa5cd28f73adec4b4a31df70b66780d8"
822
+ dependencies = [
823
+ "cc",
824
+ ]
825
+
829
826
  [[package]]
830
827
  name = "quote"
831
828
  version = "1.0.44"
@@ -1244,8 +1241,7 @@ dependencies = [
1244
1241
 
1245
1242
  [[package]]
1246
1243
  name = "tree-sitter-language"
1247
- version = "0.1.7"
1248
- source = "git+https://github.com/trim21/tree-sitter.git?rev=b714e2a7c01e8d5abab526f23e40b77c33babcb4#b714e2a7c01e8d5abab526f23e40b77c33babcb4"
1244
+ version = "0.1.6"
1249
1245
 
1250
1246
  [[package]]
1251
1247
  name = "unicode-ident"
@@ -1422,18 +1418,18 @@ dependencies = [
1422
1418
 
1423
1419
  [[package]]
1424
1420
  name = "zerocopy"
1425
- version = "0.8.34"
1421
+ version = "0.8.37"
1426
1422
  source = "registry+https://github.com/rust-lang/crates.io-index"
1427
- checksum = "71ddd76bcebeed25db614f82bf31a9f4222d3fbba300e6fb6c00afa26cbd4d9d"
1423
+ checksum = "7456cf00f0685ad319c5b1693f291a650eaf345e941d082fc4e03df8a03996ac"
1428
1424
  dependencies = [
1429
1425
  "zerocopy-derive",
1430
1426
  ]
1431
1427
 
1432
1428
  [[package]]
1433
1429
  name = "zerocopy-derive"
1434
- version = "0.8.34"
1430
+ version = "0.8.37"
1435
1431
  source = "registry+https://github.com/rust-lang/crates.io-index"
1436
- checksum = "d8187381b52e32220d50b255276aa16a084ec0a9017a0ca2152a1f55c539758d"
1432
+ checksum = "1328722bbf2115db7e19d69ebcc15e795719e2d66b60827c6a69a117365e37a0"
1437
1433
  dependencies = [
1438
1434
  "proc-macro2",
1439
1435
  "quote",
@@ -3,7 +3,7 @@ members = ["crates/*"]
3
3
  resolver = "3"
4
4
 
5
5
  [workspace.package]
6
- version = "0.1.16"
6
+ version = "0.1.18"
7
7
  authors = ["Trim21 <trim21.me@gmail.com>"]
8
8
  edition = "2024"
9
9
  homepage = "https://github.com/trim21/beancount-format"
@@ -17,8 +17,8 @@ beancount-formatter = { path = "./crates/beancount-formatter/" }
17
17
  serde = { version = "1.0.228", features = ["derive"] }
18
18
 
19
19
  [patch.crates-io]
20
- # tree-sitter-language = { path = "./patches/tree-sitter-language-0.1.6/" }
21
- tree-sitter-language = { git = 'https://github.com/trim21/tree-sitter.git', rev = 'b714e2a7c01e8d5abab526f23e40b77c33babcb4' }
20
+ tree-sitter-language = { path = "./patches/tree-sitter-language/" }
21
+ # tree-sitter-language = { git = 'https://github.com/tree-sitter/tree-sitter.git', rev = '88a54754966cc8156d557b531a7b8a808a1768a5' }
22
22
 
23
23
  [profile.release]
24
24
  opt-level = 3
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: beancount-format
3
- Version: 0.1.16
3
+ Version: 0.1.18
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python
6
6
  Classifier: Programming Language :: Python :: 3
@@ -11,7 +11,6 @@ description = "Core beancount formatter logic."
11
11
  [dependencies]
12
12
  anyhow = { workspace = true }
13
13
  beancount-parser = { git = "https://github.com/trim21/beancount.git", rev = "8b4e3311258194fe3127862dd4132028e97cc01d" }
14
- ropey = '1.6.1'
15
14
  serde = { workspace = true }
16
15
  # beancount-parser = { path = "../../../beancount/beancount/" }
17
16
  # beancount-parser = { path = "../../../beancount/beancount/crates/beancount-parser/" }
@@ -12,7 +12,7 @@ description = "CLI for the beancount formatter."
12
12
  [dependencies]
13
13
  anyhow = { workspace = true }
14
14
  beancount-formatter = { workspace = true }
15
- clap = { version = "4.5.54", features = ["derive"] }
15
+ clap = { version = "4.5.55", features = ["derive"] }
16
16
  serde = { workspace = true }
17
17
  toml = "0.9.11"
18
18
 
@@ -15,4 +15,4 @@ crate-type = ["cdylib"]
15
15
  [dependencies]
16
16
  beancount-formatter = { workspace = true }
17
17
  beancount-formatter-cli = { path = "../beancount-formatter-cli/" }
18
- pyo3 = { version = "0.27.2", features = ["abi3", "abi3-py310", "extension-module"] }
18
+ pyo3 = { version = "0.27.2", features = ["abi3", "abi3-py310", "generate-import-lib"] }
@@ -0,0 +1,19 @@
1
+ [package]
2
+ name = "tree-sitter-language"
3
+ version = "0.1.6"
4
+ authors = [
5
+ "Max Brunsfeld <maxbrunsfeld@gmail.com>",
6
+ "Amaan Qureshi <amaanq12@gmail.com>",
7
+ ]
8
+ categories = ["api-bindings", "development-tools::ffi", "parsing"]
9
+ documentation = "https://docs.rs/tree-sitter-language"
10
+ edition = "2021"
11
+ readme = "README.md"
12
+ rust-version = "1.77"
13
+ description = "The tree-sitter Language type, used by the library and by language implementations"
14
+
15
+ build = "build.rs"
16
+ links = "tree-sitter-language"
17
+
18
+ [lib]
19
+ path = "src/language.rs"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Max Brunsfeld
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ # Tree-sitter Language
2
+
3
+ This crate provides a `LanguageFn` type for grammars to create `Language` instances from a parser,
4
+ without having to worry about the `tree-sitter` crate version not matching.
@@ -0,0 +1,13 @@
1
+ fn main() {
2
+ if std::env::var("TARGET")
3
+ .unwrap_or_default()
4
+ .starts_with("wasm32-unknown")
5
+ {
6
+ let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
7
+ let wasm_headers = std::path::Path::new(&manifest_dir).join("wasm/include");
8
+ let wasm_src = std::path::Path::new(&manifest_dir).join("wasm/src");
9
+
10
+ println!("cargo::metadata=wasm-headers={}", wasm_headers.display());
11
+ println!("cargo::metadata=wasm-src={}", wasm_src.display());
12
+ }
13
+ }
@@ -0,0 +1,23 @@
1
+ #![no_std]
2
+ /// `LanguageFn` wraps a C function that returns a pointer to a tree-sitter grammar.
3
+ #[repr(transparent)]
4
+ #[derive(Clone, Copy)]
5
+ pub struct LanguageFn(unsafe extern "C" fn() -> *const ());
6
+
7
+ impl LanguageFn {
8
+ /// Creates a [`LanguageFn`].
9
+ ///
10
+ /// # Safety
11
+ ///
12
+ /// Only call this with language functions generated from grammars
13
+ /// by the Tree-sitter CLI.
14
+ pub const unsafe fn from_raw(f: unsafe extern "C" fn() -> *const ()) -> Self {
15
+ Self(f)
16
+ }
17
+
18
+ /// Gets the function wrapped by this [`LanguageFn`].
19
+ #[must_use]
20
+ pub const fn into_raw(self) -> unsafe extern "C" fn() -> *const () {
21
+ self.0
22
+ }
23
+ }
@@ -0,0 +1,14 @@
1
+ #ifndef TREE_SITTER_WASM_ASSERT_H_
2
+ #define TREE_SITTER_WASM_ASSERT_H_
3
+
4
+ #ifdef NDEBUG
5
+ #define assert(e) ((void)0)
6
+ #else
7
+ __attribute__((noreturn)) void __assert_fail(const char *assertion, const char *file, unsigned line, const char *function) {
8
+ __builtin_trap();
9
+ }
10
+ #define assert(expression) \
11
+ ((expression) ? (void)0 : __assert_fail(#expression, __FILE__, __LINE__, __func__))
12
+ #endif
13
+
14
+ #endif // TREE_SITTER_WASM_ASSERT_H_
@@ -0,0 +1,8 @@
1
+ #ifndef TREE_SITTER_WASM_CTYPE_H_
2
+ #define TREE_SITTER_WASM_CTYPE_H_
3
+
4
+ static inline int isprint(int c) {
5
+ return c >= 0x20 && c <= 0x7E;
6
+ }
7
+
8
+ #endif // TREE_SITTER_WASM_CTYPE_H_
@@ -0,0 +1,12 @@
1
+ #ifndef TREE_SITTER_WASM_ENDIAN_H_
2
+ #define TREE_SITTER_WASM_ENDIAN_H_
3
+
4
+ #define be16toh(x) __builtin_bswap16(x)
5
+ #define be32toh(x) __builtin_bswap32(x)
6
+ #define be64toh(x) __builtin_bswap64(x)
7
+ #define le16toh(x) (x)
8
+ #define le32toh(x) (x)
9
+ #define le64toh(x) (x)
10
+
11
+
12
+ #endif // TREE_SITTER_WASM_ENDIAN_H_
@@ -0,0 +1,8 @@
1
+ #ifndef TREE_SITTER_WASM_INTTYPES_H_
2
+ #define TREE_SITTER_WASM_INTTYPES_H_
3
+
4
+ // https://github.com/llvm/llvm-project/blob/0c3cf200f5b918fb5c1114e9f1764c2d54d1779b/libc/include/llvm-libc-macros/inttypes-macros.h#L209
5
+
6
+ #define PRId32 "d"
7
+
8
+ #endif // TREE_SITTER_WASM_INTTYPES_H_
@@ -0,0 +1,46 @@
1
+ #ifndef TREE_SITTER_WASM_STDINT_H_
2
+ #define TREE_SITTER_WASM_STDINT_H_
3
+
4
+ // https://github.com/llvm/llvm-project/blob/0c3cf200f5b918fb5c1114e9f1764c2d54d1779b/clang/test/Preprocessor/init.c#L1672
5
+
6
+ typedef signed char int8_t;
7
+
8
+ typedef short int16_t;
9
+
10
+ typedef int int32_t;
11
+
12
+ typedef long long int int64_t;
13
+
14
+ typedef unsigned char uint8_t;
15
+
16
+ typedef unsigned short uint16_t;
17
+
18
+ typedef unsigned int uint32_t;
19
+
20
+ typedef long long unsigned int uint64_t;
21
+
22
+ typedef long unsigned int size_t;
23
+
24
+ typedef long unsigned int uintptr_t;
25
+
26
+ #define INT8_MAX 127
27
+ #define INT16_MAX 32767
28
+ #define INT32_MAX 2147483647L
29
+ #define INT64_MAX 9223372036854775807LL
30
+
31
+ #define UINT8_MAX 255
32
+ #define UINT16_MAX 65535
33
+ #define UINT32_MAX 4294967295U
34
+ #define UINT64_MAX 18446744073709551615ULL
35
+
36
+ #if defined(__wasm32__)
37
+
38
+ #define SIZE_MAX 4294967295UL
39
+
40
+ #elif defined(__wasm64__)
41
+
42
+ #define SIZE_MAX 18446744073709551615UL
43
+
44
+ #endif
45
+
46
+ #endif // TREE_SITTER_WASM_STDINT_H_
@@ -0,0 +1,36 @@
1
+ #ifndef TREE_SITTER_WASM_STDIO_H_
2
+ #define TREE_SITTER_WASM_STDIO_H_
3
+
4
+ #include <stdbool.h>
5
+ #include <stdint.h>
6
+
7
+ typedef struct FILE FILE;
8
+
9
+ typedef __builtin_va_list va_list;
10
+ #define va_start(ap, last) __builtin_va_start(ap, last)
11
+ #define va_end(ap) __builtin_va_end(ap)
12
+ #define va_arg(ap, type) __builtin_va_arg(ap, type)
13
+
14
+ #define stdout ((FILE *)0)
15
+
16
+ #define stderr ((FILE *)1)
17
+
18
+ #define stdin ((FILE *)2)
19
+
20
+ int fclose(FILE *stream);
21
+
22
+ FILE *fdopen(int fd, const char *mode);
23
+
24
+ int fputc(int c, FILE *stream);
25
+
26
+ int fputs(const char *restrict s, FILE *restrict stream);
27
+
28
+ size_t fwrite(const void *restrict buffer, size_t size, size_t nmemb, FILE *restrict stream);
29
+
30
+ int fprintf(FILE *restrict stream, const char *restrict format, ...);
31
+
32
+ int snprintf(char *restrict buffer, size_t buffsz, const char *restrict format, ...);
33
+
34
+ int vsnprintf(char *restrict buffer, size_t buffsz, const char *restrict format, va_list vlist);
35
+
36
+ #endif // TREE_SITTER_WASM_STDIO_H_
@@ -0,0 +1,15 @@
1
+ #ifndef TREE_SITTER_WASM_STDLIB_H_
2
+ #define TREE_SITTER_WASM_STDLIB_H_
3
+
4
+ #include <stdint.h>
5
+
6
+ #define NULL ((void*)0)
7
+
8
+ void* malloc(size_t);
9
+ void* calloc(size_t, size_t);
10
+ void free(void*);
11
+ void* realloc(void*, size_t);
12
+
13
+ __attribute__((noreturn)) void abort(void);
14
+
15
+ #endif // TREE_SITTER_WASM_STDLIB_H_
@@ -0,0 +1,18 @@
1
+ #ifndef TREE_SITTER_WASM_STRING_H_
2
+ #define TREE_SITTER_WASM_STRING_H_
3
+
4
+ #include <stdint.h>
5
+
6
+ int memcmp(const void *lhs, const void *rhs, size_t count);
7
+
8
+ void *memcpy(void *restrict dst, const void *restrict src, size_t size);
9
+
10
+ void *memmove(void *dst, const void *src, size_t count);
11
+
12
+ void *memset(void *dst, int value, size_t count);
13
+
14
+ int strncmp(const char *left, const char *right, size_t n);
15
+
16
+ size_t strlen(const char *str);
17
+
18
+ #endif // TREE_SITTER_WASM_STRING_H_
@@ -0,0 +1,168 @@
1
+ #ifndef TREE_SITTER_WASM_WCTYPE_H_
2
+ #define TREE_SITTER_WASM_WCTYPE_H_
3
+
4
+ typedef int wint_t;
5
+
6
+ static inline bool iswalpha(wint_t wch) {
7
+ switch (wch) {
8
+ case L'a':
9
+ case L'b':
10
+ case L'c':
11
+ case L'd':
12
+ case L'e':
13
+ case L'f':
14
+ case L'g':
15
+ case L'h':
16
+ case L'i':
17
+ case L'j':
18
+ case L'k':
19
+ case L'l':
20
+ case L'm':
21
+ case L'n':
22
+ case L'o':
23
+ case L'p':
24
+ case L'q':
25
+ case L'r':
26
+ case L's':
27
+ case L't':
28
+ case L'u':
29
+ case L'v':
30
+ case L'w':
31
+ case L'x':
32
+ case L'y':
33
+ case L'z':
34
+ case L'A':
35
+ case L'B':
36
+ case L'C':
37
+ case L'D':
38
+ case L'E':
39
+ case L'F':
40
+ case L'G':
41
+ case L'H':
42
+ case L'I':
43
+ case L'J':
44
+ case L'K':
45
+ case L'L':
46
+ case L'M':
47
+ case L'N':
48
+ case L'O':
49
+ case L'P':
50
+ case L'Q':
51
+ case L'R':
52
+ case L'S':
53
+ case L'T':
54
+ case L'U':
55
+ case L'V':
56
+ case L'W':
57
+ case L'X':
58
+ case L'Y':
59
+ case L'Z':
60
+ return true;
61
+ default:
62
+ return false;
63
+ }
64
+ }
65
+
66
+ static inline bool iswdigit(wint_t wch) {
67
+ switch (wch) {
68
+ case L'0':
69
+ case L'1':
70
+ case L'2':
71
+ case L'3':
72
+ case L'4':
73
+ case L'5':
74
+ case L'6':
75
+ case L'7':
76
+ case L'8':
77
+ case L'9':
78
+ return true;
79
+ default:
80
+ return false;
81
+ }
82
+ }
83
+
84
+ static inline bool iswalnum(wint_t wch) {
85
+ switch (wch) {
86
+ case L'a':
87
+ case L'b':
88
+ case L'c':
89
+ case L'd':
90
+ case L'e':
91
+ case L'f':
92
+ case L'g':
93
+ case L'h':
94
+ case L'i':
95
+ case L'j':
96
+ case L'k':
97
+ case L'l':
98
+ case L'm':
99
+ case L'n':
100
+ case L'o':
101
+ case L'p':
102
+ case L'q':
103
+ case L'r':
104
+ case L's':
105
+ case L't':
106
+ case L'u':
107
+ case L'v':
108
+ case L'w':
109
+ case L'x':
110
+ case L'y':
111
+ case L'z':
112
+ case L'A':
113
+ case L'B':
114
+ case L'C':
115
+ case L'D':
116
+ case L'E':
117
+ case L'F':
118
+ case L'G':
119
+ case L'H':
120
+ case L'I':
121
+ case L'J':
122
+ case L'K':
123
+ case L'L':
124
+ case L'M':
125
+ case L'N':
126
+ case L'O':
127
+ case L'P':
128
+ case L'Q':
129
+ case L'R':
130
+ case L'S':
131
+ case L'T':
132
+ case L'U':
133
+ case L'V':
134
+ case L'W':
135
+ case L'X':
136
+ case L'Y':
137
+ case L'Z':
138
+ case L'0':
139
+ case L'1':
140
+ case L'2':
141
+ case L'3':
142
+ case L'4':
143
+ case L'5':
144
+ case L'6':
145
+ case L'7':
146
+ case L'8':
147
+ case L'9':
148
+ return true;
149
+ default:
150
+ return false;
151
+ }
152
+ }
153
+
154
+ static inline bool iswspace(wint_t wch) {
155
+ switch (wch) {
156
+ case L' ':
157
+ case L'\t':
158
+ case L'\n':
159
+ case L'\v':
160
+ case L'\f':
161
+ case L'\r':
162
+ return true;
163
+ default:
164
+ return false;
165
+ }
166
+ }
167
+
168
+ #endif // TREE_SITTER_WASM_WCTYPE_H_