Skip to content

feat(parser): add boolean shorthand expressions - #83

Merged
Seddryck merged 2 commits into
mainfrom
feat/boolean-shorthand-expressions
Aug 18, 2026
Merged

feat(parser): add boolean shorthand expressions#83
Seddryck merged 2 commits into
mainfrom
feat/boolean-shorthand-expressions

Conversation

@Seddryck

@Seddryck Seddryck commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • parse ! as lossless shorthand syntax for the existing not function
  • parse |AND, |OR, and |XOR as left-associative shorthand syntax for the existing boolean functions
  • support grouping with the existing parenthesized-expression syntax
  • expose typed unary, binary, and operator syntax nodes without semantic lowering
  • add valid, composed, grouped, whitespace, and malformed-input coverage

Validation

  • npm exec tree-sitter test -- --file-name boolean-shorthands.txt (18/18 passed)
  • dotnet test bindings/csharp/Expressif.Syntax.Tests/Expressif.Syntax.Tests.csproj --no-restore --nologo -f net8.0 -p:NuGetAudit=false -p:TargetFrameworks=net8.0 (146/146 passed)

Closes #38
Closes #39
Closes #40

Summary by CodeRabbit

  • New Features

    • Added unary shorthand expressions using the ! operator.
    • Added binary shorthand expressions using |AND, |OR, and |XOR.
    • Supports nesting, precedence, associativity, parentheses, pipelines, function arguments, and generic operands.
  • Bug Fixes

    • Improved parsing and error recovery for incomplete, malformed, or unsupported shorthand expressions.
    • Updated parameterized-expression error reporting for missing separators.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 02ef9317-2bfd-4c38-91b3-ad86517c376a

📥 Commits

Reviewing files that changed from the base of the PR and between a6484e1 and 0752f73.

📒 Files selected for processing (9)
  • bindings/csharp/Expressif.Syntax.Tests/SyntaxBindingTests.cs
  • bindings/csharp/Expressif.Syntax/ExpressifSyntax.cs
  • bindings/csharp/Expressif.Syntax/SyntaxNodes.cs
  • grammar.js
  • src/grammar.json
  • src/node-types.json
  • src/parser.c
  • test/corpus/boolean-shorthands.txt
  • test/corpus/parameterized_expressions.txt

Included review availability: Your plan includes up to 1 review per rolling hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The grammar now parses unary and binary shorthand expressions with precedence and composition rules. Tree-sitter node definitions and C# syntax bindings expose their operators and operands. Corpus and binding tests cover valid, nested, composed, and malformed expressions.

Changes

Boolean shorthand expressions

Layer / File(s) Summary
Expression grammar and node model
grammar.js, src/grammar.json, src/node-types.json
Adds !, `
C# syntax binding
bindings/csharp/Expressif.Syntax/SyntaxNodes.cs, bindings/csharp/Expressif.Syntax/ExpressifSyntax.cs
Adds unary and binary syntax kinds and node classes. Binds operators and recursive operands from Tree-sitter expression nodes.
Parsing and binding validation
test/corpus/boolean-shorthands.txt, bindings/csharp/Expressif.Syntax.Tests/SyntaxBindingTests.cs, test/corpus/parameterized_expressions.txt
Adds coverage for expression structure, precedence, associativity, composition, spans, child ordering, malformed input, and parser recovery.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 0752f

The PR adds boolean shorthand parsing and typed syntax nodes with passing parser and C# test validation; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Source
  participant TreeSitterParser
  participant ExpressifSyntax
  participant SyntaxBindingTests
  Source->>TreeSitterParser: parse unary or binary shorthand
  TreeSitterParser->>ExpressifSyntax: provide expression CST nodes
  ExpressifSyntax->>SyntaxBindingTests: expose bound operators and operands
  SyntaxBindingTests->>SyntaxBindingTests: verify structure and malformed-input recovery
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issues [#38] and [#39] are addressed, but [#40] requires a dedicated curly-brace grouping node that the changes do not add or test. Add explicit grouped-expression CST nodes for curly-brace grouping, update bindings and node types, and add the required grouping and disambiguation tests.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: parser support for boolean shorthand expressions.
Out of Scope Changes check ✅ Passed The changes remain focused on boolean shorthand parsing, syntax binding, CST definitions, parser recovery, and related tests.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/boolean-shorthand-expressions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Seddryck
Seddryck marked this pull request as ready for review August 18, 2026 12:58
@Seddryck
Seddryck merged commit 6fd55c0 into main Aug 18, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement grouped expressions for boolean shorthands Implement binary shorthand expressions Implement unary shorthand expressions

1 participant