private static IEnumerable <TopLevelStatement> Build(ScLangParser.TopLevelStatementContext context) { switch (context) { case ScLangParser.StaticVariableStatementContext c: foreach (var decl in Build(c.declaration())) { yield return(new StaticVariableStatement(decl, Source(c))); } break; case ScLangParser.ConstantVariableStatementContext c: foreach (var decl in Build(c.declaration())) { yield return(new ConstantVariableStatement(decl, Source(c))); } break; default: yield return(BuildOne(context)); break; } }
private static TopLevelStatement BuildOne(ScLangParser.TopLevelStatementContext context) => context switch {