home *** CD-ROM | disk | FTP | other *** search
- package allaire.util.template;
-
- import allaire.util.Assert;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.StreamTokenizer;
- import java.io.StringBufferInputStream;
-
- class ExpressionLexer {
- private InputStream m_stream;
- private StreamTokenizer m_lexer;
- private Token m_lookAhead;
-
- public Token read() throws ExpressionException {
- Token var1;
- if (this.m_lookAhead != null) {
- var1 = this.m_lookAhead;
- this.m_lookAhead = null;
- } else {
- int var2;
- try {
- var2 = this.m_lexer.nextToken();
- } catch (IOException var3) {
- Assert.fail("Unexpected IO exception occurred while " + "reading tokens from string.");
- var2 = 0;
- }
-
- var1 = new Token(var2, this.m_lexer);
- }
-
- return var1;
- }
-
- public ExpressionLexer(String var1) {
- this((InputStream)(new StringBufferInputStream(var1)));
- }
-
- public ExpressionLexer(InputStream var1) {
- this.m_stream = var1;
- this.m_lexer = new StreamTokenizer(var1);
- this.m_lexer.eolIsSignificant(false);
- this.m_lexer.ordinaryChar(47);
- this.m_lexer.wordChars(46, 46);
- this.m_lexer.quoteChar(39);
- this.m_lexer.quoteChar(34);
- }
-
- public Token lookAhead() throws ExpressionException {
- if (this.m_lookAhead == null) {
- this.m_lookAhead = this.read();
- }
-
- return this.m_lookAhead;
- }
- }
-