Package stanfordlogic.gdl

Examples of stanfordlogic.gdl.SymbolTable


{
 
  public void testLexer()
  {
    ByteArrayInputStream input = new ByteArrayInputStream( (new String("hello there")).getBytes() );
    SymbolTable symtab = new SymbolTable();
   
    Lexer l = new Lexer(input, symtab);
   
    assertTrue( l.token() > 255 );
    assertTrue( l.token() > 255 );
    assertEquals( -1, l.token() );
   
    assertEquals(2, symtab.size() );
  }
View Full Code Here


  }
 
  public void testLexer2()
  {
    ByteArrayInputStream input = new ByteArrayInputStream( (new String("(hello there)")).getBytes() );
    SymbolTable symtab = new SymbolTable();
   
    Lexer l = new Lexer(input, symtab);
   
    assertEquals( '(', l.token() );
    int t1 = l.token();
    int t2 = l.token();
    assertTrue( t1 > 255 );
    assertTrue( t2 > 255 );
    assertEquals( ')', l.token() );
    assertEquals( -1, l.token() );
   
    assertEquals(2, symtab.size() );
   
    assertEquals("hello", symtab.get(t1));
    assertEquals("there", symtab.get(t2));
  }
View Full Code Here

  }
 
  public void testLexer3()
  {
    ByteArrayInputStream input = new ByteArrayInputStream( (new String("(hello% there)")).getBytes() );
    SymbolTable symtab = new SymbolTable();
   
    Lexer l = new Lexer(input, symtab);
   
    // Make sure that we get an exception
   
View Full Code Here

  }
   
    public void testLexer4()
    {
        ByteArrayInputStream input = new ByteArrayInputStream( (new String(";; this is\n(hello there) ;; a\n;; comment\n")).getBytes() );
        SymbolTable symtab = new SymbolTable();
       
        Lexer l = new Lexer(input, symtab);
       
        assertEquals( '(', l.token() );
        int t1 = l.token();
        int t2 = l.token();
        assertTrue( t1 > 255 );
        assertTrue( t2 > 255 );
        assertEquals( ')', l.token() );
        assertEquals( -1, l.token() );
       
        assertEquals(2, symtab.size() );
       
        assertEquals("hello", symtab.get(t1));
        assertEquals("there", symtab.get(t2));
    }
View Full Code Here

TOP

Related Classes of stanfordlogic.gdl.SymbolTable

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.