public static void Main(string[] args) { try { HTMLLexer lexer = new HTMLLexer(new ByteBuffer(Console.OpenStandardInput())); TokenBuffer buffer = new TokenBuffer(lexer); HTMLParser parser = new HTMLParser(buffer); parser.document(); } catch(Exception e) { Console.Error.WriteLine("exception: "+e); Environment.Exit(1); } }
public static void Main(string[] args) { try { HTMLLexer lexer = new HTMLLexer(new ByteBuffer(Console.OpenStandardInput())); TokenBuffer buffer = new TokenBuffer(lexer); HTMLParser parser = new HTMLParser(buffer); parser.document(); } catch (Exception e) { Console.Error.WriteLine("exception: " + e); Environment.Exit(1); } }
public void VisitorTest() { try { string input = "<html><title>blahg blah blah</title><p>para graph</p><p>second para</p></html>"; StringBuilder text = new StringBuilder(input); Console.WriteLine(input); var inputStream = new AntlrInputStream(text.ToString()); var htmlLexer = new HTMLLexer(inputStream); var commonTokenStream = new CommonTokenStream(htmlLexer); var htmlParser = new HTMLParser(commonTokenStream); var htmlContext = htmlParser.htmlDocument(); var visitor = new HTMLVisitor(); visitor.Visit(htmlContext); } catch (Exception ex) { Console.WriteLine("Error: " + ex); } }
public void Parse(Stream stream, Action <string> callback) { var inputStream = new AntlrInputStream(stream); var lexer = new HTMLLexer(inputStream); lexer.RemoveErrorListeners(); var tokenStream = new CommonTokenStream(lexer); var parser = new HTMLParser(tokenStream); parser.RemoveErrorListeners(); var context = parser.htmlDocument(); var listener = new HTMLKeywordParserListener() { Emit = (x) => callback(x), MinimumLength = MinimumLength, MaximumLength = MaximumLength, IncludeChardata = IncludeChardata, IncludeComments = IncludeComments }; var walker = new ParseTreeWalker(); walker.Walk(listener, context); }
public static HtmlParseResults InvokeParse(Stream stream) { var input = new AntlrInputStream(stream); var lexer = new HTMLLexer(input); var tokens = new CommonTokenStream(lexer); var parser = new HTMLParser(tokens); var tree = parser.htmlDocument(); var walker = new ParseTreeWalker(); var loader = new AspNetParseTree(); walker.Walk(loader, tree); return loader.Results; }