|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lpg.lpgjavaruntime.PrsStream org.eclipse.ocl.lpg.AbstractParser
public abstract class AbstractParser
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. |
int |
getDefaultRepairCount()
|
BasicEnvironment |
getEnvironment()
|
lpg.lpgjavaruntime.ErrorToken |
getErrorTokenAtCharacter(int offset)
This function returns the index of the token element containing the offset specified. |
int |
getErrorTokens()
|
AbstractLexer |
getLexer()
|
int |
getTokenIndexAtCharacter(int offset)
Overridden to search only the non-Error nodes, which are the only tokens in monotonic order. |
int |
makeErrorToken(int firsttok,
int lasttok,
int errortok,
int kind)
|
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 |
reportErrorTokenMessage(int error_token,
String msg)
Report error message for given error_token. |
void |
resetLexStream(lpg.lpgjavaruntime.LexStream lexStream)
|
void |
setDefaultRepairCount(int defaultRepairCount)
Sets the number of repairs to be performed by a parser capable of performing repairs (the BacktrackingParser) unless overridden on the specific parser invocation method. |
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, getTokenLength, getTokens, getTokenText, makeAdjunct, 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 |
---|
public AbstractParser(BasicEnvironment environment)
public AbstractParser(AbstractLexer lexer)
Method Detail |
---|
public String computeInputString(int left, int right)
left
- left most char indexright
- right most char index
public BasicEnvironment getEnvironment()
public lpg.lpgjavaruntime.ErrorToken getErrorTokenAtCharacter(int offset)
public int getDefaultRepairCount()
public int getErrorTokens()
public AbstractLexer getLexer()
public int getTokenIndexAtCharacter(int offset)
getTokenIndexAtCharacter
in class lpg.lpgjavaruntime.PrsStream
public int makeErrorToken(int firsttok, int lasttok, int errortok, int kind)
makeErrorToken
in interface lpg.lpgjavaruntime.TokenStream
makeErrorToken
in class lpg.lpgjavaruntime.PrsStream
public CSTNode parseTokensToCST()
public abstract CSTNode parseTokensToCST(lpg.lpgjavaruntime.Monitor monitor, int error_repair_count)
public void reportError(int errorCode, String locationInfo, int leftToken, int rightToken, String tokenText)
reportError
in interface lpg.lpgjavaruntime.TokenStream
reportError
in class lpg.lpgjavaruntime.PrsStream
public final void reportErrorTokenMessage(int error_token, String msg)
error_token
- the error taken indexmsg
- the message to reportpublic void resetLexStream(lpg.lpgjavaruntime.LexStream lexStream)
resetLexStream
in class lpg.lpgjavaruntime.PrsStream
public void setDefaultRepairCount(int defaultRepairCount)
defaultRepairCount
- the default repair count
IllegalArgumentException
- if the defaultRepairCount is negativepublic void setLexStream(AbstractLexer lexStream)
protected void setOffsets(CSTNode cstNode, lpg.lpgjavaruntime.IToken startEnd)
CSTNode
to the
start and end offsets of the given IToken
cstNode
- CSTNode
to set offsetsstartEnd
- IToken
to retrieve offsets fromprotected void setOffsets(CSTNode cstNode, CSTNode startEnd)
CSTNode
to the
start and end offsets of the 2nd given CSTNode
cstNode
- CSTNode
to set offsetsstartEnd
- CSTNode
to retrieve offsets fromprotected void setOffsets(CSTNode cstNode, CSTNode start, CSTNode end)
CSTNode
to the
start offset of the 2nd given CSTNode
and the end offset of
the 3rd given CSTNode
cstNode
- CSTNode
to set offsetsstart
- CSTNode
to retrieve start offset fromend
- CSTNode
to retrieve end offset fromprotected void setOffsets(CSTNode cstNode, CSTNode start, lpg.lpgjavaruntime.IToken end)
CSTNode
to the
start offset of the 2nd given CSTNode
and the end offset of
the given IToken
cstNode
- CSTNode
to set offsetsstart
- CSTNode
to retrieve start offset fromend
- IToken
to retrieve end offset fromprotected void setOffsets(CSTNode cstNode, lpg.lpgjavaruntime.IToken start, CSTNode end)
CSTNode
to the
start offset of the given IToken
and the end offset of the
2nd given CSTNode
cstNode
- CSTNode
to set offsetsstart
- IToken
to retrieve start offset fromend
- CSTNode
to retrieve end offset fromprotected void setOffsets(CSTNode cstNode, lpg.lpgjavaruntime.IToken start, lpg.lpgjavaruntime.IToken end)
CSTNode
to the
start offset of the 1std given IToken
and the end offset of
the 2nd given IToken
cstNode
- CSTNode
to set offsetsstart
- IToken
to retrieve start offset fromend
- IToken
to retrieve end offset fromprotected String unquote(String quoted)
quoted
- a possibly quoted string
quoted
without the surrounding quotes, or just
quoted
verbatim if there were none
|
Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |