예제 #1
0
파일: Main.cs 프로젝트: 0xb1dd1e/boo
 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);
   }
 }
예제 #2
0
파일: Main.cs 프로젝트: dilawar/ahir
 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);
     }
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
        }
예제 #5
-1
        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;
        }