Example #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);
        }
Example #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="c">Reference to the client</param>
        /// <param name="s">Reference to the server</param>
        /// <param name="filename">Name of the parsed file</param>
        public BBSCodeListener(IBBSClient c, IServer s, string filename) : base()
        {
            Client   = c;
            Server   = s;
            FileName = filename;

            Parsed          = new BBSCodeResult();
            TagsTable       = new TagsDict();
            EntitiesTable   = new EntitiesDict(Client);
            AttributesTable = new AttributesDict();
            ANSI            = new ANSICodes();
        }