org.eclipse.ocl.lpg
Class AbstractLexer

java.lang.Object
  extended by org.eclipse.ocl.lpg.AbstractLexer
Direct Known Subclasses:
OCLBacktrackingLexer, OCLLexer

public abstract class AbstractLexer
extends java.lang.Object

The AbstractLexer supports lexical analysis of keyword tokens produced by a keyword lexer to create syntactic tokens for an AbstractLexer that creates a corresponding CST, that may in turn be exploited by an AbstractAnalyzer to create an AST. Derived classes should extend the abstract support for AST from CST from tokens from text parsing and analysis to support the AST and CST classes appropriate to a particular language.


Constructor Summary
AbstractLexer(BasicEnvironment environment)
           
 
Method Summary
 BasicEnvironment getEnvironment()
           
abstract  DerivedLexStream getILexStream()
           
static char[] getInputChars(java.io.Reader reader)
          Read all input characters from a reader.
abstract  int[] getKeywordKinds()
          Queries the token kinds, as defined by my keyword lexer, of tokens that are keywords in by grammar.
abstract  lpg.runtime.ILexStream getLexStream()
           
abstract  lpg.runtime.LexParser getParser()
           
abstract  lpg.runtime.ParseTable getParseTable()
           
 void initialize(char[] inputChars)
          Deprecated. clients should use reset(char[], String)
 void initialize(java.io.Reader reader)
          Deprecated. clients should invoke reset(Reader, String)
abstract  void lexer(DerivedPrsStream prsStream)
          Runs the lexer's with the provided parseStream
abstract  void lexer(DerivedPrsStream prsStream, int start_offset, int end_offset)
          Runs the lexer's with the provided parseStream in specific offset of the input
abstract  void lexer(lpg.runtime.Monitor monitor, DerivedPrsStream prsStream)
          Runs the lexer's with the provided parseStream and the given monitor.
abstract  void lexer(lpg.runtime.Monitor monitor, DerivedPrsStream prsStream, int start_offset, int end_offset)
          Runs the lexer's with the provided parseStream in specific offset of the input
 void lexToTokens(AbstractParser parser)
          Deprecated. clients should invoke lexer(DerivedPrsStream)
 void lexToTokens(lpg.runtime.Monitor monitor, AbstractParser parser)
          Deprecated. clients should invoke lexer(Monitor, DerivedPrsStream)
abstract  void reportLexicalError(int startLoc, int endLoc)
          Report a lexical error in the given localization (start and end offset)
abstract  void reset(char[] input_chars, java.lang.String filename)
          Resets the lexer's input with the given char's array.
abstract  void reset(char[] input_chars, java.lang.String filename, int tab)
          Resets the lexer's input with the given char's array.
abstract  void reset(java.io.Reader reader, java.lang.String filename)
          Resets the lexer's input with the given Reader
abstract  void resetKeywordLexer()
          Rsets the lexer's keywordLexer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractLexer

public AbstractLexer(BasicEnvironment environment)
Method Detail

getInputChars

public static char[] getInputChars(java.io.Reader reader)
                            throws java.io.IOException
Read all input characters from a reader.

Parameters:
reader - providing the source text
Returns:
the input characters
Throws:
java.io.IOException - if reading fails

getEnvironment

public BasicEnvironment getEnvironment()

initialize

@Deprecated
public void initialize(char[] inputChars)
Deprecated. clients should use reset(char[], String)

Define the input text as a given array of characters.

Parameters:
inputChars - the characters

initialize

@Deprecated
public void initialize(java.io.Reader reader)
                throws java.io.IOException
Deprecated. clients should invoke reset(Reader, String)

Define the input text by reading from a reader.

Parameters:
reader - providing the source text
Throws:
java.io.IOException - if reading fails

lexToTokens

@Deprecated
public void lexToTokens(AbstractParser parser)
Deprecated. clients should invoke lexer(DerivedPrsStream)

Parameters:
parser - the AbstractParser instance

lexToTokens

@Deprecated
public void lexToTokens(lpg.runtime.Monitor monitor,
                                   AbstractParser parser)
Deprecated. clients should invoke lexer(Monitor, DerivedPrsStream)

Parameters:
parser - the AbstractParser instance

getKeywordKinds

public abstract int[] getKeywordKinds()
Queries the token kinds, as defined by my keyword lexer, of tokens that are keywords in by grammar.

Returns:
my keyword lexer's token kinds
Since:
1.3

getILexStream

public abstract DerivedLexStream getILexStream()
Returns:
the lexers's lexStream
Since:
3.0

reset

public abstract void reset(char[] input_chars,
                           java.lang.String filename)
Resets the lexer's input with the given char's array.

Parameters:
input_chars - the new lexer's input
filename - a file name used for logging when encountering errors/warnings
Since:
3.0

reset

public abstract void reset(char[] input_chars,
                           java.lang.String filename,
                           int tab)
Resets the lexer's input with the given char's array.

Parameters:
input_chars - the new lexer's input
filename - a file name used for logging when encountering errors/warnings
tab - lexer's tab length.
Since:
3.0

reset

public abstract void reset(java.io.Reader reader,
                           java.lang.String filename)
                    throws java.io.IOException
Resets the lexer's input with the given Reader

Parameters:
reader - the new lexer's input
filename - a file name used for logging when encountering errors/warnings
Throws:
java.io.IOException
Since:
3.0

lexer

public abstract void lexer(DerivedPrsStream prsStream)
Runs the lexer's with the provided parseStream

Parameters:
prsStream - the associated parseStream
Since:
3.0

lexer

public abstract void lexer(lpg.runtime.Monitor monitor,
                           DerivedPrsStream prsStream)
Runs the lexer's with the provided parseStream and the given monitor.

Parameters:
monitor - the Monitor
prsStream - the associated parseStream
Since:
3.0

lexer

public abstract void lexer(DerivedPrsStream prsStream,
                           int start_offset,
                           int end_offset)
Runs the lexer's with the provided parseStream in specific offset of the input

Parameters:
prsStream - the associated parseStream
start_offset - the start offset
end_offset - the end offset
Since:
3.0

lexer

public abstract void lexer(lpg.runtime.Monitor monitor,
                           DerivedPrsStream prsStream,
                           int start_offset,
                           int end_offset)
Runs the lexer's with the provided parseStream in specific offset of the input

Parameters:
prsStream - the associated parseStream
start_offset - the start offset
end_offset - the end offset
Since:
3.0

getParseTable

public abstract lpg.runtime.ParseTable getParseTable()
Returns:
the lexer's ParseTable
Since:
3.0

getParser

public abstract lpg.runtime.LexParser getParser()
Returns:
the lexer's LexParser
Since:
3.0

resetKeywordLexer

public abstract void resetKeywordLexer()
Rsets the lexer's keywordLexer

Since:
3.0

getLexStream

public abstract lpg.runtime.ILexStream getLexStream()
Returns:
the lexer's lexStream
Since:
3.0

reportLexicalError

public abstract void reportLexicalError(int startLoc,
                                        int endLoc)
Report a lexical error in the given localization (start and end offset)

Parameters:
startLoc - the offset the error starts
endLoc - the offset the error ends.
Since:
3.0