-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement basic expressions, function calls and literals #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a34705d
chore: initialize repository metadata
Seddryck aa5f8f6
chore: initialize Tree-sitter project with C# CI
Seddryck d01710c
feat: implement basic expression grammar
Seddryck d45a64e
Update README.md
Seddryck 57e87c4
Update SECURITY.md
Seddryck d2d1977
fix: address parser review feedback
Seddryck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| root = true | ||
|
|
||
| [*] | ||
| charset = utf-8 | ||
| end_of_line = lf | ||
| insert_final_newline = true | ||
| trim_trailing_whitespace = true | ||
| indent_style = space | ||
| indent_size = 2 | ||
|
|
||
| [*.md] | ||
| trim_trailing_whitespace = false | ||
|
|
||
| [*.{bat,cmd,ps1}] | ||
| end_of_line = crlf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Normalize text files while preserving platform-appropriate checkouts. | ||
| * text=auto | ||
|
|
||
| # Cross-platform scripts require explicit line endings. | ||
| *.sh text eol=lf | ||
| *.bash text eol=lf | ||
| *.bat text eol=crlf | ||
| *.cmd text eol=crlf | ||
| *.ps1 text eol=crlf | ||
|
|
||
| # Binary files must not be modified by Git's text conversion. | ||
| *.png binary | ||
| *.jpg binary | ||
| *.jpeg binary | ||
| *.gif binary | ||
| *.ico binary | ||
| *.pdf binary | ||
| *.zip binary | ||
|
|
||
| # Tree-sitter parser artifacts are generated from grammar.js. | ||
| src/** linguist-generated=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "!": "breaking-change", | ||
| "chore": "dependency-update", | ||
| "docs": "docs", | ||
| "style": "none", | ||
| "ci": "build", | ||
| "build": "build", | ||
| "feat": "new-feature", | ||
| "test": "none", | ||
| "refactor": "none", | ||
| "revert": "bug", | ||
| "perf": "enhancement", | ||
| "fix": "bug" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| version: 2 | ||
|
|
||
| updates: | ||
| - package-ecosystem: "npm" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
|
|
||
| - package-ecosystem: "nuget" | ||
| directory: "/bindings/csharp" | ||
| schedule: | ||
| interval: "weekly" | ||
|
|
||
| - package-ecosystem: "pip" | ||
| directory: "/bindings/python" | ||
| schedule: | ||
| interval: "weekly" | ||
|
|
||
| - package-ecosystem: "github-actions" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # .github/release.yml | ||
|
|
||
| changelog: | ||
| categories: | ||
| - title: Breaking Changes💫 | ||
| labels: | ||
| - breaking-change | ||
| - title: Exciting new features and enhancements🎉 | ||
| labels: | ||
| - new-feature | ||
| - enhancement | ||
| - title: Bug fixes 👾 | ||
| labels: | ||
| - bug | ||
| - title: Other Changes 🪛 | ||
| labels: | ||
| - "*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| parser: | ||
| name: Test Tree-sitter parser | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Tree-sitter | ||
| uses: tree-sitter/setup-action/cli@v2 | ||
|
|
||
| - name: Test parser | ||
| uses: tree-sitter/parser-test-action@v3 | ||
|
|
||
| csharp: | ||
| name: Build and test C# binding | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up .NET | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: 10.0.x | ||
|
|
||
| - name: Discover C# projects | ||
| id: csharp-projects | ||
| shell: pwsh | ||
| run: | | ||
| $projectRoot = "bindings/csharp" | ||
| $projects = if (Test-Path -LiteralPath $projectRoot -PathType Container) { | ||
| @(Get-ChildItem -LiteralPath $projectRoot -Recurse -Filter *.csproj) | ||
| } else { | ||
| @() | ||
| } | ||
| "found=$($projects.Count -gt 0)" >> $env:GITHUB_OUTPUT | ||
| if ($projects.Count -eq 0) { | ||
| Write-Host "No C# projects exist yet; skipping .NET validation." | ||
| } | ||
|
|
||
| - name: Restore C# projects | ||
| if: steps.csharp-projects.outputs.found == 'True' | ||
| shell: pwsh | ||
| run: | | ||
| $projectRoot = "bindings/csharp" | ||
| if (-not (Test-Path -LiteralPath $projectRoot -PathType Container)) { | ||
| Write-Host "No C# project directory exists; skipping restore." | ||
| exit 0 | ||
| } | ||
| Get-ChildItem -LiteralPath $projectRoot -Recurse -Filter *.csproj | ForEach-Object { | ||
| dotnet restore $_.FullName | ||
| if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | ||
| } | ||
|
|
||
| - name: Build C# projects | ||
| if: steps.csharp-projects.outputs.found == 'True' | ||
| shell: pwsh | ||
| run: | | ||
| $projectRoot = "bindings/csharp" | ||
| if (-not (Test-Path -LiteralPath $projectRoot -PathType Container)) { | ||
| Write-Host "No C# project directory exists; skipping build." | ||
| exit 0 | ||
| } | ||
| Get-ChildItem -LiteralPath $projectRoot -Recurse -Filter *.csproj | ForEach-Object { | ||
| dotnet build $_.FullName --configuration Release --no-restore | ||
| if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | ||
| } | ||
|
|
||
| - name: Test C# projects | ||
| if: steps.csharp-projects.outputs.found == 'True' | ||
| shell: pwsh | ||
| run: | | ||
| $projectRoot = "bindings/csharp" | ||
| if (-not (Test-Path -LiteralPath $projectRoot -PathType Container)) { | ||
| Write-Host "No C# project directory exists; skipping tests." | ||
| exit 0 | ||
| } | ||
| Get-ChildItem -LiteralPath $projectRoot -Recurse -Filter *.csproj | ForEach-Object { | ||
| dotnet test $_.FullName --configuration Release --no-build | ||
| if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Tree-sitter | ||
| node_modules/ | ||
| .tree-sitter/ | ||
| *.so | ||
| *.dll | ||
| *.dylib | ||
| *.wasm | ||
|
|
||
| # .NET / C# | ||
| .vs/ | ||
| bin/ | ||
| obj/ | ||
| TestResults/ | ||
| *.user | ||
| *.suo | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| .pytest_cache/ | ||
| .mypy_cache/ | ||
| .pyright/ | ||
| *.egg-info/ | ||
| dist/ | ||
|
|
||
| # TypeScript / Node | ||
| node_modules/ | ||
| coverage/ | ||
| *.tsbuildinfo | ||
| build/ | ||
| *.node | ||
|
|
||
| # IDEs | ||
| .idea/ | ||
| .vscode/ | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Logs | ||
| *.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| ## Issues | ||
|
|
||
| Issue titles MUST be descriptive natural-language titles. | ||
|
|
||
| Do NOT use Conventional Commit syntax for issue titles. | ||
|
|
||
| Prefer: | ||
|
|
||
| ```text | ||
| Map should preserve null values | ||
| Add pairwise function | ||
| Reduce allocations when mapping arrays | ||
| ``` | ||
|
|
||
| Avoid: | ||
|
|
||
| ```text | ||
| fix: preserve null values when mapping arrays | ||
| feat: add pairwise function | ||
| perf: reduce allocations when mapping arrays | ||
| ``` | ||
|
|
||
| Every issue MUST have exactly one change-type label: | ||
|
|
||
| * `bug` for a defect | ||
| * `new-feature` for new functionality | ||
| * `enhancement` for an improvement or refactoring of existing functionality | ||
|
|
||
| The label is determined by the nature of the issue. | ||
|
|
||
| ## Skills | ||
|
|
||
| Repository-specific workflows are defined under `.github/skills/`. | ||
|
|
||
| When a task matches an existing skill, read and follow that skill before making changes. | ||
|
|
||
| Skills define task-specific procedures. `AGENTS.md` defines repository-wide rules and takes precedence if a skill contains conflicting Git, worktree, branch, issue, commit, or pull-request instructions. | ||
|
|
||
| ## Pull requests | ||
|
|
||
| For every completed implementation: | ||
|
|
||
| 1. Push the task branch. | ||
| 2. Create a GitHub pull request targeting `main`. | ||
| 3. Use a Conventional Commit-style PR title. | ||
| 4. Include a concise description of the change. | ||
| 5. Include the relevant tests or validation performed. | ||
| 6. Link the pull request to the corresponding issue when one exists (use wording `close`). | ||
|
|
||
| Do NOT use `bug`, `new-feature`, or `enhancement` labels on the pull request unless explicitly requested. | ||
|
|
||
| ## Completion criteria | ||
|
|
||
| A coding task is complete only when: | ||
|
|
||
| * implementation was performed in the task's dedicated worktree; | ||
| * for a new task, the branch was created from the latest `origin/main`; | ||
| * the relevant tests have been run; | ||
| * all intended changes are committed; | ||
| * commit messages follow Conventional Commits; | ||
| * the branch has been pushed; | ||
| * a pull request targeting `main` has been created; | ||
| * the PR title follows Conventional Commits; | ||
| * the corresponding issue has the appropriate `bug`, `new-feature`, or `enhancement` label; | ||
| * the pull request is linked to the issue when one exists; | ||
| * the worktree is clean. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| cmake_minimum_required(VERSION 3.13) | ||
|
|
||
| project(tree-sitter-expressif | ||
| VERSION "0.1.0" | ||
| DESCRIPTION "Tree-sitter parser for the Expressif expression language" | ||
| HOMEPAGE_URL "https://github.com/Seddryck/Expressif.Syntax" | ||
| LANGUAGES C) | ||
|
|
||
| option(BUILD_SHARED_LIBS "Build using shared libraries" ON) | ||
| option(TREE_SITTER_REUSE_ALLOCATOR "Reuse the library allocator" OFF) | ||
|
|
||
| set(TREE_SITTER_ABI_VERSION 15 CACHE STRING "Tree-sitter ABI version") | ||
| if(NOT ${TREE_SITTER_ABI_VERSION} MATCHES "^[0-9]+$") | ||
| unset(TREE_SITTER_ABI_VERSION CACHE) | ||
| message(FATAL_ERROR "TREE_SITTER_ABI_VERSION must be an integer") | ||
| endif() | ||
|
|
||
| include(GNUInstallDirs) | ||
|
|
||
| find_program(TREE_SITTER_CLI tree-sitter DOC "Tree-sitter CLI") | ||
|
|
||
| add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/grammar.json" | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/src/node-types.json" | ||
| DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/grammar.js" | ||
| COMMAND "${TREE_SITTER_CLI}" generate grammar.js --no-parser | ||
| WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
| COMMENT "Generating grammar.json") | ||
|
|
||
| add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/parser.c" | ||
| BYPRODUCTS "${CMAKE_CURRENT_SOURCE_DIR}/src/tree_sitter/parser.h" | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/src/tree_sitter/alloc.h" | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/src/tree_sitter/array.h" | ||
| DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/grammar.json" | ||
| COMMAND "${TREE_SITTER_CLI}" generate src/grammar.json | ||
| --abi=${TREE_SITTER_ABI_VERSION} | ||
| WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
| COMMENT "Generating parser.c") | ||
|
|
||
| add_library(tree-sitter-expressif src/parser.c) | ||
| if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scanner.c) | ||
| target_sources(tree-sitter-expressif PRIVATE src/scanner.c) | ||
| endif() | ||
| target_include_directories(tree-sitter-expressif | ||
| PRIVATE src | ||
| INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/bindings/c> | ||
| $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) | ||
|
|
||
| target_compile_definitions(tree-sitter-expressif PRIVATE | ||
| $<$<BOOL:${TREE_SITTER_REUSE_ALLOCATOR}>:TREE_SITTER_REUSE_ALLOCATOR> | ||
| $<$<CONFIG:Debug>:TREE_SITTER_DEBUG>) | ||
|
|
||
| set_target_properties(tree-sitter-expressif | ||
| PROPERTIES | ||
| C_STANDARD 11 | ||
| POSITION_INDEPENDENT_CODE ON | ||
| SOVERSION "${TREE_SITTER_ABI_VERSION}.${PROJECT_VERSION_MAJOR}" | ||
| DEFINE_SYMBOL "") | ||
|
|
||
| configure_file(bindings/c/tree-sitter-expressif.pc.in | ||
| "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-expressif.pc" @ONLY) | ||
|
|
||
| install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bindings/c/tree_sitter" | ||
| DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" | ||
| FILES_MATCHING PATTERN "*.h") | ||
| install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-expressif.pc" | ||
| DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") | ||
| install(TARGETS tree-sitter-expressif | ||
| LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") | ||
|
|
||
| file(GLOB QUERIES queries/*.scm) | ||
| install(FILES ${QUERIES} | ||
| DESTINATION "${CMAKE_INSTALL_DATADIR}/tree-sitter/queries/expressif") | ||
|
|
||
| add_custom_target(ts-test "${TREE_SITTER_CLI}" test | ||
| DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/parser.c" | ||
| WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
| COMMENT "tree-sitter test") | ||
|
Seddryck marked this conversation as resolved.
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Align the binding layout across configuration and documentation.
The repository binding layout is inconsistent between
.github/dependabot.ymlandREADME.md. The supplied project exposes C, Node, and Python bindings, but these files reference C# and TypeScript directories and place Python packaging under the wrong directory. This can suppress automated dependency updates..github/dependabot.yml#L9-L17: point the pip update to the directory containingpyproject.tomlandsetup.py, and remove or relocate the NuGet block until an actual NuGet manifest exists.README.md#L69-L72: listbindings/c,bindings/node, andbindings/python.[bug]
📍 Affects 2 files
.github/dependabot.yml#L9-L17(this comment)README.md#L69-L72🤖 Prompt for AI Agents