luaparse-rs 0.1.1

Multi-version Lua parser supporting Lua 5.1-5.4 and Luau
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
use luaparse_rs::{Parser, Luau, ast};
use luaparse_rs::ast::visitor::{Visitor, VisitorMut, walk_stmt, walk_expr};
use luaparse_rs::ast::{
    Stmt, StmtKind, Expr, ExprKind, Identifier, Block,
};

#[cfg(feature = "lua51")]
use luaparse_rs::Lua51;

fn parse_luau(input: &str) -> ast::Ast {
    let parser = Parser::<Luau>::new(input).unwrap();
    parser.parse().unwrap()
}

#[test]
fn test_count_identifiers() {
    let ast = parse_luau("local x = 1\nlocal y = x + 2");
    let mut count = 0;
    ast.for_each_identifier(|_| count += 1);
    // x (decl), y (decl), x (ref)
    assert_eq!(count, 3);
}

#[test]
fn test_count_function_calls() {
    let ast = parse_luau("print(foo(1, 2), bar())");
    let mut call_count = 0;
    ast.for_each_expr(|expr| {
        if matches!(expr.kind, ExprKind::Call(_)) {
            call_count += 1;
        }
    });
    // print(...), foo(1,2), bar()
    assert_eq!(call_count, 3);
}

#[test]
fn test_count_statements() {
    let ast = parse_luau("local a = 1\nlocal b = 2\nreturn a + b");
    let mut stmt_count = 0;
    ast.for_each_stmt(|_| stmt_count += 1);
    assert_eq!(stmt_count, 3);
}

#[test]
fn test_collect_identifier_names() {
    let ast = parse_luau("local foo = bar + baz");
    let mut names = vec![];
    ast.for_each_identifier(|ident| {
        names.push(ident.name.clone());
    });
    assert!(names.contains(&"foo".into()));
    assert!(names.contains(&"bar".into()));
    assert!(names.contains(&"baz".into()));
}

#[test]
fn test_visitor_trait_custom_impl() {
    struct NumberCounter {
        count: usize,
    }

    impl Visitor for NumberCounter {
        fn visit_expr(&mut self, expr: &Expr) {
            if matches!(expr.kind, ExprKind::Number(_)) {
                self.count += 1;
            }
            walk_expr(self, expr);
        }
    }

    let ast = parse_luau("local x = 1 + 2 + 3");
    let mut counter = NumberCounter { count: 0 };
    counter.visit_ast(&ast);
    assert_eq!(counter.count, 3);
}

#[test]
fn test_visitor_nested_blocks() {
    struct BlockCounter {
        count: usize,
    }

    impl Visitor for BlockCounter {
        fn visit_block(&mut self, block: &Block) {
            self.count += 1;
            ast::visitor::walk_block(self, block);
        }
    }

    let ast = parse_luau(
        "if true then\n  while false do\n    local x = 1\n  end\nend",
    );
    let mut counter = BlockCounter { count: 0 };
    counter.visit_ast(&ast);
    // top-level block, if-then block, while body block
    assert_eq!(counter.count, 3);
}

#[test]
fn test_visitor_function_params() {
    let ast = parse_luau("local function foo(a, b, c) end");
    let mut param_count = 0;
    struct ParamCounter<'a>(&'a mut usize);
    impl Visitor for ParamCounter<'_> {
        fn visit_parameter(&mut self, param: &luaparse_rs::ast::Parameter) {
            *self.0 += 1;
            ast::visitor::walk_parameter(self, param);
        }
    }
    let mut counter = ParamCounter(&mut param_count);
    counter.visit_ast(&ast);
    assert_eq!(param_count, 3);
}

#[test]
fn test_visitor_table_fields() {
    let ast = parse_luau("local t = {a = 1, b = 2, 3}");
    let mut field_count = 0;
    struct FieldCounter<'a>(&'a mut usize);
    impl Visitor for FieldCounter<'_> {
        fn visit_table_field(&mut self, field: &ast::TableField) {
            *self.0 += 1;
            ast::visitor::walk_table_field(self, field);
        }
    }
    let mut counter = FieldCounter(&mut field_count);
    counter.visit_ast(&ast);
    assert_eq!(field_count, 3);
}

#[test]
fn test_visitor_method_calls() {
    let ast = parse_luau("obj:method1():method2()");
    let mut method_count = 0;
    ast.for_each_expr(|expr| {
        if matches!(expr.kind, ExprKind::MethodCall(_)) {
            method_count += 1;
        }
    });
    assert_eq!(method_count, 2);
}

#[test]
fn test_visitor_binary_exprs() {
    let ast = parse_luau("local x = 1 + 2 * 3 - 4");
    let mut binop_count = 0;
    ast.for_each_expr(|expr| {
        if matches!(expr.kind, ExprKind::Binary(_)) {
            binop_count += 1;
        }
    });
    // (1 + (2 * 3)) - 4 = 3 binary ops
    assert_eq!(binop_count, 3);
}

#[test]
fn test_visitor_for_loops() {
    let ast = parse_luau(
        "for i = 1, 10 do end\nfor k, v in pairs(t) do end",
    );
    let mut numeric_for = 0;
    let mut generic_for = 0;
    ast.for_each_stmt(|stmt| {
        match &stmt.kind {
            StmtKind::NumericForLoop(_) => numeric_for += 1,
            StmtKind::GenericForLoop(_) => generic_for += 1,
            _ => {}
        }
    });
    assert_eq!(numeric_for, 1);
    assert_eq!(generic_for, 1);
}

#[test]
fn test_visitor_if_expression_luau() {
    let ast = parse_luau("local x = if true then 1 else 2");
    let mut if_expr_count = 0;
    ast.for_each_expr(|expr| {
        if matches!(expr.kind, ExprKind::IfExpression(_)) {
            if_expr_count += 1;
        }
    });
    assert_eq!(if_expr_count, 1);
}

#[test]
fn test_visitor_interpolated_string() {
    let ast = parse_luau("local x = `hello {name} world {age}`");
    let mut interp_count = 0;
    let mut inner_expr_count = 0;
    ast.for_each_expr(|expr| {
        match &expr.kind {
            ExprKind::InterpolatedString(interp) => {
                interp_count += 1;
                for seg in &interp.segments {
                    if matches!(seg, ast::InterpolationSegment::Expression(_)) {
                        inner_expr_count += 1;
                    }
                }
            }
            _ => {}
        }
    });
    assert_eq!(interp_count, 1);
    assert_eq!(inner_expr_count, 2);
}

#[test]
fn test_visitor_assignment_targets() {
    let ast = parse_luau("a, b.c, d[1] = 1, 2, 3");
    let mut target_count = 0;
    struct TargetCounter<'a>(&'a mut usize);
    impl Visitor for TargetCounter<'_> {
        fn visit_assignment_target(&mut self, target: &ast::AssignmentTarget) {
            *self.0 += 1;
            ast::visitor::walk_assignment_target(self, target);
        }
    }
    let mut counter = TargetCounter(&mut target_count);
    counter.visit_ast(&ast);
    assert_eq!(target_count, 3);
}

#[test]
fn test_visitor_return_values() {
    let ast = parse_luau("return 1, 2, 3");
    let mut return_val_count = 0;
    ast.for_each_stmt(|stmt| {
        if let StmtKind::ReturnStatement(ret) = &stmt.kind {
            return_val_count = ret.values.len();
        }
    });
    assert_eq!(return_val_count, 3);
}

#[test]
fn test_visitor_deeply_nested() {
    let ast = parse_luau(
        "if true then\n  if false then\n    if true then\n      local x = 1\n    end\n  end\nend",
    );
    let mut deepest_local = false;
    ast.for_each_stmt(|stmt| {
        if matches!(stmt.kind, StmtKind::LocalDeclaration(_)) {
            deepest_local = true;
        }
    });
    assert!(deepest_local);
}

#[test]
fn test_visitor_empty_program() {
    let ast = parse_luau("");
    let mut count = 0;
    ast.for_each_stmt(|_| count += 1);
    assert_eq!(count, 0);
}

#[test]
fn test_visitor_comments_visited() {
    struct CommentCounter {
        count: usize,
    }
    impl Visitor for CommentCounter {
        fn visit_comment(&mut self, _comment: &ast::Comment) {
            self.count += 1;
        }
    }
    let ast = parse_luau("-- a comment\nlocal x = 1 -- inline");
    let mut counter = CommentCounter { count: 0 };
    counter.visit_ast(&ast);
    assert_eq!(counter.count, ast.comments.len());
}

#[test]
fn test_visitor_mut_rename_identifiers() {
    struct Renamer;
    impl VisitorMut for Renamer {
        fn visit_identifier(&mut self, ident: &mut Identifier) {
            if ident.name == "foo" {
                ident.name = "bar".into();
            }
        }
    }

    let mut ast = parse_luau("local foo = foo + 1");
    let mut renamer = Renamer;
    renamer.visit_ast(&mut ast);

    let mut found_foo = false;
    let mut found_bar = false;
    ast.for_each_identifier(|ident| {
        if ident.name == "foo" {
            found_foo = true;
        }
        if ident.name == "bar" {
            found_bar = true;
        }
    });
    assert!(!found_foo, "should have renamed all 'foo'");
    assert!(found_bar, "should have 'bar' now");
}

#[test]
fn test_visitor_mut_replace_numbers() {
    struct NumberReplacer;
    impl VisitorMut for NumberReplacer {
        fn visit_expr(&mut self, expr: &mut Expr) {
            if let ExprKind::Number(ref mut num) = expr.kind {
                num.raw = "42".into();
            }
            ast::visitor::walk_expr_mut(self, expr);
        }
    }

    let mut ast = parse_luau("local x = 1 + 2 + 3");
    let mut replacer = NumberReplacer;
    replacer.visit_ast(&mut ast);

    let mut all_42 = true;
    ast.for_each_expr(|expr| {
        if let ExprKind::Number(num) = &expr.kind {
            if num.raw != "42" {
                all_42 = false;
            }
        }
    });
    assert!(all_42, "all numbers should be 42 now");
}

#[test]
fn test_visitor_mut_inject_statements() {
    struct BlockInjector;
    impl VisitorMut for BlockInjector {
        fn visit_block(&mut self, block: &mut Block) {
            let break_stmt = Stmt::synthetic(StmtKind::BreakStatement);
            block.statements.push(break_stmt);
        }
    }

    let mut ast = parse_luau("local x = 1");
    let original_count = ast.block.statements.len();
    let mut injector = BlockInjector;
    injector.visit_ast(&mut ast);
    assert_eq!(ast.block.statements.len(), original_count + 1);
}

#[test]
fn test_visitor_mut_function_body() {
    struct BodyClearer;
    impl VisitorMut for BodyClearer {
        fn visit_stmt(&mut self, stmt: &mut Stmt) {
            if let StmtKind::LocalFunctionDeclaration(ref mut decl) = stmt.kind {
                decl.body.statements.clear();
            }
            ast::visitor::walk_stmt_mut(self, stmt);
        }
    }

    let mut ast = parse_luau("local function foo()\n  local x = 1\n  return x\nend");
    let mut clearer = BodyClearer;
    clearer.visit_ast(&mut ast);

    if let StmtKind::LocalFunctionDeclaration(ref decl) = ast.block.statements[0].kind {
        assert_eq!(decl.body.statements.len(), 0);
    } else {
        panic!("expected local function declaration");
    }
}

#[test]
fn test_visitor_scope_analysis_pattern() {
    struct ScopeAnalyzer {
        declarations: Vec<String>,
        references: Vec<String>,
    }

    impl Visitor for ScopeAnalyzer {
        fn visit_stmt(&mut self, stmt: &Stmt) {
            if let StmtKind::LocalDeclaration(ref decl) = stmt.kind {
                for var in &decl.names {
                    self.declarations.push(var.name.name.clone());
                }
            }
            walk_stmt(self, stmt);
        }

        fn visit_expr(&mut self, expr: &Expr) {
            if let ExprKind::Identifier(ref ident) = expr.kind {
                self.references.push(ident.name.clone());
            }
            walk_expr(self, expr);
        }
    }

    let ast = parse_luau("local x = 1\nlocal y = x + 2\nreturn y");
    let mut analyzer = ScopeAnalyzer {
        declarations: vec![],
        references: vec![],
    };
    analyzer.visit_ast(&ast);

    assert_eq!(analyzer.declarations, vec!["x", "y"]);
    assert!(analyzer.references.contains(&"x".to_string()));
    assert!(analyzer.references.contains(&"y".to_string()));
}

#[test]
fn test_visitor_complexity_counter() {
    struct ComplexityCounter {
        complexity: usize,
    }

    impl Visitor for ComplexityCounter {
        fn visit_stmt(&mut self, stmt: &Stmt) {
            match &stmt.kind {
                StmtKind::IfStatement(if_stmt) => {
                    self.complexity += 1; // if
                    self.complexity += if_stmt.elseif_branches.len(); // elseifs
                }
                StmtKind::WhileLoop(_) | StmtKind::RepeatLoop(_)
                | StmtKind::NumericForLoop(_) | StmtKind::GenericForLoop(_) => {
                    self.complexity += 1;
                }
                _ => {}
            }
            walk_stmt(self, stmt);
        }

        fn visit_expr(&mut self, expr: &Expr) {
            if let ExprKind::Binary(ref bin) = expr.kind {
                if matches!(
                    bin.operator,
                    ast::BinaryOperator::And | ast::BinaryOperator::Or
                ) {
                    self.complexity += 1;
                }
            }
            walk_expr(self, expr);
        }
    }

    let ast = parse_luau(
        "if a then\n  while b do end\nend\nfor i = 1, 10 do end",
    );
    let mut counter = ComplexityCounter { complexity: 0 };
    counter.visit_ast(&ast);
    // if + while + for = 3
    assert_eq!(counter.complexity, 3);
}

#[test]
fn test_visitor_mut_obfuscate_identifiers() {
    struct Obfuscator {
        counter: usize,
    }

    impl VisitorMut for Obfuscator {
        fn visit_identifier(&mut self, ident: &mut Identifier) {
            ident.name = format!("_v{}", self.counter);
            self.counter += 1;
        }
    }

    let mut ast = parse_luau("local hello = world");
    let mut obf = Obfuscator { counter: 0 };
    obf.visit_ast(&mut ast);

    // All identifiers should now be _v0, _v1, etc
    let mut names = vec![];
    ast.for_each_identifier(|ident| names.push(ident.name.clone()));
    assert!(names.iter().all(|n| n.starts_with("_v")));
}

#[test]
fn test_visitor_export_statement() {
    let ast = parse_luau("export type Foo = number");
    let mut found_export = false;
    ast.for_each_stmt(|stmt| {
        if matches!(stmt.kind, StmtKind::ExportStatement(_)) {
            found_export = true;
        }
    });
    assert!(found_export);
}

#[test]
fn test_visitor_compound_assignment() {
    let ast = parse_luau("x += 1");
    let mut found_compound = false;
    ast.for_each_stmt(|stmt| {
        if matches!(stmt.kind, StmtKind::CompoundAssignment(_)) {
            found_compound = true;
        }
    });
    assert!(found_compound);
}

#[test]
fn test_visitor_do_block() {
    let ast = parse_luau("do\n  local x = 1\nend");
    let mut found_do = false;
    let mut found_local_inside = false;
    ast.for_each_stmt(|stmt| {
        match &stmt.kind {
            StmtKind::DoBlock(_) => found_do = true,
            StmtKind::LocalDeclaration(_) => found_local_inside = true,
            _ => {}
        }
    });
    assert!(found_do);
    assert!(found_local_inside);
}

#[test]
fn test_visitor_unary_expressions() {
    let ast = parse_luau("local x = -1\nlocal y = not true\nlocal z = #t");
    let mut unary_count = 0;
    ast.for_each_expr(|expr| {
        if matches!(expr.kind, ExprKind::Unary(_)) {
            unary_count += 1;
        }
    });
    assert_eq!(unary_count, 3);
}

#[test]
fn test_visitor_string_literals() {
    let ast = parse_luau(r#"local a = "hello" local b = 'world'"#);
    let mut string_count = 0;
    ast.for_each_expr(|expr| {
        if matches!(expr.kind, ExprKind::String(_)) {
            string_count += 1;
        }
    });
    assert_eq!(string_count, 2);
}

#[test]
fn test_visitor_field_access_chain() {
    let ast = parse_luau("local x = a.b.c.d");
    let mut field_count = 0;
    ast.for_each_expr(|expr| {
        if matches!(expr.kind, ExprKind::FieldAccess(_)) {
            field_count += 1;
        }
    });
    // a.b, (a.b).c, ((a.b).c).d = 3 field accesses
    assert_eq!(field_count, 3);
}

#[test]
fn test_visitor_parenthesized() {
    let ast = parse_luau("local x = (1 + 2)");
    let mut paren_count = 0;
    ast.for_each_expr(|expr| {
        if matches!(expr.kind, ExprKind::Parenthesized(_)) {
            paren_count += 1;
        }
    });
    assert_eq!(paren_count, 1);
}

#[test]
fn test_visitor_continue_statement() {
    let ast = parse_luau("for i = 1, 10 do continue end");
    let mut found_continue = false;
    ast.for_each_stmt(|stmt| {
        if matches!(stmt.kind, StmtKind::ContinueStatement) {
            found_continue = true;
        }
    });
    assert!(found_continue);
}

#[test]
fn test_visitor_repeat_loop() {
    let ast = parse_luau("repeat local x = 1 until x > 10");
    let mut found_repeat = false;
    ast.for_each_stmt(|stmt| {
        if matches!(stmt.kind, StmtKind::RepeatLoop(_)) {
            found_repeat = true;
        }
    });
    assert!(found_repeat);
}

#[test]
fn test_visitor_function_expression() {
    let ast = parse_luau("local f = function(a, b) return a + b end");
    let mut func_expr_count = 0;
    ast.for_each_expr(|expr| {
        if matches!(expr.kind, ExprKind::Function(_)) {
            func_expr_count += 1;
        }
    });
    assert_eq!(func_expr_count, 1);
}

#[test]
fn test_visitor_vararg() {
    let ast = parse_luau("local function f(...) return ... end");
    let mut vararg_count = 0;
    ast.for_each_expr(|expr| {
        if matches!(expr.kind, ExprKind::Vararg) {
            vararg_count += 1;
        }
    });
    assert_eq!(vararg_count, 1);
}

#[test]
fn test_visitor_index_access() {
    let ast = parse_luau("local x = t[1][2]");
    let mut index_count = 0;
    ast.for_each_expr(|expr| {
        if matches!(expr.kind, ExprKind::IndexAccess(_)) {
            index_count += 1;
        }
    });
    assert_eq!(index_count, 2);
}

#[cfg(feature = "lua51")]
#[test]
fn test_visitor_goto_and_label() {
    // goto/labels are Lua 5.2+, test with lua51 feature that they're rejected
    let input = "::label::\ngoto label";
    let parser = Parser::<luaparse_rs::Lua52>::new(input).unwrap();
    let ast = parser.parse().unwrap();
    let mut goto_count = 0;
    let mut label_count = 0;
    ast.for_each_stmt(|stmt| {
        match &stmt.kind {
            StmtKind::GotoStatement(_) => goto_count += 1,
            StmtKind::LabelStatement(_) => label_count += 1,
            _ => {}
        }
    });
    assert_eq!(goto_count, 1);
    assert_eq!(label_count, 1);
}

#[test]
fn test_visitor_while_loop() {
    let ast = parse_luau("while true do break end");
    let mut while_count = 0;
    let mut break_count = 0;
    ast.for_each_stmt(|stmt| {
        match &stmt.kind {
            StmtKind::WhileLoop(_) => while_count += 1,
            StmtKind::BreakStatement => break_count += 1,
            _ => {}
        }
    });
    assert_eq!(while_count, 1);
    assert_eq!(break_count, 1);
}

#[test]
fn test_visitor_elseif_branches() {
    let ast = parse_luau(
        "if a then\nelseif b then\nelseif c then\nelse\nend",
    );
    let mut elseif_count = 0;
    ast.for_each_stmt(|stmt| {
        if let StmtKind::IfStatement(ref if_stmt) = stmt.kind {
            elseif_count = if_stmt.elseif_branches.len();
        }
    });
    assert_eq!(elseif_count, 2);
}

#[test]
fn test_visitor_mut_walk_all_nodes() {
    struct NoopMut;
    impl VisitorMut for NoopMut {}

    let code = r#"
        local function greet(name: string): string
            return `hello {name}`
        end
        local x = if true then 1 else 2
        export type Foo = { bar: number }
        for i = 1, 10 do
            x += i
        end
        while true do break end
        repeat until false
        do end
    "#;
    let mut ast = parse_luau(code);
    let mut noop = NoopMut;
    noop.visit_ast(&mut ast);
}

#[test]
fn test_visitor_walk_all_nodes_immutable() {
    struct Noop;
    impl Visitor for Noop {}

    let code = r#"
        local function greet(name: string): string
            return `hello {name}`
        end
        local x = if true then 1 else 2
        export type Foo = { bar: number }
        for i = 1, 10 do
            x += i
        end
        for k, v in pairs(t) do end
        while true do break end
        repeat until false
        do end
        a.b.c = 1
        obj:method()
        local t = {a = 1, [2] = 3, 4}
        local y = -x
        local z = not true
        local w = #t
        local p = (1 + 2)
        local q: number = 1 :: number
    "#;
    let ast = parse_luau(code);
    let mut noop = Noop;
    noop.visit_ast(&ast);
}