Пример #1
0
        /// <summary>
        /// Process the file
        /// </summary>
        /// <param name="FileName">File to parse</param>
        /// <returns><see cref="BBSCodeResult"/> with processed data</returns>
        public BBSCodeResult GetProcessed(string FileName)
        {
            BBSCodeResult ret = new BBSCodeResult();
            Stream        stream;

            if (TextHelpers.TextHelper.IsUrl(FileName))
            {
                WebClient webClient = new WebClient();
                stream = webClient.OpenRead(FileName);
            }
            else
            {
                stream = File.OpenRead(FileName);
            }

            using (StreamReader fileStream = new StreamReader(stream))
            {
                AntlrInputStream  inputStream = new AntlrInputStream(fileStream);
                BBSCodeLexer      lexer       = new BBSCodeLexer(inputStream);
                CommonTokenStream tokenStream = new CommonTokenStream(lexer);
                BBSCodeParser     parser      = new BBSCodeParser(tokenStream);
                BBSCodeParser.BbsCodeContentContext context = parser.bbsCodeContent();
                BBSCodeListener listener = new BBSCodeListener(client, server, FileName);
                ParseTreeWalker walker   = new ParseTreeWalker();
                bool            built    = parser.BuildParseTree;
                walker.Walk(listener, context);
                ret = listener.Parsed;
            }
            return(ret);
        }
Пример #2
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="BBSCodeParser.bbsCodeContent"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitBbsCodeContent([NotNull] BBSCodeParser.BbsCodeContentContext context)
 {
 }