using static Generator; public static class ParserGenerator { public static void Main() { Generate( "MixFixGenerated.cs", "using System.Collections.Generic;\n" + "using System.Collections.Immutable;\n" + "using S = Lexer.S;\n" + "using PrecedenceGroupName = System.String;", "public static partial class MixFix {", "}", "MixFix.", Types( // TODO: maybe instead of going through a // Rule node we could just memoize the ToGrammar1 // function, and attach an optional name to nodes Variant("Grammar1", Case("Grammar1", "RepeatOnePlus"), Case("IEnumerable", "Or"), Case("IEnumerable", "Sequence"), Case("S", "Terminal"), Case("ValueTuple", "Annotated"), Case("string", "Rule")), Variant("Grammar2", Case("Grammar2", "RepeatOnePlus"), Case("IEnumerable", "Or"), Case("IEnumerable", "Sequence"), Case("S", "Terminal")), Variant("Fixity", Case("Closed"), Case("InfixLeftAssociative"), Case("InfixRightAssociative"), Case("InfixNonAssociative"), Case("Prefix"), Case("Postfix")), Variant("Associativity", Case("NonAssociative"), Case("LeftAssociative"), Case("RightAssociative")), Record("Operator", Field("PrecedenceGroupName", "precedenceGroup"), Field("Associativity", "associativity"), Field("ImmutableList", "parts")), Variant("Part", Case("S", "Name"), Case("ImmutableHashSet", "Hole")), Record("DAGNode", Field("ImmutableList", "infixLeftAssociative"), Field("ImmutableList", "infixRightAssociative"), Field("ImmutableList", "infixNonAssociative"), Field("ImmutableList", "prefix"), Field("ImmutableList", "postfix"), Field("ImmutableList", "closed")))); } }