예제 #1
0
 /// <summary>
 /// Extract LG imports from a file parse tree.
 /// </summary>
 /// <param name="file">LGFile context from antlr parser.</param>
 /// <param name="source">text source.</param>
 /// <returns>lg template list.</returns>
 private static IList <LGImport> ExtractLGImports(LGFileParser.FileContext file, string source = "")
 {
     return(file == null ? new List <LGImport>() :
            file.paragraph()
            .Select(x => x.importDefinition())
            .Where(x => x != null)
            .Select(t => new LGImport(t, source))
            .ToList());
 }
예제 #2
0
 /// <summary>
 /// Extract LG templates from a file parse tree.
 /// </summary>
 /// <param name="file">LGFile context from antlr parser.</param>
 /// <param name="lgfileContent">LGFile content.</param>
 /// <param name="source">text source.</param>
 /// <returns>lg template list.</returns>
 private static IList <LGTemplate> ExtractLGTemplates(LGFileParser.FileContext file, string lgfileContent, string source = "")
 {
     return(file == null ? new List <LGTemplate>() :
            file.paragraph()
            .Select(x => x.templateDefinition())
            .Where(x => x != null)
            .Select(t => new LGTemplate(t, lgfileContent, source))
            .ToList());
 }
예제 #3
0
        private static IList <Diagnostic> GetInvalidTemplateErrors(LGFileParser.FileContext fileContext, string id)
        {
            var errorTemplates = fileContext == null ? new List <LGFileParser.ErrorTemplateContext>() :
                                 fileContext.paragraph()
                                 .Select(x => x.errorTemplate())
                                 .Where(x => x != null);

            return(errorTemplates.Select(u => BuildDiagnostic("error context.", u, id)).ToList());
        }
 /// <summary>
 /// Extract LG options from the parse tree of a file.
 /// </summary>
 /// <param name="file">LG file context from ANTLR parser.</param>
 /// <returns>Option list.</returns>
 private static IList <string> ExtractLGOptions(LGFileParser.FileContext file)
 {
     return(file == null ? new List <string>() :
            file.paragraph()
            .Select(x => x.optionsDefinition())
            .Where(x => x != null)
            .Select(t => ExtractOption(t.GetText()))
            .Where(t => !string.IsNullOrEmpty(t))
            .ToList());
 }
예제 #5
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="LGFileParser.file"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitFile([NotNull] LGFileParser.FileContext context)
 {
 }
예제 #6
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="LGFileParser.file"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitFile([NotNull] LGFileParser.FileContext context)
 {
     return(VisitChildren(context));
 }