WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit ecbd15e

Browse files
authored
Merge pull request #23 from alaviss/for-0.0.3
Improvements staged for 0.0.3 Notable changes: * Flattened several constructs * Smaller parser, and is now brought back into the repository * Added a highlighting query Short log: grammar: redefine proc expression as extension of type grammar: remove modified_type grammar: inline symbol_declaration_list to tuple grammar: split blank_identifier from identifier bring back the parser bump dependencies and version to 0.0.3 grammar: unify operators as (operator) queries: add highlighting query
2 parents dd09bda + bdd375d commit ecbd15e

File tree

18 files changed

+1154287
-1444
lines changed

18 files changed

+1154287
-1444
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,6 @@ name: CI
77
on: [push, pull_request]
88

99
jobs:
10-
# uptodate:
11-
# name: Node test build
12-
# runs-on: ubuntu-latest
13-
# steps:
14-
# - uses: actions/checkout@v3
15-
# - uses: actions/setup-node@v3
16-
# with:
17-
# node-version: "16"
18-
# cache: "npm"
19-
# - run: npm install
20-
# - run: npm run build
21-
# - name: Check for differences between commit and built file
22-
# run: |
23-
# if ! git diff --exit-code; then
24-
# echo '::error::There are differences between commit and code built. Make sure that `npm run build` is run before commiting. Check log for more details.'
25-
# git diff
26-
# exit 1
27-
# fi
28-
# shell: bash
29-
3010
generate:
3111
name: Generate parser
3212
runs-on: macos-latest
@@ -38,14 +18,15 @@ jobs:
3818
node-version: "16"
3919
- run: npm install
4020
- run: npm run build
41-
- uses: actions/upload-artifact@v3
42-
with:
43-
name: parser
44-
path: src/parser.c
21+
- name: Check for differences between commit and built file
22+
run: |
23+
if ! git diff --exit-code; then
24+
echo '::error::There are differences between commit and code built. Make sure that `npm run build` is run before commiting. Check log for more details.'
25+
git diff
26+
exit 1
27+
fi
4528
4629
tests:
47-
needs:
48-
- generate
4930
strategy:
5031
matrix:
5132
os: [ubuntu-latest, macos-latest, windows-latest]
@@ -58,10 +39,6 @@ jobs:
5839
node-version: "16"
5940
cache: "npm"
6041
- run: npm install
61-
- uses: actions/download-artifact@v3
62-
with:
63-
name: parser
64-
path: src
6542
- name: Run test suite
6643
run: |
6744
if [[ "$RUNNER_OS" == macOS ]]; then
@@ -77,19 +54,13 @@ jobs:
7754
shell: bash
7855

7956
rust:
80-
needs:
81-
- generate
8257
strategy:
8358
matrix:
8459
os: [ubuntu-latest, macos-latest, windows-latest]
8560
runs-on: ${{ matrix.os }}
8661
name: Run rust test build on ${{ matrix.os }}
8762
steps:
8863
- uses: actions/checkout@v3
89-
- uses: actions/download-artifact@v3
90-
with:
91-
name: parser
92-
path: src
9364
- name: Install Rust toolchain
9465
uses: actions-rs/toolchain@v1
9566
with:
@@ -101,7 +72,7 @@ jobs:
10172

10273
success:
10374
needs:
104-
# - uptodate
75+
- generate
10576
- tests
10677
- rust
10778
if: always()

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ target/
1111

1212
# C stuff
1313
.cache/
14-
src/parser.c

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[package]
66
name = "tree-sitter-nim"
77
description = "nim grammar for the tree-sitter parsing library"
8-
version = "0.0.2"
8+
version = "0.0.3"
99
keywords = ["incremental", "parsing", "nim"]
1010
categories = ["parsing", "text-editors"]
1111
repository = "https://github.com/tree-sitter/tree-sitter-nim"

binding.gyp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-FileCopyrightText: None
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
{
6+
"targets": [
7+
{
8+
"target_name": "tree_sitter_nim_binding",
9+
"include_dirs": [
10+
"<!(node -e \"require('nan')\")",
11+
"src"
12+
],
13+
"sources": [
14+
"bindings/node/binding.cc",
15+
"src/parser.c",
16+
"src/scanner.cc"
17+
],
18+
"cflags_c": [
19+
"-std=c99",
20+
]
21+
}
22+
]
23+
}

corpus/declarations.txt

Lines changed: 35 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ const Test* {.importc: "TEST".}: int
5858
(variable_declaration
5959
(symbol_declaration_list
6060
(tuple_deconstruct_declaration
61-
(symbol_declaration_list
62-
(symbol_declaration
63-
name: (identifier))
64-
(symbol_declaration
65-
name: (identifier)))))
61+
(symbol_declaration
62+
name: (identifier))
63+
(symbol_declaration
64+
name: (identifier))))
6665
value: (tuple_construction
6766
(integer_literal)
6867
(integer_literal))))
@@ -75,13 +74,12 @@ const Test* {.importc: "TEST".}: int
7574
(variable_declaration
7675
(symbol_declaration_list
7776
(tuple_deconstruct_declaration
78-
(symbol_declaration_list
79-
(symbol_declaration
80-
name: (identifier))
81-
(symbol_declaration
82-
name: (identifier))
83-
(symbol_declaration
84-
name: (identifier)))))
77+
(symbol_declaration
78+
name: (identifier))
79+
(symbol_declaration
80+
name: (identifier))
81+
(symbol_declaration
82+
name: (identifier))))
8583
value: (tuple_construction
8684
(integer_literal)
8785
(integer_literal)
@@ -90,12 +88,11 @@ const Test* {.importc: "TEST".}: int
9088
(variable_declaration
9189
(symbol_declaration_list
9290
(tuple_deconstruct_declaration
93-
(symbol_declaration_list
94-
(symbol_declaration
95-
name: (identifier))
96-
(symbol_declaration
97-
name: (exported_symbol
98-
(identifier))))))
91+
(symbol_declaration
92+
name: (identifier))
93+
(symbol_declaration
94+
name: (exported_symbol
95+
(identifier)))))
9996
value: (tuple_construction
10097
(integer_literal)
10198
(integer_literal))))
@@ -171,11 +168,10 @@ l_e_t
171168
(variable_declaration
172169
(symbol_declaration_list
173170
(tuple_deconstruct_declaration
174-
(symbol_declaration_list
175-
(symbol_declaration
176-
name: (identifier))
177-
(symbol_declaration
178-
name: (identifier)))))
171+
(symbol_declaration
172+
name: (identifier))
173+
(symbol_declaration
174+
name: (identifier))))
179175
value: (tuple_construction
180176
(integer_literal)
181177
(integer_literal)))))
@@ -245,21 +241,19 @@ var (x, ) = (1, )
245241
(variable_declaration
246242
(symbol_declaration_list
247243
(tuple_deconstruct_declaration
248-
(symbol_declaration_list
249-
(symbol_declaration
250-
name: (identifier))
251-
(symbol_declaration
252-
name: (identifier)))))
244+
(symbol_declaration
245+
name: (identifier))
246+
(symbol_declaration
247+
name: (identifier))))
253248
value: (tuple_construction
254249
(integer_literal)
255250
(integer_literal))))
256251
(var_section
257252
(variable_declaration
258253
(symbol_declaration_list
259254
(tuple_deconstruct_declaration
260-
(symbol_declaration_list
261-
(symbol_declaration
262-
name: (identifier)))))
255+
(symbol_declaration
256+
name: (identifier))))
263257
value: (tuple_construction
264258
(integer_literal)))))
265259

@@ -284,8 +278,7 @@ type
284278
(type_declaration
285279
(type_symbol_declaration
286280
name: (identifier))
287-
(modified_type
288-
modifier: (distinct_type)
281+
(distinct_type
289282
(identifier)))
290283
(type_declaration
291284
(type_symbol_declaration
@@ -295,8 +288,7 @@ type
295288
(symbol_declaration_list
296289
(symbol_declaration
297290
name: (identifier))))))
298-
(modified_type
299-
modifier: (ref_type)
291+
(ref_type
300292
(identifier)))))
301293

302294
================================================================================
@@ -400,7 +392,7 @@ type
400392
values: (expression_list
401393
(infix_expression
402394
left: (identifier)
403-
operator: (infix_operator)
395+
operator: (operator)
404396
right: (identifier)))
405397
(field_declaration_list
406398
(field_declaration
@@ -412,7 +404,7 @@ type
412404
values: (expression_list
413405
(infix_expression
414406
left: (identifier)
415-
operator: (infix_operator)
407+
operator: (operator)
416408
right: (identifier)))
417409
(field_declaration_list
418410
(field_declaration
@@ -424,7 +416,7 @@ type
424416
values: (expression_list
425417
(infix_expression
426418
left: (identifier)
427-
operator: (infix_operator)
419+
operator: (operator)
428420
right: (identifier))
429421
(identifier)
430422
(identifier)
@@ -471,8 +463,7 @@ type
471463
(type_declaration
472464
(type_symbol_declaration
473465
name: (identifier))
474-
(modified_type
475-
modifier: (ref_type)
466+
(ref_type
476467
(object_declaration
477468
(field_declaration_list
478469
(field_declaration
@@ -504,8 +495,7 @@ type
504495
(colon_expression
505496
left: (identifier)
506497
right: (string_literal))))
507-
(modified_type
508-
modifier: (ref_type)
498+
(ref_type
509499
(object_declaration
510500
inherits: (identifier)
511501
(field_declaration_list
@@ -538,8 +528,7 @@ type
538528
(type_declaration
539529
(type_symbol_declaration
540530
name: (identifier))
541-
(modified_type
542-
modifier: (ref_type)
531+
(ref_type
543532
(object_declaration)))
544533
(type_declaration
545534
(type_symbol_declaration
@@ -667,7 +656,7 @@ type
667656
(infix_expression
668657
left: (infix_expression
669658
left: (identifier)
670-
operator: (infix_operator)
659+
operator: (operator)
671660
right: (identifier))
672661
right: (identifier))
673662
(infix_expression
@@ -817,7 +806,7 @@ proc foo =
817806
body: (statement_list
818807
(infix_expression
819808
left: (identifier)
820-
operator: (infix_operator)
809+
operator: (operator)
821810
right: (identifier))))
822811
(macro_declaration
823812
name: (identifier)

0 commit comments

Comments
 (0)