Exemplo n.º 1
0
 /// <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)))})");
 }
Exemplo n.º 2
0
 /// <inheritdoc/>
 public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens)
 {
     if (tokens.EnumType == null)
     {
         return(TypeNames.IToken);
     }
     else
     {
         return($"{TypeNames.IToken}<{tokens.EnumType.ToDisplayString()}>");
     }
 }
Exemplo n.º 3
0
 /// <inheritdoc/>
 public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens) =>
 this.Reference.GetParsedType(ruleSet, tokens);
Exemplo n.º 4
0
 /// <inheritdoc/>
 public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens) =>
 $"{this.Subexpr.GetParsedType(ruleSet, tokens)}?";
Exemplo n.º 5
0
 /// <inheritdoc/>
 public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens) =>
 $"{TypeNames.IReadOnlyList}<{this.Subexpr.GetParsedType(ruleSet, tokens)}>";
Exemplo n.º 6
0
 /// <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);
Exemplo n.º 7
0
 /// <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) =>
Exemplo n.º 8
0
 /// <inheritdoc/>
 public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens) =>
 this.Elements[0].GetParsedType(ruleSet, tokens);
Exemplo n.º 9
0
        /// <inheritdoc/>
        public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens)
        {
            var called = ruleSet.GetRule(this.Name);

            return(called.Ast.GetParsedType(ruleSet, tokens));
        }
Exemplo n.º 10
0
 /// <inheritdoc/>
 public override string GetParsedType(RuleSet ruleSet, TokenKindSet tokens) =>
 this.Method.ReturnType.ToDisplayString();