27 instantiations of Production
CSharpSyntaxGenerator (27)
Grammar\GrammarGenerator.cs (27)
78rules[name] = [new("/* see lexical specification */")];
168rules.Add("UnderscoreCharacter", [Text("_"), new("""'\\u005' /* unicode_escape_sequence for underscore */""")]);
170new("""/* [\p{L}\p{Nl}] category letter, all subcategories; category number, subcategory letter */"""),
171new("unicode_escape_sequence /* only escapes for categories L & Nl allowed */")]);
174new("""/* [\p{Mn}\p{Mc}] category Mark, subcategories non-spacing and spacing combining */"""),
175new("unicode_escape_sequence /* only escapes for categories Mn & Mc allowed */")]);
178new("""/* [\p{Nd}] category number, subcategory decimal digit */"""),
179new("unicode_escape_sequence /* only escapes for category Nd allowed */")]);
182new("""/* [\p{Pc}] category Punctuation, subcategory connector */"""),
183new("unicode_escape_sequence /* only escapes for category Pc allowed */")]);
186new("""/* [\p{Cf}] category Other, subcategory format. */"""),
187new("unicode_escape_sequence /* only escapes for category Cf allowed */")]);
244rules.Add("SingleRegularStringLiteralCharacter", [new("""/* ~["\\\u000D\u000A\u0085\u2028\u2029] anything but ", \, and new_line_character */""")]);
248rules.Add("SingleVerbatimStringLiteralCharacter", [new("/* anything but quotation mark (U+0022) */")]);
252rules.Add("InterpolatedMultiLineRawStringStartToken", [new(""""'$'+ '"""' '"'*"""")]);
253rules.Add("InterpolatedRawStringEndToken", [new(""""'"""' '"'* /* must match number of quotes in raw_string_start_token */"""")]);
254rules.Add("InterpolatedSingleLineRawStringStartToken", [new(""""'$'+ '"""' '"'*"""")]);
261rules.Add("SingleCharacter", [new("""/* ~['\\\u000D\u000A\u0085\u2028\u2029] anything but ', \\, and new_line_character */""")]);
300=> strings.Select(s => new Production($"""'{Escape(s)}'""")).ToList();
306=> new($"'{Escape(value)}'");
309=> new(string.Join(delim, productions.Where(p => p.Text.Length > 0)), productions.SelectMany(p => p.ReferencedRules));
329=> field.Type == "bool" ? new Production("") :
356tokenName.StartsWith("EndOf") ? new Production("") :
357tokenName.StartsWith("Omitted") ? new Production("/* epsilon */") : RuleReference(tokenName);
366=> new(
384public Production Prefix(string prefix) => new(prefix + this, ReferencedRules);
385public Production Suffix(string suffix, bool when = true) => when ? new(this + suffix, ReferencedRules) : this;
41 references to Production
CSharpSyntaxGenerator (41)
Grammar\GrammarGenerator.cs (41)
24var rules = types.ToDictionary(n => n.Name, _ => new List<Production>());
114foreach (var production in sorted)
122private static void AddLexicalRules(Dictionary<string, List<Production>> rules)
136var utf8Suffix = Choice(anyCasing("U8"));
192var decimalDigitPlus = RuleReference("DecimalDigit").OneOrMany;
193var exponentPart = RuleReference("ExponentPart");
194var exponentPartOpt = exponentPart.Optional;
195var realTypeSuffix = RuleReference("RealTypeSuffix");
196var realTypeSuffixOpt = realTypeSuffix.Optional;
216var decimalDigit = RuleReference("DecimalDigit");
217var decimalDigitPlus = decimalDigit.OneOrMany;
218var integerTypeSuffixOpt = RuleReference("IntegerTypeSuffix").Optional;
230var hexDigit = RuleReference("HexadecimalDigit");
231var hexDigitOpt = hexDigit.Optional;
264IEnumerable<Production> productionRange(char start, char end)
270IEnumerable<Production> repeat(Production production, int count)
273IEnumerable<Production> anyCasing(string value)
299private static List<Production> JoinWords(IEnumerable<string> strings)
305private static Production Text(string value)
308private static Production Join(IEnumerable<Production> productions, string delim)
311private static Production ToProduction(TreeTypeChild child)
320private static Production Choice(IEnumerable<Production> productions, bool parenthesize = true)
323private static Production Sequence(IEnumerable<Production> productions)
326private static Production HandleField(Field field)
335private static Production HandleSeparatedList(Field field, string elementType)
341private static Production HandleList(Field field, string elementType)
348private static Production HandleTokenField(Field field)
353private static Production HandleTokenName(string tokenName)
365private static Production RuleReference(string name)
377string text, IEnumerable<string> referencedRules = null) : IComparable<Production>
383public int CompareTo(Production other) => StringComparer.OrdinalIgnoreCase.Compare(this.Text, other.Text);
384public Production Prefix(string prefix) => new(prefix + this, ReferencedRules);
385public Production Suffix(string suffix, bool when = true) => when ? new(this + suffix, ReferencedRules) : this;
386public Production Parenthesize(bool when = true) => when ? Prefix("(").Suffix(")") : this;
387public Production Optional => Suffix("?");
388public Production ZeroOrMany => Suffix("*");
389public Production OneOrMany => Suffix("+");