## org.eclipse.ocl.lpg
Class AbstractLexer

    java.lang.Object
      lpg.lpgjavaruntime.LexStream
          lpg.lpgjavaruntime.LpgLexStream
              org.eclipse.ocl.lpg.AbstractLexer

All Implemented Interfaces:
  lpg.lpgjavaruntime.ParseErrorCodes, lpg.lpgjavaruntime.RuleAction, lpg.lpgjavaruntime.TokenStream

Direct Known Subclasses:
  OCLBacktrackingLexer, OCLLexer

    public abstract class AbstractLexer

extends lpg.lpgjavaruntime.LpgLexStream
implements lpg.lpgjavaruntime.RuleAction

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.

Field Summary
`protected static int` `ECLIPSE_TAB_VALUE`

Fields inherited from interface lpg.lpgjavaruntime.ParseErrorCodes
`BEFORE_CODE, DELETION_CODE, EOF_CODE, ERROR_CODE, errorMsgText, INSERTION_CODE, INVALID_CODE, INVALID_TOKEN_CODE, LEX_ERROR_CODE, MERGE_CODE, MISPLACED_CODE, SCOPE_CODE, SECONDARY_CODE, SUBSTITUTION_CODE`

Constructor Summary
`AbstractLexer(BasicEnvironment environment)`
`AbstractLexer(BasicEnvironment environment, char[] input_chars, String filename, int tab)`
`AbstractLexer(BasicEnvironment environment, String filename, int tab)`

Method Summary
`protected int` `computeErrorCode(int leftToken, int rightToken)`
`BasicEnvironment` `getEnvironment()`
`static char[]` `getInputChars(Reader reader)` Read all input characters from a reader.
`int[]` `getKeywordKinds()` Queries the token kinds, as defined by my keyword lexer, of tokens that are keywords in by grammar.
`void` `initialize(char[] inputChars)` Define the input text as a given array of characters.
`void` `initialize(Reader reader)` Define the input text by reading from a reader.
`void` `lexToTokens(AbstractParser parser)`
`abstract void` `lexToTokens(lpg.lpgjavaruntime.Monitor monitor, AbstractParser parser)`
`void` `reportError(int leftToken, int rightToken)` Errors generated within the lexer are redirected to the error handler if there is one.

Methods inherited from class lpg.lpgjavaruntime.LpgLexStream
`getKind, orderedExportedSymbols`

Methods inherited from class lpg.lpgjavaruntime.LexStream

`afterEol, badToken, computeLineOffsets, getCharValue, getColumn, getColumnOfCharAt, getEndColumn, getEndLine, getFileName, getFirstErrorToken, getInputChars, getLastErrorToken, getLine, getLine, getLineCount, getLineNumberOfCharAt, getLineOffset, getLineOffsets, getName, getNext, getPrevious, getPrsStream, getStreamIndex, getStreamLength, getTab, getToken, getToken, initialize, initialize, makeErrorToken, makeToken, peek, reportError, reportError, reportError, reset, reset, setFileName, setInputChars, setLineOffset, setLineOffsets, setPrsStream, setStreamIndex, setStreamLength, setTab`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface lpg.lpgjavaruntime.RuleAction
`ruleAction`

Field Detail

### ECLIPSE_TAB_VALUE

    protected static final int ECLIPSE_TAB_VALUE

See Also:
  Constant Field Values

Constructor Detail

### AbstractLexer

    public AbstractLexer(BasicEnvironment environment,
                         String filename,
                         int tab)
                  throws IOException

Throws:
  `IOException`

### AbstractLexer

    public AbstractLexer(BasicEnvironment environment,
                         char[] input_chars,
                         String filename,
                         int tab)

### AbstractLexer

    public AbstractLexer(BasicEnvironment environment)

Method Detail

### getInputChars

    public static char[] getInputChars(Reader reader)
                                throws IOException

  Read all input characters from a reader.

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

### computeErrorCode

    protected int computeErrorCode(int leftToken,
                                   int rightToken)

### getEnvironment

    public BasicEnvironment getEnvironment()

### getKeywordKinds

    public 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

### lexToTokens

    public void lexToTokens(AbstractParser parser)

### lexToTokens

    public abstract void lexToTokens(lpg.lpgjavaruntime.Monitor monitor,
                                     AbstractParser parser)

### reportError

    public void reportError(int leftToken,
                            int rightToken)

  Errors generated within the lexer are redirected to the error handler if there is one. Note that other variants of reportError either feed this one, are fed from a default implementation of this one or originate in the parser, where a ParserErrorHandler can intercept them.

  Specified by:
    `reportError` in interface `lpg.lpgjavaruntime.TokenStream`
  Overrides:
    `reportError` in class `lpg.lpgjavaruntime.LexStream`

### initialize

    public void initialize(char[] inputChars)

  Define the input text as a given array of characters.

  Parameters:
    `buffer` - the characters

### initialize

    public void initialize(Reader reader)
                    throws IOException

  Define the input text by reading from a reader.

  Parameters:
    `reader` - providing the source text
  Throws:
    `IOException` - if reading fails

Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved.