home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / CFJava.cab / CFJavaRuntime.cab / allaire / util / template / ExpressionLexer.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-03-31  |  1.4 KB  |  56 lines

  1. package allaire.util.template;
  2.  
  3. import allaire.util.Assert;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.io.StreamTokenizer;
  7. import java.io.StringBufferInputStream;
  8.  
  9. class ExpressionLexer {
  10.    private InputStream m_stream;
  11.    private StreamTokenizer m_lexer;
  12.    private Token m_lookAhead;
  13.  
  14.    public Token read() throws ExpressionException {
  15.       Token var1;
  16.       if (this.m_lookAhead != null) {
  17.          var1 = this.m_lookAhead;
  18.          this.m_lookAhead = null;
  19.       } else {
  20.          int var2;
  21.          try {
  22.             var2 = this.m_lexer.nextToken();
  23.          } catch (IOException var3) {
  24.             Assert.fail("Unexpected IO exception occurred while " + "reading tokens from string.");
  25.             var2 = 0;
  26.          }
  27.  
  28.          var1 = new Token(var2, this.m_lexer);
  29.       }
  30.  
  31.       return var1;
  32.    }
  33.  
  34.    public ExpressionLexer(String var1) {
  35.       this((InputStream)(new StringBufferInputStream(var1)));
  36.    }
  37.  
  38.    public ExpressionLexer(InputStream var1) {
  39.       this.m_stream = var1;
  40.       this.m_lexer = new StreamTokenizer(var1);
  41.       this.m_lexer.eolIsSignificant(false);
  42.       this.m_lexer.ordinaryChar(47);
  43.       this.m_lexer.wordChars(46, 46);
  44.       this.m_lexer.quoteChar(39);
  45.       this.m_lexer.quoteChar(34);
  46.    }
  47.  
  48.    public Token lookAhead() throws ExpressionException {
  49.       if (this.m_lookAhead == null) {
  50.          this.m_lookAhead = this.read();
  51.       }
  52.  
  53.       return this.m_lookAhead;
  54.    }
  55. }
  56.