tree-sitter-abl 0.0.47

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.
@@ -0,0 +1,43 @@
1
+ name: Test
2
+ on:
3
+ - push
4
+ - pull_request
5
+ jobs:
6
+ main:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - name: Checkout
11
+ uses: actions/checkout@v3
12
+
13
+ - name: Install Node.js
14
+ uses: actions/setup-node@v3
15
+ with:
16
+ node-version: 16
17
+
18
+ - uses: pnpm/action-setup@v2
19
+ name: Install pnpm
20
+ id: pnpm-install
21
+ with:
22
+ version: 7
23
+ run_install: false
24
+
25
+ - name: Get pnpm store directory
26
+ id: pnpm-cache
27
+ shell: bash
28
+ run: |
29
+ echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
30
+
31
+ - uses: actions/cache@v3
32
+ name: Setup pnpm cache
33
+ with:
34
+ path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
35
+ key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
36
+ restore-keys: |
37
+ ${{ runner.os }}-pnpm-store-
38
+
39
+ - name: Install dependencies
40
+ run: pnpm install
41
+
42
+ - name: Run tests
43
+ run: npm run test
package/.prettierrc ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "trailingComma": "none",
3
+ "printWidth": 80,
4
+ "tabWidth": 2,
5
+ "semi": true,
6
+ "singleQuote": false
7
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "AblFormatter.variableAssignmentFormatting": true
3
+ }
package/Cargo.lock ADDED
@@ -0,0 +1,59 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 3
4
+
5
+ [[package]]
6
+ name = "aho-corasick"
7
+ version = "1.0.1"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04"
10
+ dependencies = [
11
+ "memchr",
12
+ ]
13
+
14
+ [[package]]
15
+ name = "cc"
16
+ version = "1.0.79"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
19
+
20
+ [[package]]
21
+ name = "memchr"
22
+ version = "2.5.0"
23
+ source = "registry+https://github.com/rust-lang/crates.io-index"
24
+ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
25
+
26
+ [[package]]
27
+ name = "regex"
28
+ version = "1.8.1"
29
+ source = "registry+https://github.com/rust-lang/crates.io-index"
30
+ checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370"
31
+ dependencies = [
32
+ "aho-corasick",
33
+ "memchr",
34
+ "regex-syntax",
35
+ ]
36
+
37
+ [[package]]
38
+ name = "regex-syntax"
39
+ version = "0.7.1"
40
+ source = "registry+https://github.com/rust-lang/crates.io-index"
41
+ checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c"
42
+
43
+ [[package]]
44
+ name = "tree-sitter"
45
+ version = "0.20.10"
46
+ source = "registry+https://github.com/rust-lang/crates.io-index"
47
+ checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d"
48
+ dependencies = [
49
+ "cc",
50
+ "regex",
51
+ ]
52
+
53
+ [[package]]
54
+ name = "tree-sitter-abl"
55
+ version = "0.0.1"
56
+ dependencies = [
57
+ "cc",
58
+ "tree-sitter",
59
+ ]
package/Cargo.toml ADDED
@@ -0,0 +1,26 @@
1
+ [package]
2
+ name = "tree-sitter-abl"
3
+ description = "abl grammar for the tree-sitter parsing library"
4
+ version = "0.0.1"
5
+ keywords = ["incremental", "parsing", "abl"]
6
+ categories = ["parsing", "text-editors"]
7
+ repository = "https://github.com/tree-sitter/tree-sitter-abl"
8
+ edition = "2018"
9
+ license = "MIT"
10
+
11
+ build = "bindings/rust/build.rs"
12
+ include = [
13
+ "bindings/rust/*",
14
+ "grammar.js",
15
+ "queries/*",
16
+ "src/*",
17
+ ]
18
+
19
+ [lib]
20
+ path = "bindings/rust/lib.rs"
21
+
22
+ [dependencies]
23
+ tree-sitter = "~0.20.10"
24
+
25
+ [build-dependencies]
26
+ cc = "1.0"
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Kamil Jakubus, Jason Chrosrova and contributors
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.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # tree-sitter-abl
2
+
3
+ OpenEdge Advanced Business Language (ABL) grammar for tree-sitter.
4
+
5
+ To see syntax tree output see `test/corpus`.
6
+
7
+ Check out [tree-sitter-df](https://github.com/usagi-coffee/tree-sitter-df) for progress data definitions parser.
8
+
9
+ ## Usage
10
+
11
+ > Keep in mind there are many ABL statements that are not yet implemented but that doesn't ***necessarily*** mean they're not parsable, it just means the syntax tree won't have details about the statements!
12
+
13
+ For the grammar usage in your project look at tree-sitter documentation on how to use the grammar parsers because you can use tree-sitter parsers using [node](https://github.com/tree-sitter/node-tree-sitter)/[rust](https://github.com/tree-sitter/tree-sitter/tree/master/lib/binding_rust)/[wasm](https://github.com/tree-sitter/tree-sitter/tree/master/lib/binding_web) bindings.
14
+
15
+ ### Node
16
+
17
+ ```bash
18
+ npm install @usagi-coffee/tree-sitter-abl
19
+ ```
20
+
21
+ ### WASM
22
+
23
+ Prebuilt WASM binary can be found in NPM package or build yourself with `npm run build:wasm`.
24
+ Follow [web-tree-sitter](https://github.com/tree-sitter/tree-sitter/tree/master/lib/binding_web) binding documentation.
25
+
26
+ ```
27
+ // Getting wasm binary from the npm package
28
+ const fs = require('node:fs');
29
+ const mod = fs.readFileSync('node_modules/@usagi-coffee/tree-sitter-abl/tree-sitter-abl.wasm');
30
+ ```
31
+
32
+ ### Shared library (.so)
33
+
34
+ You can build a shared library `.so` to use it in tools like [ast-grep](https://ast-grep.github.io/)
35
+
36
+ ```bash
37
+ gcc -shared -fPIC -fno-exceptions -g -I 'src' -o abl.so -O2 src/scanner.c -xc src/parser.c -lstdc++
38
+ ```
39
+
40
+ ### Running the tests
41
+
42
+ ```bash
43
+ npm run test
44
+ ```
45
+
46
+ ### Testing your file
47
+
48
+ ```bash
49
+ npm run parse your_file.p
50
+ ```
51
+
52
+ ## License
53
+
54
+ ```LICENSE
55
+ MIT License
56
+
57
+ Copyright (c) Kamil Jakubus, Jason Chrosrova and contributors
58
+
59
+ Permission is hereby granted, free of charge, to any person obtaining a copy
60
+ of this software and associated documentation files (the "Software"), to deal
61
+ in the Software without restriction, including without limitation the rights
62
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
63
+ copies of the Software, and to permit persons to whom the Software is
64
+ furnished to do so, subject to the following conditions:
65
+
66
+ The above copyright notice and this permission notice shall be included in all
67
+ copies or substantial portions of the Software.
68
+
69
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
70
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
71
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
72
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
73
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
74
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
75
+ SOFTWARE.
76
+ ```
package/binding.gyp ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "targets": [
3
+ {
4
+ "target_name": "tree_sitter_abl_binding",
5
+ "include_dirs": [
6
+ "<!(node -e \"require('nan')\")",
7
+ "src"
8
+ ],
9
+ "sources": [
10
+ "bindings/node/binding.cc",
11
+ "src/parser.c",
12
+ "src/scanner.c",
13
+ ],
14
+ "cflags_c": [
15
+ "-std=c99",
16
+ ]
17
+ }
18
+ ]
19
+ }
@@ -0,0 +1,28 @@
1
+ #include "tree_sitter/parser.h"
2
+ #include <node.h>
3
+ #include "nan.h"
4
+
5
+ using namespace v8;
6
+
7
+ extern "C" TSLanguage * tree_sitter_abl();
8
+
9
+ namespace {
10
+
11
+ NAN_METHOD(New) {}
12
+
13
+ void Init(Local<Object> exports, Local<Object> module) {
14
+ Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
15
+ tpl->SetClassName(Nan::New("Language").ToLocalChecked());
16
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
17
+
18
+ Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
19
+ Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
20
+ Nan::SetInternalFieldPointer(instance, 0, tree_sitter_abl());
21
+
22
+ Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("abl").ToLocalChecked());
23
+ Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
24
+ }
25
+
26
+ NODE_MODULE(tree_sitter_abl_binding, Init)
27
+
28
+ } // namespace
@@ -0,0 +1,9 @@
1
+ const assert = require("node:assert");
2
+ const { test } = require("node:test");
3
+
4
+ const Parser = require("tree-sitter");
5
+
6
+ test("can load grammar", () => {
7
+ const parser = new Parser();
8
+ assert.doesNotThrow(() => parser.setLanguage(require(".")));
9
+ });
@@ -0,0 +1,28 @@
1
+ type BaseNode = {
2
+ type: string;
3
+ named: boolean;
4
+ };
5
+
6
+ type ChildNode = {
7
+ multiple: boolean;
8
+ required: boolean;
9
+ types: BaseNode[];
10
+ };
11
+
12
+ type NodeInfo =
13
+ | (BaseNode & {
14
+ subtypes: BaseNode[];
15
+ })
16
+ | (BaseNode & {
17
+ fields: { [name: string]: ChildNode };
18
+ children: ChildNode[];
19
+ });
20
+
21
+ type Language = {
22
+ name: string;
23
+ language: unknown;
24
+ nodeTypeInfo: NodeInfo[];
25
+ };
26
+
27
+ declare const language: Language;
28
+ export = language;
@@ -0,0 +1,19 @@
1
+ try {
2
+ module.exports = require("../../build/Release/tree_sitter_abl_binding");
3
+ } catch (error1) {
4
+ if (error1.code !== 'MODULE_NOT_FOUND') {
5
+ throw error1;
6
+ }
7
+ try {
8
+ module.exports = require("../../build/Debug/tree_sitter_abl_binding");
9
+ } catch (error2) {
10
+ if (error2.code !== 'MODULE_NOT_FOUND') {
11
+ throw error2;
12
+ }
13
+ throw error1
14
+ }
15
+ }
16
+
17
+ try {
18
+ module.exports.nodeTypeInfo = require("../../src/node-types.json");
19
+ } catch (_) {}
@@ -0,0 +1,40 @@
1
+ fn main() {
2
+ let src_dir = std::path::Path::new("src");
3
+
4
+ let mut c_config = cc::Build::new();
5
+ c_config.include(&src_dir);
6
+ c_config
7
+ .flag_if_supported("-Wno-unused-parameter")
8
+ .flag_if_supported("-Wno-unused-but-set-variable")
9
+ .flag_if_supported("-Wno-trigraphs");
10
+ let parser_path = src_dir.join("parser.c");
11
+ c_config.file(&parser_path);
12
+
13
+ // If your language uses an external scanner written in C,
14
+ // then include this block of code:
15
+
16
+ /*
17
+ let scanner_path = src_dir.join("scanner.c");
18
+ c_config.file(&scanner_path);
19
+ println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
20
+ */
21
+
22
+ c_config.compile("parser");
23
+ 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
+ /*
29
+ let mut cpp_config = cc::Build::new();
30
+ cpp_config.cpp(true);
31
+ cpp_config.include(&src_dir);
32
+ cpp_config
33
+ .flag_if_supported("-Wno-unused-parameter")
34
+ .flag_if_supported("-Wno-unused-but-set-variable");
35
+ let scanner_path = src_dir.join("scanner.cc");
36
+ cpp_config.file(&scanner_path);
37
+ cpp_config.compile("scanner");
38
+ println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
39
+ */
40
+ }
@@ -0,0 +1,52 @@
1
+ //! This crate provides abl language support for the [tree-sitter][] parsing library.
2
+ //!
3
+ //! Typically, you will use the [language][language func] function to add this language to a
4
+ //! tree-sitter [Parser][], and then use the parser to parse some code:
5
+ //!
6
+ //! ```
7
+ //! let code = "";
8
+ //! let mut parser = tree_sitter::Parser::new();
9
+ //! parser.set_language(tree_sitter_abl::language()).expect("Error loading abl grammar");
10
+ //! let tree = parser.parse(code, None).unwrap();
11
+ //! ```
12
+ //!
13
+ //! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
14
+ //! [language func]: fn.language.html
15
+ //! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
16
+ //! [tree-sitter]: https://tree-sitter.github.io/
17
+
18
+ use tree_sitter::Language;
19
+
20
+ extern "C" {
21
+ fn tree_sitter_abl() -> Language;
22
+ }
23
+
24
+ /// Get the tree-sitter [Language][] for this grammar.
25
+ ///
26
+ /// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
27
+ pub fn language() -> Language {
28
+ unsafe { tree_sitter_abl() }
29
+ }
30
+
31
+ /// The content of the [`node-types.json`][] file for this grammar.
32
+ ///
33
+ /// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
34
+ pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
35
+
36
+ // Uncomment these to include any queries that this grammar contains
37
+
38
+ // pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
39
+ // pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
40
+ // pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
41
+ // pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
42
+
43
+ #[cfg(test)]
44
+ mod tests {
45
+ #[test]
46
+ fn test_can_load_grammar() {
47
+ let mut parser = tree_sitter::Parser::new();
48
+ parser
49
+ .set_language(super::language())
50
+ .expect("Error loading abl language");
51
+ }
52
+ }
package/example1.cls ADDED
@@ -0,0 +1,11 @@
1
+ CLASS TestFormatting:
2
+
3
+ define TEMP-TABLE ttFormatting NO-UNDO
4
+ FIELD uid AS INT64
5
+ FIELD textInfo AS CHARACTER
6
+ FIELD NotifyPropertyChanged AS LOGICAL
7
+ FIELD NotifyOnSourceUpdate AS Progress.Lang.Object
8
+ INDEX idx1 IS PRIMARY UNIQUE uid
9
+ INDEX idx2 textInfo NotifyOnSourceUpdate NotifyPropertyChanged.
10
+
11
+ END CLASS.