Package org.allspice.parser.parsetable

Examples of org.allspice.parser.parsetable.TokenStream


public class TestJavaTokenizer extends TestCase {
  public TokenStream makeTokenizer(String s) {
    return new JavaTokenizer(new StringReader(s)) ;
  }
  public void testfoo() throws SyntaxError {
    TokenStream tok = makeTokenizer("+") ;
    {
      Token t = tok.next() ;
      assertEquals(t.name,"+") ;
    }
  }
View Full Code Here


      assertEquals(t.name,"+") ;
    }
  }

  public void test0() throws SyntaxError {
    TokenStream tok = makeTokenizer("'1' \"1\" \"ab\\\"c\" \"ab\\nc\" '\\u0123' '\\067' '\\''") ;
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Character.valueOf('1')) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,"1") ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,"ab\"c") ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,"ab\nc") ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Character.valueOf('\u0123')) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Character.valueOf('\067')) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Character.valueOf('\'')) ;
    }
  }
View Full Code Here

      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Character.valueOf('\'')) ;
    }
  }
  public void test5() throws SyntaxError {
    TokenStream tok = makeTokenizer("1 2L 0xa 0xaL 0 0XA 010") ;
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Integer.valueOf(1)) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Long.valueOf(2)) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Integer.valueOf(10)) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Long.valueOf(10)) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Integer.valueOf(0)) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Integer.valueOf(10)) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Integer.valueOf(010)) ;
    }
  }
View Full Code Here

      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Integer.valueOf(010)) ;
    }
  }
  public void test7() throws SyntaxError {
    TokenStream tok = makeTokenizer("1.1 2F 2D .1 1.") ;
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Double.valueOf(1.1)) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Float.valueOf(2)) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Double.valueOf(2)) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Double.valueOf(.1)) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Double.valueOf(1.)) ;
    }
  }
View Full Code Here

      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Double.valueOf(1.)) ;
    }
  }
  public void test6() throws SyntaxError {
    TokenStream tok = makeTokenizer("true false null") ;
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Boolean.TRUE) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertEquals(t.value,Boolean.FALSE) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
      assertNull(t.value) ;
    }
  }
View Full Code Here

      assertEquals(t.name,JavaTokens.CONST) ;
      assertNull(t.value) ;
    }
  }
  public void testKey(String key) throws SyntaxError {
    TokenStream tok = makeTokenizer(key) ;
    {
      Token t = tok.next() ;
      assertEquals(t.name,key) ;
      assertEquals(t.value,key) ;
    }
  }
View Full Code Here

      assertEquals(t.name,key) ;
      assertEquals(t.value,key) ;
    }
  }
  public void test1() throws SyntaxError {
    TokenStream tok = makeTokenizer("abc") ;
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.ID) ;
      assertEquals(t.value,"abc") ;
    }
    testKey(JavaTokens.RETURN) ;
    testKey(JavaTokens.SYNCHRONIZED) ;
View Full Code Here

    testKey(JavaTokens.IMPORT) ;
    testKey(JavaTokens.PACKAGE) ;
    testKey(JavaTokens.THROWS) ;
  }
  public void test2() throws SyntaxError {
    TokenStream tok = makeTokenizer("+ = +=") ;
    {
      Token t = tok.next() ;
      assertEquals(t.name,"+") ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,"=") ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,"+=") ;
    }
  }
View Full Code Here

      Token t = tok.next() ;
      assertEquals(t.name,"+=") ;
    }
  }
  public void test3() throws SyntaxError {
    TokenStream tok = makeTokenizer("5 [  ] [ 5 ]") ;
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,"[]") ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,"[") ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,JavaTokens.CONST) ;
    }
    {
      Token t = tok.next() ;
      assertEquals(t.name,"]") ;
    }
  }
View Full Code Here

      Token t = tok.next() ;
      assertEquals(t.name,"]") ;
    }
  }
  public void test4() throws SyntaxError {
    TokenStream tok = makeTokenizer("/** comment *********/ [  /* trick */ ]") ;
    {
      Token t = tok.next() ;
      assertEquals(t.name,"[]") ;
    }
  }
View Full Code Here

TOP

Related Classes of org.allspice.parser.parsetable.TokenStream

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.