Skip to content

Commit

Permalink
Merge pull request #23 from alaviss/for-0.0.3
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alaviss authored May 28, 2023
2 parents dd09bda + bdd375d commit ecbd15e
Show file tree
Hide file tree
Showing 18 changed files with 1,154,287 additions and 1,444 deletions.
45 changes: 8 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,6 @@ name: CI
on: [push, pull_request]

jobs:
# uptodate:
# name: Node test build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: "16"
# cache: "npm"
# - run: npm install
# - run: npm run build
# - name: Check for differences between commit and built file
# run: |
# if ! git diff --exit-code; then
# 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.'
# git diff
# exit 1
# fi
# shell: bash

generate:
name: Generate parser
runs-on: macos-latest
Expand All @@ -38,14 +18,15 @@ jobs:
node-version: "16"
- run: npm install
- run: npm run build
- uses: actions/upload-artifact@v3
with:
name: parser
path: src/parser.c
- name: Check for differences between commit and built file
run: |
if ! git diff --exit-code; then
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.'
git diff
exit 1
fi
tests:
needs:
- generate
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
Expand All @@ -58,10 +39,6 @@ jobs:
node-version: "16"
cache: "npm"
- run: npm install
- uses: actions/download-artifact@v3
with:
name: parser
path: src
- name: Run test suite
run: |
if [[ "$RUNNER_OS" == macOS ]]; then
Expand All @@ -77,19 +54,13 @@ jobs:
shell: bash

rust:
needs:
- generate
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
name: Run rust test build on ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: parser
path: src
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -101,7 +72,7 @@ jobs:

success:
needs:
# - uptodate
- generate
- tests
- rust
if: always()
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ target/

# C stuff
.cache/
src/parser.c
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[package]
name = "tree-sitter-nim"
description = "nim grammar for the tree-sitter parsing library"
version = "0.0.2"
version = "0.0.3"
keywords = ["incremental", "parsing", "nim"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-nim"
Expand Down
23 changes: 23 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: None
#
# SPDX-License-Identifier: CC0-1.0

{
"targets": [
{
"target_name": "tree_sitter_nim_binding",
"include_dirs": [
"<!(node -e \"require('nan')\")",
"src"
],
"sources": [
"bindings/node/binding.cc",
"src/parser.c",
"src/scanner.cc"
],
"cflags_c": [
"-std=c99",
]
}
]
}
81 changes: 35 additions & 46 deletions corpus/declarations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ const Test* {.importc: "TEST".}: int
(variable_declaration
(symbol_declaration_list
(tuple_deconstruct_declaration
(symbol_declaration_list
(symbol_declaration
name: (identifier))
(symbol_declaration
name: (identifier)))))
(symbol_declaration
name: (identifier))
(symbol_declaration
name: (identifier))))
value: (tuple_construction
(integer_literal)
(integer_literal))))
Expand All @@ -75,13 +74,12 @@ const Test* {.importc: "TEST".}: int
(variable_declaration
(symbol_declaration_list
(tuple_deconstruct_declaration
(symbol_declaration_list
(symbol_declaration
name: (identifier))
(symbol_declaration
name: (identifier))
(symbol_declaration
name: (identifier)))))
(symbol_declaration
name: (identifier))
(symbol_declaration
name: (identifier))
(symbol_declaration
name: (identifier))))
value: (tuple_construction
(integer_literal)
(integer_literal)
Expand All @@ -90,12 +88,11 @@ const Test* {.importc: "TEST".}: int
(variable_declaration
(symbol_declaration_list
(tuple_deconstruct_declaration
(symbol_declaration_list
(symbol_declaration
name: (identifier))
(symbol_declaration
name: (exported_symbol
(identifier))))))
(symbol_declaration
name: (identifier))
(symbol_declaration
name: (exported_symbol
(identifier)))))
value: (tuple_construction
(integer_literal)
(integer_literal))))
Expand Down Expand Up @@ -171,11 +168,10 @@ l_e_t
(variable_declaration
(symbol_declaration_list
(tuple_deconstruct_declaration
(symbol_declaration_list
(symbol_declaration
name: (identifier))
(symbol_declaration
name: (identifier)))))
(symbol_declaration
name: (identifier))
(symbol_declaration
name: (identifier))))
value: (tuple_construction
(integer_literal)
(integer_literal)))))
Expand Down Expand Up @@ -245,21 +241,19 @@ var (x, ) = (1, )
(variable_declaration
(symbol_declaration_list
(tuple_deconstruct_declaration
(symbol_declaration_list
(symbol_declaration
name: (identifier))
(symbol_declaration
name: (identifier)))))
(symbol_declaration
name: (identifier))
(symbol_declaration
name: (identifier))))
value: (tuple_construction
(integer_literal)
(integer_literal))))
(var_section
(variable_declaration
(symbol_declaration_list
(tuple_deconstruct_declaration
(symbol_declaration_list
(symbol_declaration
name: (identifier)))))
(symbol_declaration
name: (identifier))))
value: (tuple_construction
(integer_literal)))))

Expand All @@ -284,8 +278,7 @@ type
(type_declaration
(type_symbol_declaration
name: (identifier))
(modified_type
modifier: (distinct_type)
(distinct_type
(identifier)))
(type_declaration
(type_symbol_declaration
Expand All @@ -295,8 +288,7 @@ type
(symbol_declaration_list
(symbol_declaration
name: (identifier))))))
(modified_type
modifier: (ref_type)
(ref_type
(identifier)))))

================================================================================
Expand Down Expand Up @@ -400,7 +392,7 @@ type
values: (expression_list
(infix_expression
left: (identifier)
operator: (infix_operator)
operator: (operator)
right: (identifier)))
(field_declaration_list
(field_declaration
Expand All @@ -412,7 +404,7 @@ type
values: (expression_list
(infix_expression
left: (identifier)
operator: (infix_operator)
operator: (operator)
right: (identifier)))
(field_declaration_list
(field_declaration
Expand All @@ -424,7 +416,7 @@ type
values: (expression_list
(infix_expression
left: (identifier)
operator: (infix_operator)
operator: (operator)
right: (identifier))
(identifier)
(identifier)
Expand Down Expand Up @@ -471,8 +463,7 @@ type
(type_declaration
(type_symbol_declaration
name: (identifier))
(modified_type
modifier: (ref_type)
(ref_type
(object_declaration
(field_declaration_list
(field_declaration
Expand Down Expand Up @@ -504,8 +495,7 @@ type
(colon_expression
left: (identifier)
right: (string_literal))))
(modified_type
modifier: (ref_type)
(ref_type
(object_declaration
inherits: (identifier)
(field_declaration_list
Expand Down Expand Up @@ -538,8 +528,7 @@ type
(type_declaration
(type_symbol_declaration
name: (identifier))
(modified_type
modifier: (ref_type)
(ref_type
(object_declaration)))
(type_declaration
(type_symbol_declaration
Expand Down Expand Up @@ -667,7 +656,7 @@ type
(infix_expression
left: (infix_expression
left: (identifier)
operator: (infix_operator)
operator: (operator)
right: (identifier))
right: (identifier))
(infix_expression
Expand Down Expand Up @@ -817,7 +806,7 @@ proc foo =
body: (statement_list
(infix_expression
left: (identifier)
operator: (infix_operator)
operator: (operator)
right: (identifier))))
(macro_declaration
name: (identifier)
Expand Down
Loading

0 comments on commit ecbd15e

Please sign in to comment.