fix(tree-sitter): add interface/type alias/as cast support, fix ternary scanner bug - #1303
fix(tree-sitter): add interface/type alias/as cast support, fix ternary scanner bug#1303ciokyyy wants to merge 2 commits into
Conversation
…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
|
@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.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
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], |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit d5cc7c2. Configure here.


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),typealiases, andas/as constexpressions, wired into top-leveldeclaration.Parser behavior is tightened around types and expressions:
object_typemembers can be separated by;or,,newmay take type arguments, array destructuring allows member/subscript patterns, and call vs ternary precedence is adjusted via named precedences and extra conflict rules (includingas_expression).The external scanner no longer treats a trailing
?as a reason to reject automatic semicolons when ASI fails—so ternary?is disambiguated viascan_ternary_qmarkinstead of blocking ASI incorrectly.Reviewed by Cursor Bugbot for commit d5cc7c2. Bugbot is set up for automated code reviews on this repo. Configure here.