All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class epp.Lex

java.lang.Object
   |
   +----epp.Lex

public class Lex
extends Object
The Lex.java file defines methods of the EPP preprocessor that are used for lexical analyzation of the Java language.

Note: This class is provided for the sake of creating javadocs. It does not exist in the actual EPP source code.

The parser calls the lexical analyzer indirectly using the methods match and matchAny.

When a new token is required by a call to methods match or matchAny, the readToken method is called. This method other methods if required, and cutouts a token from EppInputStream and returns that token.

Plug-ins may extend this method to modify the behaviour of the lexical analyzer. For example, in standard Java, the string "**" will be analyzed as two :"*" Symbols. If you want to extend this so that the string will be analyzed as a single :"**" Symbol, you would write as follows.

SystemMixin NewOp {
  class Epp {
    extend Token readOperator(EppInputStream in){
      if (in.peekc() == '*') {
        int p = in.pointer();
        in.getc();
        if (in.getc() == '*') {
           return :"**";
        }
        in.backtrack(p);
        return original(in);
      } else {
        return original(in);
      }
    }
  }
}

See Also:
EppInputStream, match, matchAny, readToken

Constructor Index

 o Lex()

Method Index

 o readCharLiteral(EppInputStream)
Called from readOperator when the first character of the token is a single quote and returns a string literal.
 o readEndOfLineComment(EppInputStream)
Skips comments beginning with "//" and returns the next token.
 o readEscapedChar(EppInputStream, StringBuffer, char)
Handles escape sequences such as "\"".
 o readId(EppInputStream)
Reads the an identifier or keyword (if, while, etc.) and returns it as a symbol.
 o readNumber(EppInputStream)
Reads and returns a number literal.
 o readOperator(EppInputStream)
Called when the first character of the token is a symbol.
 o readSharp(EppInputStream)
Processes a token beginning with "#".
 o readStringLiteral(EppInputStream)
Called from readOperator when the first character of the token is a double quote and returns a string literal.
 o readTokenAtNextLine(EppInputStream)
Ignores the rest of the line, reads a token from the next line and returns that token.
 o readTokenStart(EppInputStream)
Reads and returns a single token from argument in.
 o readTraditionalComment(EppInputStream)
Skips comments beginning with "/*" and returns the next token.

Constructors

 o Lex
 public Lex()

Methods

 o readTokenStart
 public Token readTokenStart(EppInputStream in)
Reads and returns a single token from argument in. Assumes that space characters are already skipped. Peeks at the first character and calls readId, readNumber, readOperator depending on whether the the value is an alphabet, number, or symbol. This method is call from readToken.

See Also:
readToken
 o readId
 public Token readId(EppInputStream in)
Reads the an identifier or keyword (if, while, etc.) and returns it as a symbol. Called when the first character of the token is an alphabet.

 o readNumber
 public Token readNumber(EppInputStream in)
Reads and returns a number literal. Called from readTokenStart when the first character of the token is a number. However, in such case where the token is ".1", readTokenStart calls readOperator, and then this method is called.

 o readOperator
 public Token readOperator(EppInputStream in)
Called when the first character of the token is a symbol. Calls other methods such as readTraditional if required.

 o readStringLiteral
 public Token readStringLiteral(EppInputStream in)
Called from readOperator when the first character of the token is a double quote and returns a string literal.

 o readCharLiteral
 public Token readCharLiteral(EppInputStream in)
Called from readOperator when the first character of the token is a single quote and returns a string literal.

 o readEscapedChar
 public void readEscapedChar(EppInputStream in,
                             StringBuffer buf,
                             char c)
Handles escape sequences such as "\"". Called from readStringLiteral and readCharLiteral.

 o readTraditionalComment
 public Token readTraditionalComment(EppInputStream in)
Skips comments beginning with "/*" and returns the next token. The two characters "/*" are assumed already consumed when this method is called.

 o readEndOfLineComment
 public Token readEndOfLineComment(EppInputStream in)
Skips comments beginning with "//" and returns the next token. The two characters "//" are assumed already consumed when this method is called.

 o readSharp
 public Token readSharp(EppInputStream in)
Processes a token beginning with "#". The character "#" is assumed already consumed when this method is called. By default, this method calls the readTokenAtNextLine method. (In order to skip the #epp command.)

 o readTokenAtNextLine
 public Token readTokenAtNextLine(EppInputStream in)
Ignores the rest of the line, reads a token from the next line and returns that token. This method is called from readEndOfLineComment and readSharp.


All Packages  Class Hierarchy  This Package  Previous  Next  Index