@pb-shrugged/tree-sitter-powerscript 0.0.1

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.
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # tree-sitter-powerscript
2
+
3
+ A [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar for powerscript.
4
+
5
+ ## Supported File Types
6
+
7
+ - `.srs` - Structure
8
+ - `.srf` - Function
9
+ - `.srw` - Window
10
+ - `.sru` - User Object
11
+ - `.sra` - Application
12
+ - `.srm` - Menu
13
+
14
+ ## Installation
15
+
16
+ ### As a npm package on your project
17
+
18
+ ```bash
19
+ npm install tree-sitter-powerscript
20
+ ```
21
+
22
+ ### Usage with Tree-sitter CLI
23
+
24
+ ```bash
25
+ # Install tree-sitter CLI
26
+ npm install -g tree-sitter-cli
27
+
28
+ # Clone this repository
29
+ git clone https://github.com/pb-shrugged/tree-sitter-powerscript.git
30
+ cd tree-sitter-powerscript
31
+
32
+ # Generate the parser
33
+ tree-sitter generate
34
+
35
+ # Test the parser
36
+ tree-sitter test
37
+
38
+ # Parse a powerscript file
39
+ tree-sitter parse path/to/your/file.sru
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ### Node.js
45
+
46
+ ```javascript
47
+ const Parser = require('tree-sitter');
48
+ const Powerscript = require('tree-sitter-powerscript');
49
+
50
+ const parser = new Parser();
51
+ parser.setLanguage(Powerscript);
52
+
53
+ const sourceCode = `
54
+ global type w_main from window
55
+ end type
56
+
57
+ on w_main.create
58
+ // Window creation code
59
+ end on
60
+ `;
61
+
62
+ const tree = parser.parse(sourceCode);
63
+ console.log(tree.rootNode.toString());
64
+ ```
65
+
66
+ ## Development
67
+
68
+ ### Prerequisites
69
+
70
+ - Node.js
71
+ - tree-sitter CLI
72
+
73
+ ### Setup
74
+
75
+ ```bash
76
+ git clone https://github.com/pb-shrugged/tree-sitter-powerscript.git
77
+ cd tree-sitter-powerscript
78
+ npm install
79
+ ```
80
+
81
+ ### Development Commands
82
+
83
+ ```bash
84
+ # Generate the grammar
85
+ npm run ts:generate
86
+
87
+ # Run tests
88
+ npm run ts:test
89
+
90
+ # Build WebAssembly
91
+ npm run ts:run
92
+
93
+ # Lint code
94
+ npm run lint
95
+
96
+ # Run all tests
97
+ npm test
98
+ ```
99
+
100
+ ## CI/CD Pipeline
101
+
102
+ This project uses GitHub Actions for continuous integration and deployment:
103
+
104
+ - [**Lint**](/.github/workflows/lint.yml): Runs lint on push and pull request
105
+ - [**CI Workflow**](/.github/workflows/ci.yml): Runs tests on every push and pull request
106
+ - [**Publish Workflow**](/.github/workflows/publish.yml): Automatically creates GitHub releases and publishes to NPM when tags are pushed
107
+
108
+ ### Automated Releases
109
+
110
+ To create a new release:
111
+
112
+ 1. Manually update the tree-sitter version with `tree-sitter version <VERSION>` then create the git tag: `git tag v<VERSION> && git push origin v<VERSION>`
113
+
114
+ The release process will automatically:
115
+ - Generate cross-platform binaries
116
+ - Create a GitHub release with assets
117
+ - Publish the package to NPM
118
+
119
+ ## Contributing
120
+
121
+ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
122
+
123
+ ### Quick Start for Contributors
124
+
125
+ 1. Fork the repository
126
+ 2. Create a feature branch: `git checkout -b feature/amazing-feature`
127
+ 3. Make your changes and add tests
128
+ 4. Run tests: `npm run ts:test` for the test/corpus files and `npm run test` for the bindings/node files
129
+ 5. Commit your changes: `git commit -m 'Add amazing feature'`
130
+ 6. Push to the branch: `git push origin feature/amazing-feature`
131
+ 7. Open a Pull Request
132
+
133
+ ## License
134
+
135
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
136
+
137
+ ## Links
138
+
139
+ - [NPM Package](https://www.npmjs.com/package/@pb-shrugged/tree-sitter-powerscript)
140
+ - [GitHub Repository](https://github.com/pb-shrugged/tree-sitter-powerscript)
141
+ - [Tree-sitter Documentation](https://tree-sitter.github.io/tree-sitter/)
142
+ - [PowerBuilder Documentation](https://docs.appeon.com/#pb)
package/binding.gyp ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "targets": [
3
+ {
4
+ "target_name": "tree_sitter_powerscript_binding",
5
+ "dependencies": [
6
+ "<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
7
+ ],
8
+ "include_dirs": [
9
+ "src",
10
+ ],
11
+ "sources": [
12
+ "bindings/node/binding.cc",
13
+ "src/parser.c",
14
+ ],
15
+ "variables": {
16
+ "has_scanner": "<!(node -p \"fs.existsSync('src/scanner.c')\")"
17
+ },
18
+ "conditions": [
19
+ ["has_scanner=='true'", {
20
+ "sources+": ["src/scanner.c"],
21
+ }],
22
+ ["OS!='win'", {
23
+ "cflags_c": [
24
+ "-std=c11",
25
+ ],
26
+ }, { # OS == "win"
27
+ "cflags_c": [
28
+ "/std:c11",
29
+ "/utf-8",
30
+ ],
31
+ }],
32
+ ],
33
+ }
34
+ ]
35
+ }
@@ -0,0 +1,19 @@
1
+ #include <napi.h>
2
+
3
+ typedef struct TSLanguage TSLanguage;
4
+
5
+ extern "C" TSLanguage *tree_sitter_powerscript();
6
+
7
+ // "tree-sitter", "language" hashed with BLAKE2
8
+ const napi_type_tag LANGUAGE_TYPE_TAG = {
9
+ 0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
10
+ };
11
+
12
+ Napi::Object Init(Napi::Env env, Napi::Object exports) {
13
+ auto language = Napi::External<TSLanguage>::New(env, tree_sitter_powerscript());
14
+ language.TypeTag(&LANGUAGE_TYPE_TAG);
15
+ exports["language"] = language;
16
+ return exports;
17
+ }
18
+
19
+ NODE_API_MODULE(tree_sitter_powerscript_binding, Init)
@@ -0,0 +1,11 @@
1
+ const assert = require("node:assert");
2
+ const { test } = require("node:test");
3
+
4
+ const Parser = require("tree-sitter");
5
+
6
+ const PowerscriptLanguage = require("./index")
7
+
8
+ test("can load grammar", () => {
9
+ const parser = new Parser();
10
+ assert.doesNotThrow(() => parser.setLanguage(PowerscriptLanguage));
11
+ });
@@ -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,11 @@
1
+ const root = require("path").join(__dirname, "..", "..");
2
+
3
+ module.exports =
4
+ typeof process.versions.bun === "string"
5
+ // Support `bun build --compile` by being statically analyzable enough to find the .node file at build-time
6
+ ? require(`../../prebuilds/${process.platform}-${process.arch}/tree-sitter-powerscript.node`)
7
+ : require("node-gyp-build")(root);
8
+
9
+ try {
10
+ module.exports.nodeTypeInfo = require("../../src/node-types.json");
11
+ } catch (_) { }