@konomanoasa/tree-sitter-posix-awk 0.20.3 → 0.21.0
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/Cargo.toml +3 -3
- package/README.md +0 -6
- package/bindings/python/__init__.py +9 -0
- package/bindings/python/binding.c +31 -0
- package/bindings/python/binding.pyi +3 -0
- package/bindings/python/py.typed +0 -0
- package/grammar.js +10 -3
- package/package.json +10 -8
- package/pyproject.toml +60 -0
- package/setup.py +28 -0
- package/src/grammar.json +124 -41
- package/src/node-types.json +1 -1
- package/src/parser.c +30105 -29949
- package/src/scanner.c +257 -33
- package/test/bindings.test.rs +11 -1403
- package/tree-sitter.json +2 -2
package/Cargo.toml
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "konomanoasa-tree-sitter-posix-awk"
|
|
3
|
-
version = "0.
|
|
4
|
-
edition = "2024"
|
|
3
|
+
version = "0.21.0"
|
|
5
4
|
description = "Tree-sitter grammar for POSIX awk."
|
|
6
5
|
readme = "README.md"
|
|
7
|
-
repository = "https://github.com/konomanoasa/tree-sitter-posix-awk"
|
|
8
6
|
license = "MIT"
|
|
7
|
+
repository = "https://github.com/konomanoasa/tree-sitter-posix-awk"
|
|
8
|
+
edition = "2024"
|
|
9
9
|
build = "bindings/rust/build.rs"
|
|
10
10
|
links = "tree-sitter-posix-awk"
|
|
11
11
|
include = [
|
package/README.md
CHANGED
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
[Tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar for
|
|
8
8
|
POSIX.1-2024 AWK.
|
|
9
9
|
|
|
10
|
-
For GNU awk, see [tree-sitter-awk](https://github.com/konomanoasa/tree-sitter-awk).
|
|
11
|
-
|
|
12
10
|
## Installation
|
|
13
11
|
|
|
14
12
|
```sh
|
|
@@ -28,10 +26,6 @@ npm test
|
|
|
28
26
|
- [POSIX.1-2024 AWK](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/awk.html)
|
|
29
27
|
- [POSIX.1-2024 extended regular expressions](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/basedefs/V1_chap09.html#tag_09_04)
|
|
30
28
|
|
|
31
|
-
## Used By
|
|
32
|
-
|
|
33
|
-
[awk-ts-mode](https://github.com/konomanoasa/awk-ts-mode)
|
|
34
|
-
|
|
35
29
|
## License
|
|
36
30
|
|
|
37
31
|
[MIT](LICENSE)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#include <Python.h>
|
|
2
|
+
|
|
3
|
+
#include "tree_sitter/parser.h"
|
|
4
|
+
|
|
5
|
+
const TSLanguage *tree_sitter_posix_awk(void);
|
|
6
|
+
|
|
7
|
+
static PyObject *language(PyObject *self, PyObject *args) {
|
|
8
|
+
(void)self;
|
|
9
|
+
(void)args;
|
|
10
|
+
return PyCapsule_New(
|
|
11
|
+
(void *)tree_sitter_posix_awk(),
|
|
12
|
+
"tree_sitter.Language",
|
|
13
|
+
NULL
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static PyMethodDef methods[] = {
|
|
18
|
+
{"language", language, METH_NOARGS, "Return the posix_awk language capsule."},
|
|
19
|
+
{NULL, NULL, 0, NULL},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
static struct PyModuleDef module = {
|
|
23
|
+
PyModuleDef_HEAD_INIT,
|
|
24
|
+
.m_name = "binding",
|
|
25
|
+
.m_size = -1,
|
|
26
|
+
.m_methods = methods,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
PyMODINIT_FUNC PyInit_binding(void) {
|
|
30
|
+
return PyModule_Create(&module);
|
|
31
|
+
}
|
|
File without changes
|
package/grammar.js
CHANGED
|
@@ -20,6 +20,7 @@ export const EXPRESSION = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export const FILE_SOURCE_TIER = "additive";
|
|
23
|
+
export const INPUT_PIPE_PRECEDENCE = 13;
|
|
23
24
|
|
|
24
25
|
export const RESERVED_WORDS = {
|
|
25
26
|
keyword: [
|
|
@@ -183,9 +184,12 @@ const ereExpressionRules = (insideGroup) => {
|
|
|
183
184
|
insideGroup ? alias($[name(rule)], $[rule]) : $[rule];
|
|
184
185
|
return {
|
|
185
186
|
[name("extended_reg_exp")]: ($) =>
|
|
186
|
-
|
|
187
|
+
choice(
|
|
187
188
|
member($, "ere_branch"),
|
|
188
|
-
|
|
189
|
+
seq(
|
|
190
|
+
optional(member($, "ere_branch")),
|
|
191
|
+
repeat1(seq(token.immediate("|"), optional(member($, "ere_branch")))),
|
|
192
|
+
),
|
|
189
193
|
),
|
|
190
194
|
|
|
191
195
|
[name("ere_branch")]: ($) => repeat1(member($, "ere_expression")),
|
|
@@ -217,6 +221,7 @@ const ereExpressionRules = (insideGroup) => {
|
|
|
217
221
|
? []
|
|
218
222
|
: [alias(token.immediate(")"), $.ordinary_character)]),
|
|
219
223
|
alias(token.immediate("}"), $.ordinary_character),
|
|
224
|
+
alias($._ere_literal_brace, $.ordinary_character),
|
|
220
225
|
$.ordinary_character,
|
|
221
226
|
$.quoted_character,
|
|
222
227
|
token.immediate("."),
|
|
@@ -783,6 +788,8 @@ const definition = {
|
|
|
783
788
|
$._continuation_newline,
|
|
784
789
|
$._literal_break,
|
|
785
790
|
$._stray_backslash,
|
|
791
|
+
$._ere_interval_opening,
|
|
792
|
+
$._ere_literal_brace,
|
|
786
793
|
$._error_sentinel,
|
|
787
794
|
],
|
|
788
795
|
|
|
@@ -1073,7 +1080,7 @@ const definition = {
|
|
|
1073
1080
|
|
|
1074
1081
|
_ere_interval: ($) =>
|
|
1075
1082
|
seq(
|
|
1076
|
-
|
|
1083
|
+
alias($._ere_interval_opening, "{"),
|
|
1077
1084
|
field("minimum", $.duplication_count),
|
|
1078
1085
|
optional(
|
|
1079
1086
|
seq(
|
package/package.json
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konomanoasa/tree-sitter-posix-awk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.21.0",
|
|
5
4
|
"description": "Tree-sitter grammar for POSIX awk.",
|
|
6
5
|
"license": "MIT",
|
|
7
6
|
"repository": "git+https://github.com/konomanoasa/tree-sitter-posix-awk.git",
|
|
7
|
+
"type": "module",
|
|
8
8
|
"files": [
|
|
9
9
|
"Cargo.toml",
|
|
10
|
+
"bindings/python/*.c",
|
|
11
|
+
"bindings/python/*.py",
|
|
12
|
+
"bindings/python/*.pyi",
|
|
13
|
+
"bindings/python/py.typed",
|
|
10
14
|
"bindings/rust/*.rs",
|
|
11
15
|
"grammar.js",
|
|
16
|
+
"pyproject.toml",
|
|
12
17
|
"queries/*.scm",
|
|
18
|
+
"setup.py",
|
|
13
19
|
"src/*.c",
|
|
14
20
|
"src/*.json",
|
|
15
21
|
"src/tree_sitter/*.h",
|
|
@@ -25,14 +31,10 @@
|
|
|
25
31
|
"check:queries": "npm run tree-sitter -- check-queries",
|
|
26
32
|
"format": "biome format --write .",
|
|
27
33
|
"generate": "npm run tree-sitter -- generate-all",
|
|
28
|
-
"test": "npm run tree-sitter -- test-corpus --rebuild && node --test --test-concurrency=1 test/build.test.js test/cst.test.js test/highlight.test.js test/incremental.test.js test/parser.test.js",
|
|
29
|
-
"test:fuzz": "
|
|
30
|
-
"test:fuzz:corpus": "npm run tree-sitter -- fuzz-all --iterations 100 --edits 5",
|
|
31
|
-
"test:highlights": "node --test test/highlight.test.js",
|
|
32
|
-
"test:incremental": "node --test --test-concurrency=1 test/cst.test.js test/parser.test.js test/incremental.test.js",
|
|
34
|
+
"test": "npm run tree-sitter -- test-corpus --rebuild && node --test --test-concurrency=1 test/build.test.js test/cst.test.js test/highlight.test.js test/incremental.test.js test/parser.test.js && node scripts/check-c.js --test",
|
|
35
|
+
"test:fuzz": "npm run tree-sitter -- fuzz-all --iterations 100 --edits 5",
|
|
33
36
|
"test:performance": "node --test test/performance.test.js",
|
|
34
37
|
"test:sanitize": "node scripts/check-c.js --sanitize",
|
|
35
|
-
"test:scanner": "node scripts/check-c.js",
|
|
36
38
|
"tree-sitter": "node scripts/tree-sitter.js"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
package/pyproject.toml
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "konomanoasa-tree-sitter-posix-awk"
|
|
3
|
+
version = "0.21.0"
|
|
4
|
+
description = "Tree-sitter grammar for POSIX awk."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
|
|
9
|
+
[project.urls]
|
|
10
|
+
Repository = "https://github.com/konomanoasa/tree-sitter-posix-awk"
|
|
11
|
+
|
|
12
|
+
[dependency-groups]
|
|
13
|
+
dev = [
|
|
14
|
+
"poethepoet==0.49.0",
|
|
15
|
+
"ruff==0.17.3",
|
|
16
|
+
"setuptools==84.2.1",
|
|
17
|
+
"tree-sitter==0.26.0",
|
|
18
|
+
"twine==7.0.0",
|
|
19
|
+
"ty==0.0.95",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = ["setuptools==84.2.1"]
|
|
24
|
+
build-backend = "setuptools.build_meta"
|
|
25
|
+
|
|
26
|
+
[tool.setuptools]
|
|
27
|
+
include-package-data = false
|
|
28
|
+
packages = ["tree_sitter_posix_awk", "tree_sitter_posix_awk.queries"]
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.package-dir]
|
|
31
|
+
tree_sitter_posix_awk = "bindings/python"
|
|
32
|
+
"tree_sitter_posix_awk.queries" = "queries"
|
|
33
|
+
|
|
34
|
+
[tool.setuptools.package-data]
|
|
35
|
+
tree_sitter_posix_awk = ["*.pyi", "py.typed"]
|
|
36
|
+
"tree_sitter_posix_awk.queries" = ["*.scm"]
|
|
37
|
+
|
|
38
|
+
[tool.poe]
|
|
39
|
+
executor.type = "simple"
|
|
40
|
+
|
|
41
|
+
[tool.poe.tasks]
|
|
42
|
+
build = "uv build --no-sources"
|
|
43
|
+
check = [
|
|
44
|
+
{ cmd = "ruff check setup.py bindings/python test/bindings.test.py" },
|
|
45
|
+
{ cmd = "ty check setup.py bindings/python test/bindings.test.py" },
|
|
46
|
+
{ cmd = "ruff format --check setup.py bindings/python test/bindings.test.py" },
|
|
47
|
+
]
|
|
48
|
+
format = "ruff format setup.py bindings/python test/bindings.test.py"
|
|
49
|
+
test = "python test/bindings.test.py"
|
|
50
|
+
|
|
51
|
+
[tool.ruff]
|
|
52
|
+
indent-width = 4
|
|
53
|
+
line-length = 80
|
|
54
|
+
|
|
55
|
+
[tool.ruff.format]
|
|
56
|
+
indent-style = "space"
|
|
57
|
+
skip-magic-trailing-comma = true
|
|
58
|
+
|
|
59
|
+
[tool.ruff.lint.isort]
|
|
60
|
+
split-on-trailing-comma = false
|
package/setup.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from setuptools import Extension, setup
|
|
5
|
+
|
|
6
|
+
Path("dist/metadata").mkdir(parents=True, exist_ok=True)
|
|
7
|
+
|
|
8
|
+
setup(
|
|
9
|
+
options={
|
|
10
|
+
"build": {"build_base": "dist/build"},
|
|
11
|
+
"egg_info": {"egg_base": "dist/metadata"},
|
|
12
|
+
},
|
|
13
|
+
ext_modules=[
|
|
14
|
+
Extension(
|
|
15
|
+
"tree_sitter_posix_awk.binding",
|
|
16
|
+
sources=[
|
|
17
|
+
"bindings/python/binding.c",
|
|
18
|
+
"src/parser.c",
|
|
19
|
+
"src/scanner.c",
|
|
20
|
+
],
|
|
21
|
+
include_dirs=["src"],
|
|
22
|
+
depends=["src/tree_sitter/alloc.h", "src/tree_sitter/parser.h"],
|
|
23
|
+
extra_compile_args=["/std:c17", "/utf-8"]
|
|
24
|
+
if sys.platform == "win32"
|
|
25
|
+
else ["-std=c17"],
|
|
26
|
+
)
|
|
27
|
+
],
|
|
28
|
+
)
|
package/src/grammar.json
CHANGED
|
@@ -1790,30 +1790,55 @@
|
|
|
1790
1790
|
]
|
|
1791
1791
|
},
|
|
1792
1792
|
"extended_reg_exp": {
|
|
1793
|
-
"type": "
|
|
1793
|
+
"type": "CHOICE",
|
|
1794
1794
|
"members": [
|
|
1795
1795
|
{
|
|
1796
1796
|
"type": "SYMBOL",
|
|
1797
1797
|
"name": "ere_branch"
|
|
1798
1798
|
},
|
|
1799
1799
|
{
|
|
1800
|
-
"type": "
|
|
1801
|
-
"
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
"
|
|
1808
|
-
|
|
1800
|
+
"type": "SEQ",
|
|
1801
|
+
"members": [
|
|
1802
|
+
{
|
|
1803
|
+
"type": "CHOICE",
|
|
1804
|
+
"members": [
|
|
1805
|
+
{
|
|
1806
|
+
"type": "SYMBOL",
|
|
1807
|
+
"name": "ere_branch"
|
|
1808
|
+
},
|
|
1809
|
+
{
|
|
1810
|
+
"type": "BLANK"
|
|
1809
1811
|
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1812
|
+
]
|
|
1813
|
+
},
|
|
1814
|
+
{
|
|
1815
|
+
"type": "REPEAT1",
|
|
1816
|
+
"content": {
|
|
1817
|
+
"type": "SEQ",
|
|
1818
|
+
"members": [
|
|
1819
|
+
{
|
|
1820
|
+
"type": "IMMEDIATE_TOKEN",
|
|
1821
|
+
"content": {
|
|
1822
|
+
"type": "STRING",
|
|
1823
|
+
"value": "|"
|
|
1824
|
+
}
|
|
1825
|
+
},
|
|
1826
|
+
{
|
|
1827
|
+
"type": "CHOICE",
|
|
1828
|
+
"members": [
|
|
1829
|
+
{
|
|
1830
|
+
"type": "SYMBOL",
|
|
1831
|
+
"name": "ere_branch"
|
|
1832
|
+
},
|
|
1833
|
+
{
|
|
1834
|
+
"type": "BLANK"
|
|
1835
|
+
}
|
|
1836
|
+
]
|
|
1837
|
+
}
|
|
1838
|
+
]
|
|
1814
1839
|
}
|
|
1815
|
-
|
|
1816
|
-
|
|
1840
|
+
}
|
|
1841
|
+
]
|
|
1817
1842
|
}
|
|
1818
1843
|
]
|
|
1819
1844
|
},
|
|
@@ -1940,6 +1965,15 @@
|
|
|
1940
1965
|
"named": true,
|
|
1941
1966
|
"value": "ordinary_character"
|
|
1942
1967
|
},
|
|
1968
|
+
{
|
|
1969
|
+
"type": "ALIAS",
|
|
1970
|
+
"content": {
|
|
1971
|
+
"type": "SYMBOL",
|
|
1972
|
+
"name": "_ere_literal_brace"
|
|
1973
|
+
},
|
|
1974
|
+
"named": true,
|
|
1975
|
+
"value": "ordinary_character"
|
|
1976
|
+
},
|
|
1943
1977
|
{
|
|
1944
1978
|
"type": "SYMBOL",
|
|
1945
1979
|
"name": "ordinary_character"
|
|
@@ -1980,7 +2014,7 @@
|
|
|
1980
2014
|
]
|
|
1981
2015
|
},
|
|
1982
2016
|
"group_extended_reg_exp": {
|
|
1983
|
-
"type": "
|
|
2017
|
+
"type": "CHOICE",
|
|
1984
2018
|
"members": [
|
|
1985
2019
|
{
|
|
1986
2020
|
"type": "ALIAS",
|
|
@@ -1992,28 +2026,58 @@
|
|
|
1992
2026
|
"value": "ere_branch"
|
|
1993
2027
|
},
|
|
1994
2028
|
{
|
|
1995
|
-
"type": "
|
|
1996
|
-
"
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
"
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
"content": {
|
|
2009
|
-
"type": "SYMBOL",
|
|
2010
|
-
"name": "group_ere_branch"
|
|
2029
|
+
"type": "SEQ",
|
|
2030
|
+
"members": [
|
|
2031
|
+
{
|
|
2032
|
+
"type": "CHOICE",
|
|
2033
|
+
"members": [
|
|
2034
|
+
{
|
|
2035
|
+
"type": "ALIAS",
|
|
2036
|
+
"content": {
|
|
2037
|
+
"type": "SYMBOL",
|
|
2038
|
+
"name": "group_ere_branch"
|
|
2039
|
+
},
|
|
2040
|
+
"named": true,
|
|
2041
|
+
"value": "ere_branch"
|
|
2011
2042
|
},
|
|
2012
|
-
|
|
2013
|
-
|
|
2043
|
+
{
|
|
2044
|
+
"type": "BLANK"
|
|
2045
|
+
}
|
|
2046
|
+
]
|
|
2047
|
+
},
|
|
2048
|
+
{
|
|
2049
|
+
"type": "REPEAT1",
|
|
2050
|
+
"content": {
|
|
2051
|
+
"type": "SEQ",
|
|
2052
|
+
"members": [
|
|
2053
|
+
{
|
|
2054
|
+
"type": "IMMEDIATE_TOKEN",
|
|
2055
|
+
"content": {
|
|
2056
|
+
"type": "STRING",
|
|
2057
|
+
"value": "|"
|
|
2058
|
+
}
|
|
2059
|
+
},
|
|
2060
|
+
{
|
|
2061
|
+
"type": "CHOICE",
|
|
2062
|
+
"members": [
|
|
2063
|
+
{
|
|
2064
|
+
"type": "ALIAS",
|
|
2065
|
+
"content": {
|
|
2066
|
+
"type": "SYMBOL",
|
|
2067
|
+
"name": "group_ere_branch"
|
|
2068
|
+
},
|
|
2069
|
+
"named": true,
|
|
2070
|
+
"value": "ere_branch"
|
|
2071
|
+
},
|
|
2072
|
+
{
|
|
2073
|
+
"type": "BLANK"
|
|
2074
|
+
}
|
|
2075
|
+
]
|
|
2076
|
+
}
|
|
2077
|
+
]
|
|
2014
2078
|
}
|
|
2015
|
-
|
|
2016
|
-
|
|
2079
|
+
}
|
|
2080
|
+
]
|
|
2017
2081
|
}
|
|
2018
2082
|
]
|
|
2019
2083
|
},
|
|
@@ -2138,6 +2202,15 @@
|
|
|
2138
2202
|
"named": true,
|
|
2139
2203
|
"value": "ordinary_character"
|
|
2140
2204
|
},
|
|
2205
|
+
{
|
|
2206
|
+
"type": "ALIAS",
|
|
2207
|
+
"content": {
|
|
2208
|
+
"type": "SYMBOL",
|
|
2209
|
+
"name": "_ere_literal_brace"
|
|
2210
|
+
},
|
|
2211
|
+
"named": true,
|
|
2212
|
+
"value": "ordinary_character"
|
|
2213
|
+
},
|
|
2141
2214
|
{
|
|
2142
2215
|
"type": "SYMBOL",
|
|
2143
2216
|
"name": "ordinary_character"
|
|
@@ -2270,11 +2343,13 @@
|
|
|
2270
2343
|
"type": "SEQ",
|
|
2271
2344
|
"members": [
|
|
2272
2345
|
{
|
|
2273
|
-
"type": "
|
|
2346
|
+
"type": "ALIAS",
|
|
2274
2347
|
"content": {
|
|
2275
|
-
"type": "
|
|
2276
|
-
"
|
|
2277
|
-
}
|
|
2348
|
+
"type": "SYMBOL",
|
|
2349
|
+
"name": "_ere_interval_opening"
|
|
2350
|
+
},
|
|
2351
|
+
"named": false,
|
|
2352
|
+
"value": "{"
|
|
2278
2353
|
},
|
|
2279
2354
|
{
|
|
2280
2355
|
"type": "FIELD",
|
|
@@ -10797,6 +10872,14 @@
|
|
|
10797
10872
|
"type": "SYMBOL",
|
|
10798
10873
|
"name": "_stray_backslash"
|
|
10799
10874
|
},
|
|
10875
|
+
{
|
|
10876
|
+
"type": "SYMBOL",
|
|
10877
|
+
"name": "_ere_interval_opening"
|
|
10878
|
+
},
|
|
10879
|
+
{
|
|
10880
|
+
"type": "SYMBOL",
|
|
10881
|
+
"name": "_ere_literal_brace"
|
|
10882
|
+
},
|
|
10800
10883
|
{
|
|
10801
10884
|
"type": "SYMBOL",
|
|
10802
10885
|
"name": "_error_sentinel"
|