Package org.jwall.log.io

Examples of org.jwall.log.io.ParserGenerator$Token


  public void setTokenStopIndex(int index) {
  }

  public String toString() {
    if ( payload instanceof Token ) {
      Token t = (Token)payload;
      if ( t.getType() == Token.EOF ) {
        return "<EOF>";
      }
      return t.getText();
    }
    return payload.toString();
  }
View Full Code Here


   */
  public String toStringWithHiddenTokens() {
    StringBuffer buf = new StringBuffer();
    if ( hiddenTokens!=null ) {
      for (int i = 0; i < hiddenTokens.size(); i++) {
        Token hidden = (Token) hiddenTokens.get(i);
        buf.append(hidden.getText());
      }
    }
    String nodeText = this.toString();
    if ( !nodeText.equals("<EOF>") ) buf.append(nodeText);
    return buf.toString();
View Full Code Here

    }

    // Wildcard?
    if ( ttype == TreePatternLexer.DOT ) {
      ttype = tokenizer.nextToken();
      Token wildcardPayload = new CommonToken(0, ".");
      TreeWizard.TreePattern node =
        new TreeWizard.WildcardTreePattern(wildcardPayload);
      if ( label!=null ) {
        node.label = label;
      }
View Full Code Here

    Tree t = (Tree)create(fromToken);
    return t;
  }

  public Object create(int tokenType, String text) {
    Token fromToken = createToken(tokenType, text);
    Tree t = (Tree)create(fromToken);
    return t;
  }
View Full Code Here

  public void consume() {
    if ( initialStreamState ) {
      consumeInitialHiddenTokens();
    }
    int a = input.index();
    Token t = input.LT(1);
    input.consume();
    int b = input.index();
    dbg.consumeToken(t);
    if ( b>a+1 ) {
      // then we consumed more than one token; must be off channel tokens
View Full Code Here

    super(adaptor, elementDescription, elements);
  }

  /** Get next token from stream and make a node for it */
  public Object nextNode() {
    Token t = (Token)_next();
    return adaptor.create(t);
  }
View Full Code Here

  }
*/
  public void process() throws IOException {
    CharStream input = new ANTLRFileStream(dispelFile);
    DISPEL lexer = new DISPEL(input);
    Token token;
    while ((token = lexer.nextToken()) != Token.EOF_TOKEN) {
      tp.process(token);
    }
  }
View Full Code Here

    CharStream input;
    try {
      input = new ANTLRInputStream(is);
     
      DISPEL lexer = new DISPEL(input);
      Token token;
       
        while ((token = lexer.nextToken()).getType() !=
          org.antlr.runtime3_3_0.Token.EOF) {
   
          tp.process(token);
View Full Code Here

    @Test
    public void testCreate() throws Exception
    {
        String grammar = "%{REMOTE_ADDR}\" %{REMOTE_PORT} TEST [ABC] %{ABC}";
        String input = "127.0.0.1\" 80 TEST [ABC] abc-value";
        ParserGenerator gen = new ParserGenerator( grammar );

        Parser<Map<String,String>> parser = gen.newParser();
        Map<String,String> msg = parser.parse( input );
        log.info( "Message parsed is: {}", msg );
        for( String key : msg.keySet() ){
            log.info( "  {} = {}", key, msg.get( key ) );
        }
View Full Code Here

    @Test
    public void testAccessLogCombined() throws Exception {
        String input = "www-ai.cs.uni-dortmund.de www-ai.cs.uni-dortmund.de 66.249.72.167 - - [08/Jul/2011:00:01:29 +0200] \"GET /FUNSTUFF/JAI/index.html HTTP/1.1\" 200 3487 \"-\" \"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\"";
        String grammar = "%{REQUEST_HEADERS:Host} %{VHOST_NAME} %{REMOTE_ADDR} %{REMOTE_USER} %{TMP} [%{DATE}] \"%{REQUEST_METHOD} %{REQUEST_URI} %{PROTO}\" %{RESPONSE_STATUS} %{RESPONSE_SIZE} \"%{REQUEST_HEADERS:Referer}\" \"%{REQUEST_HEADERS:User-Agent}\"";
       
        ParserGenerator gen = new ParserGenerator( grammar );
        Map<String,String> map = gen.parse( input );
        for( String key : map.keySet() ){
            log.info( " '{}' = '{}'", key, map.get( key ) );
        }
       
        List<String> grams = gen.parseGrammar( grammar );
        for( String g : grams ){
            log.info( "{}", g );
        }
    }
View Full Code Here

TOP

Related Classes of org.jwall.log.io.ParserGenerator$Token

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.