Skip to content

fix(tree-sitter): add interface/type alias/as cast support, fix ternary scanner bug - #1303

Closed
ciokyyy wants to merge 2 commits into
Ripple-TS:mainfrom
ciokyyy:fix/grammar-typescript-features
Closed

fix(tree-sitter): add interface/type alias/as cast support, fix ternary scanner bug#1303
ciokyyy wants to merge 2 commits into
Ripple-TS:mainfrom
ciokyyy:fix/grammar-typescript-features

Conversation

@ciokyyy

@ciokyyy ciokyyy commented Jun 20, 2026

Copy link
Copy Markdown

Fixes the tree-sitter grammar and external scanner for the ripple/tsrx language.


Note

Medium Risk
Grammar and scanner changes can shift parse trees for existing Ripple/TSRX sources across editors and tooling; impact is confined to the tree-sitter package, not application runtime.

Overview
Extends the Ripple tree-sitter grammar with common TypeScript surface syntax: interface (bodies with properties, methods, index signatures), type aliases, and as / as const expressions, wired into top-level declaration.

Parser behavior is tightened around types and expressions: object_type members can be separated by ; or ,, new may take type arguments, array destructuring allows member/subscript patterns, and call vs ternary precedence is adjusted via named precedences and extra conflict rules (including as_expression).

The external scanner no longer treats a trailing ? as a reason to reject automatic semicolons when ASI fails—so ternary ? is disambiguated via scan_ternary_qmark instead of blocking ASI incorrectly.

Reviewed by Cursor Bugbot for commit d5cc7c2. Bugbot is set up for automated code reviews on this repo. Configure here.

…ry scanner bug

Fixes the tree-sitter grammar and external scanner for .tsrx files:

Grammar (grammar.js):
- Add interface_declaration rule (interface keyword, body, method/index signatures)
- Add type_alias_declaration rule
- Add as_expression rule for TypeScript casts
- Add generic_type to primary_expression for new Map<K,V>() patterns
- Fix object_type to accept semicolons as member separators
- Add missing _type_annotation to index_signature
- Add precedences array for proper shift/reduce conflict resolution
- Add necessary conflict declarations

Scanner (scanner.c):
- Fix AUTOMATIC_SEMICOLON handler that was returning before TERNARY_QMARK
  could be checked, causing ALL ternary expressions (a ? b : c) to fail

Closes #1302
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

@Opaius is attempting to deploy a commit to the Ripple Team Team on Vercel.

A member of the Team first needs to authorize it.

…ry scanner bug

Grammar changes:
- Add interface_declaration, type_alias_declaration, as_expression rules
- Add type_arguments to new_expression for new Map<K,V>() support
- Fix object_type to accept semicolons as member separators
- Fix index_signature to include missing _type_annotation
- Fix various missing features

Scanner fix (CRITICAL):
- The AUTOMATIC_SEMICOLON handler returned before TERNARY_QMARK
  could be checked, causing ALL ternary expressions to fail.
  Fixed the control flow to allow TERNARY_QMARK to be produced.

The 440-line version of transitions.tsrx parses with 0 errors.
Larger files (700+ lines) may have issues due to GLR state explosion
from the many conflicts needed for TypeScript support.

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit d5cc7c2. Configure here.

[$.type, $.nested_type_identifier],
[$._type_annotation, $.array_type],
[$.empty_statement, $.object_type],
[$.call_expression, $.ternary_expression],

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.

Missing cast in statement expressions

Medium Severity

This commit adds as_expression to the general expression rule but not to _expression_statement_expression or the @{} container expression-statement choice. Top-level or container statements like value as Type; therefore fail to parse as casts unless wrapped in parentheses, unlike other TypeScript contexts that use expression.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d5cc7c2. Configure here.

@ciokyyy ciokyyy closed this by deleting the head repository Aug 7, 2026
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.

1 participant