Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
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
21 changes: 21 additions & 0 deletions .gitattributes
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
14 changes: 14 additions & 0 deletions .github/conventional_commits_labels.json
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"
}
22 changes: 22 additions & 0 deletions .github/dependabot.yml
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"
Comment on lines +9 to +17

Copy link
Copy Markdown
Contributor

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.yml and README.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 containing pyproject.toml and setup.py, and remove or relocate the NuGet block until an actual NuGet manifest exists.
  • README.md#L69-L72: list bindings/c, bindings/node, and bindings/python.

[bug]

📍 Affects 2 files
  • .github/dependabot.yml#L9-L17 (this comment)
  • README.md#L69-L72
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/dependabot.yml around lines 9 - 17, Align both binding references
with the repository layout: in .github/dependabot.yml lines 9-17, point the pip
ecosystem at the directory containing pyproject.toml and setup.py and remove or
relocate the NuGet entry until a NuGet manifest exists; in README.md lines
69-72, list bindings/c, bindings/node, and bindings/python instead of the C# and
TypeScript paths.


- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
17 changes: 17 additions & 0 deletions .github/release.yml
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:
- "*"
104 changes: 104 additions & 0 deletions .github/workflows/ci.yml
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 }
}
44 changes: 44 additions & 0 deletions .gitignore
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
66 changes: 66 additions & 0 deletions AGENTS.md
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.
77 changes: 77 additions & 0 deletions CMakeLists.txt
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")
Comment thread
Seddryck marked this conversation as resolved.
Loading