/// <inheritdoc/> public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens) { if (this.Elements.Count == 1) { return(this.Elements[0].GetParsedType(ruleSet, tokens)); } return($"({string.Join(", ", this.Elements.Select(e => e.GetParsedType(ruleSet, tokens)))})"); }
/// <inheritdoc/> public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens) { if (tokens.EnumType == null) { return(TypeNames.IToken); } else { return($"{TypeNames.IToken}<{tokens.EnumType.ToDisplayString()}>"); } }
/// <inheritdoc/> public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens) => this.Reference.GetParsedType(ruleSet, tokens);
/// <inheritdoc/> public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens) => $"{this.Subexpr.GetParsedType(ruleSet, tokens)}?";
/// <inheritdoc/> public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens) => $"{TypeNames.IReadOnlyList}<{this.Subexpr.GetParsedType(ruleSet, tokens)}>";
/// <summary> /// Calculates what the result type would be, if parsing the thing this AST describes. /// </summary> /// <param name="ruleSet">The set of available rule definitions.</param> /// <param name="tokens">The set of available token-types.</param> /// <returns>The string that describes the parsed type.</returns> public abstract string GetParsedType(RuleSet ruleSet, TokenKindSet tokens);
/// <summary> /// Parses a BNF grammar text into a <see cref="BnfAst"/>. /// </summary> /// <param name="source">The source text to parse.</param> /// <param name="tokenKinds">The <see cref="TokenKindSet"/> to use when determining what certain identifiers /// should mean (is it a token-type match, or a rule invocation).</param> /// <returns>The pair of the rule name and its <see cref="BnfAst"/>.</returns> public static (string Name, BnfAst?Ast) Parse(string source, TokenKindSet tokenKinds) =>
/// <inheritdoc/> public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens) => this.Elements[0].GetParsedType(ruleSet, tokens);
/// <inheritdoc/> public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens) { var called = ruleSet.GetRule(this.Name); return(called.Ast.GetParsedType(ruleSet, tokens)); }
/// <inheritdoc/> public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens) => this.Method.ReturnType.ToDisplayString();