visitFuncExpr method

  1. @override
GzBaseNode visitFuncExpr(
  1. FuncExpr expr
)
override

Implementation

@override
GzBaseNode visitFuncExpr(FuncExpr expr) {
  final id = switch (expr.id) {
    '' => '<anonymous>',
    final String s => s,
  };

  final args = expr.args
      .map((e) => node(e.id.lexeme, color: 'lightgrey', shape: 'box'))
      .toList();
  final body = expr.body.map((e) => e.accept(this)).toList();

  return node(
    'func $id',
    color: seafoamGreen,
    shape: 'box',
    children: [
      node('stmts', children: body, color: pink),
      node('args', children: args, color: pink),
    ],
  );
}