org.eclipse.ocl.lpg
Class AbstractParser

java.lang.Object
  extended by lpg.lpgjavaruntime.PrsStream
      extended by org.eclipse.ocl.lpg.AbstractParser
All Implemented Interfaces:
lpg.lpgjavaruntime.ParseErrorCodes, lpg.lpgjavaruntime.TokenStream
Direct Known Subclasses:
AbstractOCLParser

public abstract class AbstractParser
extends lpg.lpgjavaruntime.PrsStream

The AbstractParser supports syntactic analysis of a tokens produced by an AbstractLexer to create 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
 
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
AbstractParser(AbstractLexer lexer)
           
AbstractParser(BasicEnvironment environment)
           
 
Method Summary
 String computeInputString(int left, int right)
          Returns a single line string representation of the input chars for the given range.
 BasicEnvironment getEnvironment()
           
 AbstractLexer getLexer()
           
 CSTNode parseTokensToCST()
           
abstract  CSTNode parseTokensToCST(lpg.lpgjavaruntime.Monitor monitor, int error_repair_count)
           
 void reportError(int errorCode, String locationInfo, int leftToken, int rightToken, String tokenText)
           
 void resetLexStream(lpg.lpgjavaruntime.LexStream lexStream)
           
 void setLexStream(AbstractLexer lexStream)
           
protected  void setOffsets(CSTNode cstNode, CSTNode startEnd)
          Sets the start and end offsets of the given CSTNode to the start and end offsets of the 2nd given CSTNode
protected  void setOffsets(CSTNode cstNode, CSTNode start, CSTNode end)
          Sets the start and end offsets of the given CSTNode to the start offset of the 2nd given CSTNode and the end offset of the 3rd given CSTNode
protected  void setOffsets(CSTNode cstNode, CSTNode start, lpg.lpgjavaruntime.IToken end)
          Sets the start and end offsets of the given CSTNode to the start offset of the 2nd given CSTNode and the end offset of the given IToken
protected  void setOffsets(CSTNode cstNode, lpg.lpgjavaruntime.IToken startEnd)
          Sets the start and end offsets of the given CSTNode to the start and end offsets of the given IToken
protected  void setOffsets(CSTNode cstNode, lpg.lpgjavaruntime.IToken start, CSTNode end)
          Sets the start and end offsets of the given CSTNode to the start offset of the given IToken and the end offset of the 2nd given CSTNode
protected  void setOffsets(CSTNode cstNode, lpg.lpgjavaruntime.IToken start, lpg.lpgjavaruntime.IToken end)
          Sets the start and end offsets of the given CSTNode to the start offset of the 1std given IToken and the end offset of the 2nd given IToken
protected  String unquote(String quoted)
          Removes the "s surrounding a quoted string, if any.
 
Methods inherited from class lpg.lpgjavaruntime.PrsStream
addAdjunct, addToken, afterEol, badToken, dumpToken, dumpTokens, getAdjuncts, getColumn, getColumnOfTokenAt, getEndColumn, getEndColumnOfTokenAt, getEndLine, getEndLineNumberOfTokenAt, getEndOffset, getFileName, getFirstErrorToken, getFirstRealToken, getFollowingAdjuncts, getInputChars, getIToken, getKind, getLastErrorToken, getLastRealToken, getLexStream, getLine, getLineNumberOfTokenAt, getName, getNext, getPrecedingAdjuncts, getPrevious, getSize, getStartOffset, getStreamIndex, getStreamLength, getToken, getToken, getTokenAt, getTokenAtCharacter, getTokenIndexAtCharacter, getTokenLength, getTokens, getTokenText, makeAdjunct, makeErrorToken, makeToken, mapKind, orderedTerminalSymbols, peek, remapTerminalSymbols, reportError, reportError, reportError, reset, reset, resetTokenStream, setSize, setStreamIndex, setStreamLength, setStreamLength
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractParser

public AbstractParser(BasicEnvironment environment)

AbstractParser

public AbstractParser(AbstractLexer lexer)
Method Detail

computeInputString

public String computeInputString(int left,
                                 int right)
Returns a single line string representation of the input chars for the given range.

Parameters:
left - left most char index
right - right most char index
Returns:
a single line string representation of the input chars

getEnvironment

public BasicEnvironment getEnvironment()

getLexer

public AbstractLexer getLexer()

parseTokensToCST

public CSTNode parseTokensToCST()

parseTokensToCST

public abstract CSTNode parseTokensToCST(lpg.lpgjavaruntime.Monitor monitor,
                                         int error_repair_count)

reportError

public void reportError(int errorCode,
                        String locationInfo,
                        int leftToken,
                        int rightToken,
                        String tokenText)
Specified by:
reportError in interface lpg.lpgjavaruntime.TokenStream
Overrides:
reportError in class lpg.lpgjavaruntime.PrsStream

resetLexStream

public void resetLexStream(lpg.lpgjavaruntime.LexStream lexStream)
Overrides:
resetLexStream in class lpg.lpgjavaruntime.PrsStream

setLexStream

public void setLexStream(AbstractLexer lexStream)

setOffsets

protected void setOffsets(CSTNode cstNode,
                          lpg.lpgjavaruntime.IToken startEnd)
Sets the start and end offsets of the given CSTNode to the start and end offsets of the given IToken

Parameters:
cstNode - CSTNode to set offsets
startEnd - IToken to retrieve offsets from

setOffsets

protected void setOffsets(CSTNode cstNode,
                          CSTNode startEnd)
Sets the start and end offsets of the given CSTNode to the start and end offsets of the 2nd given CSTNode

Parameters:
cstNode - CSTNode to set offsets
startEnd - CSTNode to retrieve offsets from

setOffsets

protected void setOffsets(CSTNode cstNode,
                          CSTNode start,
                          CSTNode end)
Sets the start and end offsets of the given CSTNode to the start offset of the 2nd given CSTNode and the end offset of the 3rd given CSTNode

Parameters:
cstNode - CSTNode to set offsets
start - CSTNode to retrieve start offset from
end - CSTNode to retrieve end offset from

setOffsets

protected void setOffsets(CSTNode cstNode,
                          CSTNode start,
                          lpg.lpgjavaruntime.IToken end)
Sets the start and end offsets of the given CSTNode to the start offset of the 2nd given CSTNode and the end offset of the given IToken

Parameters:
cstNode - CSTNode to set offsets
start - CSTNode to retrieve start offset from
end - IToken to retrieve end offset from

setOffsets

protected void setOffsets(CSTNode cstNode,
                          lpg.lpgjavaruntime.IToken start,
                          CSTNode end)
Sets the start and end offsets of the given CSTNode to the start offset of the given IToken and the end offset of the 2nd given CSTNode

Parameters:
cstNode - CSTNode to set offsets
start - IToken to retrieve start offset from
end - CSTNode to retrieve end offset from

setOffsets

protected void setOffsets(CSTNode cstNode,
                          lpg.lpgjavaruntime.IToken start,
                          lpg.lpgjavaruntime.IToken end)
Sets the start and end offsets of the given CSTNode to the start offset of the 1std given IToken and the end offset of the 2nd given IToken

Parameters:
cstNode - CSTNode to set offsets
start - IToken to retrieve start offset from
end - IToken to retrieve end offset from

unquote

protected String unquote(String quoted)
Removes the "s surrounding a quoted string, if any.

Parameters:
quoted - a possibly quoted string
Returns:
quoted without the surrounding quotes, or just quoted verbatim if there were none

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