@@ -18,32 +18,27 @@ impl Parser<'_> {
1818 pub fn parse_root ( & mut self ) {
1919 self . start_node ( SyntaxKind :: Root ) ;
2020
21- // Track spans of unnamed defs to emit errors for non-last ones
2221 let mut unnamed_def_spans: Vec < TextRange > = Vec :: new ( ) ;
2322
2423 while !self . has_fatal_error ( ) && ( self . peek ( ) != SyntaxKind :: Error || !self . eof ( ) ) {
2524 // LL(2): Id followed by Equals → named definition (if PascalCase)
2625 if self . peek ( ) == SyntaxKind :: Id && self . peek_nth ( 1 ) == SyntaxKind :: Equals {
2726 self . parse_def ( ) ;
2827 } else {
29- // Anonymous def: wrap expression in Def node
3028 let start = self . current_span ( ) . start ( ) ;
3129 self . start_node ( SyntaxKind :: Def ) ;
3230 let success = self . parse_expr_or_error ( ) ;
3331 if !success {
34- // Synchronize: consume remaining garbage until next def boundary
3532 self . synchronize_to_def_start ( ) ;
3633 }
3734 self . finish_node ( ) ;
38- // Only track successfully parsed defs for validation
3935 if success {
4036 let end = self . last_non_trivia_end ( ) . unwrap_or ( start) ;
4137 unnamed_def_spans. push ( TextRange :: new ( start, end) ) ;
4238 }
4339 }
4440 }
4541
46- // Emit errors for all unnamed defs except the last one
4742 if unnamed_def_spans. len ( ) > 1 {
4843 for span in & unnamed_def_spans[ ..unnamed_def_spans. len ( ) - 1 ] {
4944 let def_text = & self . source [ usize:: from ( span. start ( ) ) ..usize:: from ( span. end ( ) ) ] ;
@@ -164,12 +159,10 @@ impl Parser<'_> {
164159 /// PascalCase identifiers without children become `Ref` nodes.
165160 /// PascalCase identifiers with children emit an error but parse as `Tree`.
166161 fn parse_tree ( & mut self ) {
167- // Use checkpoint so we can decide Tree vs Ref after seeing the full content
168162 let checkpoint = self . checkpoint ( ) ;
169163 self . push_delimiter ( SyntaxKind :: ParenOpen ) ;
170164 self . bump ( ) ; // consume '('
171165
172- // Track if this is a reference (PascalCase identifier)
173166 let mut is_ref = false ;
174167 let mut ref_name: Option < String > = None ;
175168
@@ -199,7 +192,6 @@ impl Parser<'_> {
199192 }
200193
201194 if self . peek ( ) == SyntaxKind :: Slash {
202- // Supertype syntax - commit to Tree
203195 if is_ref {
204196 self . start_node_at ( checkpoint, SyntaxKind :: Tree ) ;
205197 self . error ( "references cannot use supertype syntax (/)" ) ;
0 commit comments