@konomanoasa/tree-sitter-awk 0.2.0 → 0.4.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/CMakeLists.txt +90 -0
- package/Makefile +131 -0
- package/bindings/c/tree-sitter-awk.pc.in +10 -0
- package/bindings/c/tree_sitter/tree-sitter-awk.h +16 -0
- package/grammar.js +17 -27
- package/package.json +9 -5
- package/src/grammar.json +19 -7
- package/src/parser.c +13546 -13622
- package/src/scanner.c +32 -46
- package/test/binding.test.c +6 -0
- package/tree-sitter.json +2 -2
package/CMakeLists.txt
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.13)
|
|
2
|
+
|
|
3
|
+
project(
|
|
4
|
+
tree-sitter-awk
|
|
5
|
+
VERSION 0.4.0
|
|
6
|
+
DESCRIPTION "Tree-sitter grammar for POSIX awk."
|
|
7
|
+
HOMEPAGE_URL "https://github.com/konomanoasa/tree-sitter-awk"
|
|
8
|
+
LANGUAGES C
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
|
|
12
|
+
option(TREE_SITTER_REUSE_ALLOCATOR "Reuse the Tree-sitter allocator" OFF)
|
|
13
|
+
|
|
14
|
+
file(
|
|
15
|
+
STRINGS src/parser.c
|
|
16
|
+
TREE_SITTER_ABI_DEFINITION
|
|
17
|
+
REGEX "^#define LANGUAGE_VERSION [0-9]+$"
|
|
18
|
+
)
|
|
19
|
+
if(NOT TREE_SITTER_ABI_DEFINITION MATCHES "^#define LANGUAGE_VERSION [0-9]+$")
|
|
20
|
+
message(FATAL_ERROR "The parser must define one LANGUAGE_VERSION")
|
|
21
|
+
endif()
|
|
22
|
+
string(
|
|
23
|
+
REGEX REPLACE "^#define LANGUAGE_VERSION " ""
|
|
24
|
+
TREE_SITTER_ABI_VERSION
|
|
25
|
+
"${TREE_SITTER_ABI_DEFINITION}"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
include(GNUInstallDirs)
|
|
29
|
+
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
|
30
|
+
include(CTest)
|
|
31
|
+
endif()
|
|
32
|
+
|
|
33
|
+
add_library(tree-sitter-awk src/parser.c src/scanner.c)
|
|
34
|
+
target_include_directories(
|
|
35
|
+
tree-sitter-awk
|
|
36
|
+
INTERFACE
|
|
37
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/bindings/c>
|
|
38
|
+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
39
|
+
)
|
|
40
|
+
target_compile_definitions(
|
|
41
|
+
tree-sitter-awk
|
|
42
|
+
PRIVATE
|
|
43
|
+
$<$<BOOL:${TREE_SITTER_REUSE_ALLOCATOR}>:TREE_SITTER_REUSE_ALLOCATOR>
|
|
44
|
+
$<$<CONFIG:Debug>:TREE_SITTER_DEBUG>
|
|
45
|
+
)
|
|
46
|
+
set_target_properties(
|
|
47
|
+
tree-sitter-awk
|
|
48
|
+
PROPERTIES
|
|
49
|
+
C_STANDARD 11
|
|
50
|
+
C_STANDARD_REQUIRED ON
|
|
51
|
+
DEFINE_SYMBOL ""
|
|
52
|
+
POSITION_INDEPENDENT_CODE ON
|
|
53
|
+
SOVERSION "${TREE_SITTER_ABI_VERSION}.${PROJECT_VERSION_MAJOR}"
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
if(BUILD_TESTING AND CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
|
57
|
+
add_executable(tree-sitter-awk-binding-test test/binding.test.c)
|
|
58
|
+
target_link_libraries(tree-sitter-awk-binding-test PRIVATE tree-sitter-awk)
|
|
59
|
+
add_test(
|
|
60
|
+
NAME tree-sitter-awk-binding
|
|
61
|
+
COMMAND tree-sitter-awk-binding-test
|
|
62
|
+
)
|
|
63
|
+
endif()
|
|
64
|
+
|
|
65
|
+
configure_file(
|
|
66
|
+
bindings/c/tree-sitter-awk.pc.in
|
|
67
|
+
"${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-awk.pc"
|
|
68
|
+
@ONLY
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
install(
|
|
72
|
+
TARGETS tree-sitter-awk
|
|
73
|
+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
74
|
+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
75
|
+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
76
|
+
)
|
|
77
|
+
install(
|
|
78
|
+
DIRECTORY bindings/c/tree_sitter
|
|
79
|
+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
80
|
+
FILES_MATCHING PATTERN "*.h"
|
|
81
|
+
)
|
|
82
|
+
install(
|
|
83
|
+
FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-awk.pc"
|
|
84
|
+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
|
85
|
+
)
|
|
86
|
+
install(
|
|
87
|
+
DIRECTORY queries/
|
|
88
|
+
DESTINATION "${CMAKE_INSTALL_DATADIR}/tree-sitter/queries/awk"
|
|
89
|
+
FILES_MATCHING PATTERN "*.scm"
|
|
90
|
+
)
|
package/Makefile
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
LANGUAGE_NAME := tree-sitter-awk
|
|
2
|
+
HOMEPAGE_URL := https://github.com/konomanoasa/tree-sitter-awk
|
|
3
|
+
VERSION := 0.4.0
|
|
4
|
+
DESCRIPTION := Tree-sitter grammar for POSIX awk.
|
|
5
|
+
|
|
6
|
+
PREFIX ?= /usr/local
|
|
7
|
+
DATADIR ?= $(PREFIX)/share
|
|
8
|
+
INCLUDEDIR ?= $(PREFIX)/include
|
|
9
|
+
LIBDIR ?= $(PREFIX)/lib
|
|
10
|
+
BINDIR ?= $(PREFIX)/bin
|
|
11
|
+
PCLIBDIR ?= $(LIBDIR)/pkgconfig
|
|
12
|
+
|
|
13
|
+
SOURCES := src/parser.c src/scanner.c
|
|
14
|
+
OBJECTS := $(SOURCES:.c=.o)
|
|
15
|
+
MAKE_BUILD_DIR := build/make
|
|
16
|
+
STATIC_LIBRARY := lib$(LANGUAGE_NAME).a
|
|
17
|
+
PKG_CONFIG := $(LANGUAGE_NAME).pc
|
|
18
|
+
TEST := $(MAKE_BUILD_DIR)/binding.test
|
|
19
|
+
|
|
20
|
+
ARFLAGS := rcs
|
|
21
|
+
override CFLAGS += -std=c11 -fPIC
|
|
22
|
+
|
|
23
|
+
SONAME_MAJOR := $(shell sed -n 's/\#define LANGUAGE_VERSION //p' src/parser.c)
|
|
24
|
+
SONAME_MINOR := $(word 1,$(subst ., ,$(VERSION)))
|
|
25
|
+
|
|
26
|
+
ifeq ($(SONAME_MAJOR),)
|
|
27
|
+
$(error The parser must define LANGUAGE_VERSION)
|
|
28
|
+
endif
|
|
29
|
+
|
|
30
|
+
MACHINE := $(shell $(CC) -dumpmachine)
|
|
31
|
+
|
|
32
|
+
ifneq ($(findstring darwin,$(MACHINE)),)
|
|
33
|
+
SOEXT := dylib
|
|
34
|
+
SOEXTVER_MAJOR := $(SONAME_MAJOR).$(SOEXT)
|
|
35
|
+
SOEXTVER := $(SONAME_MAJOR).$(SONAME_MINOR).$(SOEXT)
|
|
36
|
+
LINKSHARED := -dynamiclib -Wl,-install_name,$(LIBDIR)/lib$(LANGUAGE_NAME).$(SOEXTVER)
|
|
37
|
+
else ifneq ($(findstring mingw32,$(MACHINE)),)
|
|
38
|
+
SOEXT := dll
|
|
39
|
+
LINKSHARED := -s -shared -Wl,--out-implib,lib$(LANGUAGE_NAME).dll.a
|
|
40
|
+
TEST := $(MAKE_BUILD_DIR)/binding.test.exe
|
|
41
|
+
else
|
|
42
|
+
SOEXT := so
|
|
43
|
+
SOEXTVER_MAJOR := $(SOEXT).$(SONAME_MAJOR)
|
|
44
|
+
SOEXTVER := $(SOEXT).$(SONAME_MAJOR).$(SONAME_MINOR)
|
|
45
|
+
LINKSHARED := -shared -Wl,-soname,lib$(LANGUAGE_NAME).$(SOEXTVER)
|
|
46
|
+
ifneq ($(filter $(shell uname),FreeBSD NetBSD DragonFly),)
|
|
47
|
+
PCLIBDIR := $(PREFIX)/libdata/pkgconfig
|
|
48
|
+
endif
|
|
49
|
+
endif
|
|
50
|
+
|
|
51
|
+
SHARED_LIBRARY := lib$(LANGUAGE_NAME).$(SOEXT)
|
|
52
|
+
|
|
53
|
+
all: $(STATIC_LIBRARY) $(SHARED_LIBRARY) $(PKG_CONFIG)
|
|
54
|
+
|
|
55
|
+
$(STATIC_LIBRARY): $(OBJECTS)
|
|
56
|
+
$(AR) $(ARFLAGS) $@ $^
|
|
57
|
+
|
|
58
|
+
$(SHARED_LIBRARY): $(OBJECTS)
|
|
59
|
+
$(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@
|
|
60
|
+
ifneq ($(STRIP),)
|
|
61
|
+
$(STRIP) $@
|
|
62
|
+
endif
|
|
63
|
+
|
|
64
|
+
$(PKG_CONFIG): bindings/c/$(LANGUAGE_NAME).pc.in FORCE
|
|
65
|
+
sed -e 's|@PROJECT_VERSION@|$(VERSION)|' \
|
|
66
|
+
-e 's|@CMAKE_INSTALL_LIBDIR@|$(LIBDIR:$(PREFIX)/%=%)|' \
|
|
67
|
+
-e 's|@CMAKE_INSTALL_INCLUDEDIR@|$(INCLUDEDIR:$(PREFIX)/%=%)|' \
|
|
68
|
+
-e 's|@PROJECT_DESCRIPTION@|$(DESCRIPTION)|' \
|
|
69
|
+
-e 's|@PROJECT_HOMEPAGE_URL@|$(HOMEPAGE_URL)|' \
|
|
70
|
+
-e 's|@CMAKE_INSTALL_PREFIX@|$(PREFIX)|' $< > $@
|
|
71
|
+
|
|
72
|
+
src/parser.o: src/tree_sitter/parser.h
|
|
73
|
+
src/scanner.o: src/tree_sitter/alloc.h src/tree_sitter/parser.h
|
|
74
|
+
|
|
75
|
+
$(MAKE_BUILD_DIR):
|
|
76
|
+
mkdir -p $@
|
|
77
|
+
|
|
78
|
+
$(TEST): test/binding.test.c $(STATIC_LIBRARY) | $(MAKE_BUILD_DIR)
|
|
79
|
+
$(CC) $(CPPFLAGS) $(CFLAGS) -Ibindings/c $< $(STATIC_LIBRARY) $(LDFLAGS) $(LDLIBS) -o $@
|
|
80
|
+
|
|
81
|
+
test: $(TEST)
|
|
82
|
+
./$(TEST)
|
|
83
|
+
|
|
84
|
+
install: all
|
|
85
|
+
install -d '$(DESTDIR)$(DATADIR)'/tree-sitter/queries/awk \
|
|
86
|
+
'$(DESTDIR)$(INCLUDEDIR)'/tree_sitter \
|
|
87
|
+
'$(DESTDIR)$(PCLIBDIR)' \
|
|
88
|
+
'$(DESTDIR)$(LIBDIR)'
|
|
89
|
+
install -m644 bindings/c/tree_sitter/$(LANGUAGE_NAME).h \
|
|
90
|
+
'$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h
|
|
91
|
+
install -m644 $(PKG_CONFIG) '$(DESTDIR)$(PCLIBDIR)'/$(PKG_CONFIG)
|
|
92
|
+
install -m644 $(STATIC_LIBRARY) '$(DESTDIR)$(LIBDIR)'/$(STATIC_LIBRARY)
|
|
93
|
+
ifneq ($(findstring mingw32,$(MACHINE)),)
|
|
94
|
+
install -d '$(DESTDIR)$(BINDIR)'
|
|
95
|
+
install -m755 $(SHARED_LIBRARY) '$(DESTDIR)$(BINDIR)'/$(SHARED_LIBRARY)
|
|
96
|
+
install -m644 lib$(LANGUAGE_NAME).dll.a \
|
|
97
|
+
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).dll.a
|
|
98
|
+
else
|
|
99
|
+
install -m755 $(SHARED_LIBRARY) \
|
|
100
|
+
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER)
|
|
101
|
+
cd '$(DESTDIR)$(LIBDIR)' && \
|
|
102
|
+
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER) \
|
|
103
|
+
lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR)
|
|
104
|
+
cd '$(DESTDIR)$(LIBDIR)' && \
|
|
105
|
+
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) $(SHARED_LIBRARY)
|
|
106
|
+
endif
|
|
107
|
+
install -m644 queries/*.scm \
|
|
108
|
+
'$(DESTDIR)$(DATADIR)'/tree-sitter/queries/awk
|
|
109
|
+
|
|
110
|
+
uninstall:
|
|
111
|
+
$(RM) '$(DESTDIR)$(LIBDIR)'/$(STATIC_LIBRARY) \
|
|
112
|
+
'$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h \
|
|
113
|
+
'$(DESTDIR)$(PCLIBDIR)'/$(PKG_CONFIG)
|
|
114
|
+
ifneq ($(findstring mingw32,$(MACHINE)),)
|
|
115
|
+
$(RM) '$(DESTDIR)$(BINDIR)'/$(SHARED_LIBRARY) \
|
|
116
|
+
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).dll.a
|
|
117
|
+
else
|
|
118
|
+
$(RM) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER) \
|
|
119
|
+
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) \
|
|
120
|
+
'$(DESTDIR)$(LIBDIR)'/$(SHARED_LIBRARY)
|
|
121
|
+
endif
|
|
122
|
+
$(RM) -r '$(DESTDIR)$(DATADIR)'/tree-sitter/queries/awk
|
|
123
|
+
|
|
124
|
+
clean:
|
|
125
|
+
$(RM) $(OBJECTS) $(STATIC_LIBRARY) $(SHARED_LIBRARY) \
|
|
126
|
+
lib$(LANGUAGE_NAME).dll.a $(PKG_CONFIG)
|
|
127
|
+
$(RM) -r $(MAKE_BUILD_DIR)
|
|
128
|
+
|
|
129
|
+
FORCE:
|
|
130
|
+
|
|
131
|
+
.PHONY: all clean FORCE install test uninstall
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
prefix=@CMAKE_INSTALL_PREFIX@
|
|
2
|
+
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
|
3
|
+
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
|
4
|
+
|
|
5
|
+
Name: tree-sitter-awk
|
|
6
|
+
Description: @PROJECT_DESCRIPTION@
|
|
7
|
+
URL: @PROJECT_HOMEPAGE_URL@
|
|
8
|
+
Version: @PROJECT_VERSION@
|
|
9
|
+
Libs: -L${libdir} -ltree-sitter-awk
|
|
10
|
+
Cflags: -I${includedir}
|
package/grammar.js
CHANGED
|
@@ -30,9 +30,6 @@ const optionalNewlineLayout = ($) =>
|
|
|
30
30
|
optional(seq($.newline_opt, repeat($.line_continuation))),
|
|
31
31
|
);
|
|
32
32
|
|
|
33
|
-
// A statement owns only the line continuations interior to its own trailing
|
|
34
|
-
// newline_opt. Continuations after that gap belong to the surrounding list,
|
|
35
|
-
// action, or item, keeping every continuation a single owner.
|
|
36
33
|
const statementEndLayout = ($) =>
|
|
37
34
|
optional(seq(repeat($.line_continuation), $.newline_opt));
|
|
38
35
|
|
|
@@ -232,10 +229,7 @@ const actionBoundaryBody = ($) =>
|
|
|
232
229
|
actionBody(
|
|
233
230
|
$,
|
|
234
231
|
alias(
|
|
235
|
-
statementListWithTail(
|
|
236
|
-
$,
|
|
237
|
-
alias($._action_body_boundary_control, $.unterminated_statement),
|
|
238
|
-
),
|
|
232
|
+
statementListWithTail($, actionBoundaryControlBody($)),
|
|
239
233
|
$.unterminated_statement_list,
|
|
240
234
|
),
|
|
241
235
|
);
|
|
@@ -286,9 +280,6 @@ const aliasedAnyTier = ($, context, tier) =>
|
|
|
286
280
|
const expressionTargetGuard = ($, context) =>
|
|
287
281
|
context.input ? $._expression_target_guard : $._print_expression_target_guard;
|
|
288
282
|
|
|
289
|
-
const continuedPresentTierExpression = ($, context, name, tier) =>
|
|
290
|
-
continuedExpression($, name, aliasedAnyTier($, context, tier));
|
|
291
|
-
|
|
292
283
|
const nonUnaryAtom = ($, context) => {
|
|
293
284
|
const atoms = [
|
|
294
285
|
$._parenthesized_expression,
|
|
@@ -306,15 +297,6 @@ const nonUnaryAtom = ($, context) => {
|
|
|
306
297
|
return choice(...atoms);
|
|
307
298
|
};
|
|
308
299
|
|
|
309
|
-
const prefixUpdateExpression = ($) =>
|
|
310
|
-
prec.right(
|
|
311
|
-
PRECEDENCE.prefixUpdate,
|
|
312
|
-
seq(
|
|
313
|
-
field("operator", choice($.incr, $.decr)),
|
|
314
|
-
continuedExpression($, "operand", $.lvalue),
|
|
315
|
-
),
|
|
316
|
-
);
|
|
317
|
-
|
|
318
300
|
const tieredExpressionRules = (context) => {
|
|
319
301
|
const rules = {};
|
|
320
302
|
const unary = (tier) => classTierName(context, "unary", tier);
|
|
@@ -370,6 +352,7 @@ const tieredExpressionRules = (context) => {
|
|
|
370
352
|
};
|
|
371
353
|
|
|
372
354
|
const addLeftAssociativeTier = (tier, nextTier, operator, precedence) => {
|
|
355
|
+
addAnyTier(nextTier);
|
|
373
356
|
const tail = `_${context.prefix}_${tier}_tail`;
|
|
374
357
|
rules[tail] = ($) => seq(operator($), requiredTier($, "right", nextTier));
|
|
375
358
|
for (const classification of ["unary", "non_unary"]) {
|
|
@@ -461,7 +444,7 @@ const tieredExpressionRules = (context) => {
|
|
|
461
444
|
requiredAfterOptionalNewline(
|
|
462
445
|
$,
|
|
463
446
|
expressionTargetGuard($, context),
|
|
464
|
-
|
|
447
|
+
continuedExpression($, "right", aliasedAnyTier($, context, nextTier)),
|
|
465
448
|
requiredTier($, "right", nextTier),
|
|
466
449
|
),
|
|
467
450
|
);
|
|
@@ -574,7 +557,6 @@ const tieredExpressionRules = (context) => {
|
|
|
574
557
|
);
|
|
575
558
|
}
|
|
576
559
|
|
|
577
|
-
addAnyTier("multiplicative");
|
|
578
560
|
addLeftAssociativeTier(
|
|
579
561
|
"additive",
|
|
580
562
|
"multiplicative",
|
|
@@ -582,7 +564,6 @@ const tieredExpressionRules = (context) => {
|
|
|
582
564
|
PRECEDENCE.additive,
|
|
583
565
|
);
|
|
584
566
|
|
|
585
|
-
addAnyTier("unary");
|
|
586
567
|
addLeftAssociativeTier(
|
|
587
568
|
"multiplicative",
|
|
588
569
|
"unary",
|
|
@@ -1231,7 +1212,14 @@ module.exports = grammar({
|
|
|
1231
1212
|
|
|
1232
1213
|
non_unary_expr: ($) => $._normal_non_unary_assignment_expr,
|
|
1233
1214
|
|
|
1234
|
-
_prefix_update_expr: ($) =>
|
|
1215
|
+
_prefix_update_expr: ($) =>
|
|
1216
|
+
prec.right(
|
|
1217
|
+
PRECEDENCE.prefixUpdate,
|
|
1218
|
+
seq(
|
|
1219
|
+
field("operator", choice($.incr, $.decr)),
|
|
1220
|
+
continuedExpression($, "operand", $.lvalue),
|
|
1221
|
+
),
|
|
1222
|
+
),
|
|
1235
1223
|
|
|
1236
1224
|
...normalExpressionRules,
|
|
1237
1225
|
|
|
@@ -1677,6 +1665,8 @@ module.exports = grammar({
|
|
|
1677
1665
|
|
|
1678
1666
|
// Tree-sitter rejects the POSIX bracket spelling for these delimiter
|
|
1679
1667
|
// characters, so the exclusion sets use its hexadecimal regex escape.
|
|
1668
|
+
// The comment extra competes in ERE lexical states, so every ERE token
|
|
1669
|
+
// whose set contains "#" carries a lexical precedence above the comment.
|
|
1680
1670
|
_ordinary_character: () =>
|
|
1681
1671
|
token.immediate(prec(1, /[^.\x5B\x5C*^$+?{|}()/\n]/)),
|
|
1682
1672
|
|
|
@@ -1700,19 +1690,19 @@ module.exports = grammar({
|
|
|
1700
1690
|
_ere_bracket_close_character: () => token.immediate(prec(1, "]")),
|
|
1701
1691
|
|
|
1702
1692
|
_ere_compound_nonmeta_character: () =>
|
|
1703
|
-
token.immediate(/[^\x2D\x2F\x5C\x5D\x5E\n]/),
|
|
1693
|
+
token.immediate(prec(1, /[^\x2D\x2F\x5C\x5D\x5E\n]/)),
|
|
1704
1694
|
|
|
1705
1695
|
_ere_compound_meta_character: () => token.immediate(/[\x2D\x5D\x5E]/),
|
|
1706
1696
|
|
|
1707
1697
|
_ere_class_name_spelling: () => token.immediate(/[A-Za-z][A-Za-z0-9]*/),
|
|
1708
1698
|
|
|
1709
|
-
_ere_named_escape_character: () => token.immediate(/[abfnrtv]/),
|
|
1699
|
+
_ere_named_escape_character: () => token.immediate(prec(2, /[abfnrtv]/)),
|
|
1710
1700
|
|
|
1711
1701
|
_ere_quoted_escape_character: () =>
|
|
1712
|
-
token.immediate(/[().*+?{}|^$\x5B\x5C\x5D]/),
|
|
1702
|
+
token.immediate(prec(2, /[().*+?{}|^$\x5B\x5C\x5D]/)),
|
|
1713
1703
|
|
|
1714
1704
|
_ere_undefined_escape_character: () =>
|
|
1715
|
-
token.immediate(prec(
|
|
1705
|
+
token.immediate(prec(1, /[^0-7\x2F\x5C\n]/)),
|
|
1716
1706
|
|
|
1717
1707
|
newline_opt: ($) => rawNewlines($),
|
|
1718
1708
|
|
package/package.json
CHANGED
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konomanoasa/tree-sitter-awk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Tree-sitter grammar for POSIX awk.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "git+https://github.com/konomanoasa/tree-sitter-awk.git",
|
|
7
7
|
"files": [
|
|
8
|
+
"bindings/c",
|
|
9
|
+
"CMakeLists.txt",
|
|
8
10
|
"grammar.js",
|
|
11
|
+
"Makefile",
|
|
9
12
|
"queries/*.scm",
|
|
10
13
|
"src/*.c",
|
|
11
14
|
"src/*.json",
|
|
12
15
|
"src/tree_sitter/*.h",
|
|
16
|
+
"test/binding.test.c",
|
|
13
17
|
"tree-sitter.json"
|
|
14
18
|
],
|
|
15
19
|
"publishConfig": {
|
|
16
20
|
"access": "public"
|
|
17
21
|
},
|
|
18
22
|
"scripts": {
|
|
19
|
-
"check": "biome check . && node scripts/check-
|
|
20
|
-
"format": "biome check --write . && node scripts/check-
|
|
23
|
+
"check": "biome check . && node scripts/check-c.js && node scripts/check-generated.js && npm test",
|
|
24
|
+
"format": "biome check --write . && node scripts/check-c.js --write",
|
|
21
25
|
"generate": "npm run tree-sitter -- generate",
|
|
22
26
|
"test": "npm run tree-sitter -- test --rebuild && node --test",
|
|
23
27
|
"test:fuzz": "npm run tree-sitter -- fuzz --rebuild --iterations 100 --edits 5",
|
|
24
28
|
"tree-sitter": "node scripts/tree-sitter.js"
|
|
25
29
|
},
|
|
26
30
|
"devDependencies": {
|
|
27
|
-
"@biomejs/biome": "2.5.
|
|
28
|
-
"tree-sitter-cli": "0.26.
|
|
31
|
+
"@biomejs/biome": "2.5.11",
|
|
32
|
+
"tree-sitter-cli": "0.26.13"
|
|
29
33
|
},
|
|
30
34
|
"allowScripts": {
|
|
31
35
|
"tree-sitter-cli": true
|
package/src/grammar.json
CHANGED
|
@@ -10122,8 +10122,12 @@
|
|
|
10122
10122
|
"_ere_compound_nonmeta_character": {
|
|
10123
10123
|
"type": "IMMEDIATE_TOKEN",
|
|
10124
10124
|
"content": {
|
|
10125
|
-
"type": "
|
|
10126
|
-
"value":
|
|
10125
|
+
"type": "PREC",
|
|
10126
|
+
"value": 1,
|
|
10127
|
+
"content": {
|
|
10128
|
+
"type": "PATTERN",
|
|
10129
|
+
"value": "[^\\x2D\\x2F\\x5C\\x5D\\x5E\\n]"
|
|
10130
|
+
}
|
|
10127
10131
|
}
|
|
10128
10132
|
},
|
|
10129
10133
|
"_ere_compound_meta_character": {
|
|
@@ -10143,22 +10147,30 @@
|
|
|
10143
10147
|
"_ere_named_escape_character": {
|
|
10144
10148
|
"type": "IMMEDIATE_TOKEN",
|
|
10145
10149
|
"content": {
|
|
10146
|
-
"type": "
|
|
10147
|
-
"value":
|
|
10150
|
+
"type": "PREC",
|
|
10151
|
+
"value": 2,
|
|
10152
|
+
"content": {
|
|
10153
|
+
"type": "PATTERN",
|
|
10154
|
+
"value": "[abfnrtv]"
|
|
10155
|
+
}
|
|
10148
10156
|
}
|
|
10149
10157
|
},
|
|
10150
10158
|
"_ere_quoted_escape_character": {
|
|
10151
10159
|
"type": "IMMEDIATE_TOKEN",
|
|
10152
10160
|
"content": {
|
|
10153
|
-
"type": "
|
|
10154
|
-
"value":
|
|
10161
|
+
"type": "PREC",
|
|
10162
|
+
"value": 2,
|
|
10163
|
+
"content": {
|
|
10164
|
+
"type": "PATTERN",
|
|
10165
|
+
"value": "[().*+?{}|^$\\x5B\\x5C\\x5D]"
|
|
10166
|
+
}
|
|
10155
10167
|
}
|
|
10156
10168
|
},
|
|
10157
10169
|
"_ere_undefined_escape_character": {
|
|
10158
10170
|
"type": "IMMEDIATE_TOKEN",
|
|
10159
10171
|
"content": {
|
|
10160
10172
|
"type": "PREC",
|
|
10161
|
-
"value":
|
|
10173
|
+
"value": 1,
|
|
10162
10174
|
"content": {
|
|
10163
10175
|
"type": "PATTERN",
|
|
10164
10176
|
"value": "[^0-7\\x2F\\x5C\\n]"
|