|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.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.
Constructor Summary | |
---|---|
AbstractParser(AbstractLexer lexer)
|
|
AbstractParser(BasicEnvironment environment)
|
Method Summary | |
---|---|
java.lang.String |
computeInputString(int left,
int right)
Returns a single line string representation of the input chars for the given range. |
protected char |
decodeEscapeSequence(java.text.StringCharacterIterator i)
Decodes an escape sequence in accordance with the Issue 14357 proposals for Concrete Syntaxes. |
protected int |
decodeHexCharacter(char c)
Return the value of the next character if it is a hexadecimal character. |
protected int |
decodeOctalCharacter(java.text.StringCharacterIterator i)
Return the value of the next character if it is an octal character. |
protected java.lang.String |
decodeString(lpg.runtime.IToken token,
java.lang.String string)
Returns a string with any escape sequences decoded by decodeEscapeSequence(java.text.StringCharacterIterator) . |
int |
getDefaultRepairCount()
|
BasicEnvironment |
getEnvironment()
|
abstract DerivedPrsStream |
getIPrsStream()
|
protected abstract lpg.runtime.IToken |
getLeftIToken()
|
protected abstract int |
getLeftSpan()
|
AbstractLexer |
getLexer()
|
abstract lpg.runtime.ParseTable |
getParseTable()
|
protected abstract lpg.runtime.ErrorToken |
getRhsErrorIToken(int i)
|
protected abstract int |
getRhsErrorTokenIndex(int i)
|
protected abstract lpg.runtime.IToken |
getRhsFirstIToken(int i)
|
protected abstract int |
getRhsFirstTokenIndex(int i)
|
protected abstract lpg.runtime.IToken |
getRhsIToken(int i)
|
protected abstract lpg.runtime.IToken |
getRhsLastIToken(int i)
|
protected abstract int |
getRhsLastTokenIndex(int i)
|
protected abstract java.lang.Object |
getRhsSym(int i)
|
protected abstract int |
getRhsTokenIndex(int i)
|
protected abstract lpg.runtime.IToken |
getRightIToken()
|
protected abstract int |
getRightSpan()
|
abstract int |
numTokenKinds()
|
abstract java.lang.String[] |
orderedTerminalSymbols()
|
abstract CSTNode |
parser()
Runs the parser with the current lex and parse streams |
abstract CSTNode |
parser(int error_repair_count)
Runs the parser with the current lex and parse streams
using a given error_repair_count (useful for a backtracking parser) |
abstract CSTNode |
parser(lpg.runtime.Monitor monitor)
Runs the parser with the current lex and parse streams
using the given Monitor |
abstract CSTNode |
parser(lpg.runtime.Monitor monitor,
int error_repair_count)
Runs the parser with the current lex and parse streams
using the given Monitor and error_repair_count (useful for a backtracking parser) |
CSTNode |
parseTokensToCST()
Deprecated. clients should invoke parser() |
abstract void |
reset(lpg.runtime.ILexStream lexStream)
Resets the parser's lexStream |
void |
resetLexStream(lpg.runtime.LexStream lexStream)
Deprecated. To set/reset the lex stream use reset(ILexStream) |
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 lexer)
Deprecated. To set/reset the lex stream use reset(ILexStream) |
protected void |
setOffsets(CSTNode cstNode)
Initializes a concrete-syntax node's start and end offsets from the current token in the parser stream. |
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.runtime.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.runtime.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.runtime.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.runtime.IToken start,
lpg.runtime.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 abstract void |
setResult(java.lang.Object object)
|
protected java.lang.String |
unDoubleQuote(lpg.runtime.IToken token)
Deprecated. double quotes form no part of the OCL specification |
protected java.lang.String |
unquote(java.lang.String quoted)
Deprecated. Use unDoubleQuote |
protected java.lang.String |
unSingleQuote(lpg.runtime.IToken token)
Removes any quotes surrounding the string value of a token using #unSingleQuote(String,int) and optionally decode any
escape sequences within it using decodeEscapeSequence(java.text.StringCharacterIterator) . |
protected java.lang.String |
unSingleQuote(java.lang.String quoted)
Removes any quotes surrounding a quoted string. |
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 java.lang.String computeInputString(int left, int right)
left
- left most char indexright
- right most char index
public BasicEnvironment getEnvironment()
public int getDefaultRepairCount()
public AbstractLexer getLexer()
@Deprecated public CSTNode parseTokensToCST()
parser()
@Deprecated public void resetLexStream(lpg.runtime.LexStream lexStream)
reset(ILexStream)
lexStream
- public void setDefaultRepairCount(int defaultRepairCount)
defaultRepairCount
- the default repair count@Deprecated public void setLexStream(AbstractLexer lexer)
reset(ILexStream)
lexer
- protected void setOffsets(CSTNode cstNode, lpg.runtime.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.runtime.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.runtime.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.runtime.IToken start, lpg.runtime.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 void setOffsets(CSTNode cstNode)
Initializes a concrete-syntax node's start and end offsets from the current token in the parser stream.
Note: this method resided in the OCLEssential.g template since 1.2 It has been incorporated in the abstract parser since 3.0
cstNode
- a concrete-syntax node@Deprecated protected java.lang.String unquote(java.lang.String quoted)
quoted
- a possibly quoted string
quoted
without the surrounding quotes, or just
quoted
verbatim if there were none@Deprecated protected java.lang.String unDoubleQuote(lpg.runtime.IToken token)
decodeEscapeSequence(java.text.StringCharacterIterator)
.
For MDT/OCL 1.3.0 compatibility, a problem is reported if double
quotes are present and the #ProblemOption.ELEMENT_NAME_QUOTE_ESCAPE
severity is not #ProblemHandler.Severity.OK
.
token
- containing string to be decoded
token
with escapes replacedprotected java.lang.String unSingleQuote(lpg.runtime.IToken token)
#unSingleQuote(String,int)
and optionally decode any
escape sequences within it using decodeEscapeSequence(java.text.StringCharacterIterator)
.
For MDT/OCL 1.3.0 compatibility, escape sequences conversion can be disabled
by resetting #ParsingOption.USE_BACKSLASH_ESCAPE_PROCESSING
.
token
- containing string to be decoded
token
with escapes replacedprotected java.lang.String unSingleQuote(java.lang.String quoted)
The default implementation removes a leading/trailing single quote pair, or an underscore-prefixed leading/trailing single quote pair.
quoted
- string to be decoded
protected java.lang.String decodeString(lpg.runtime.IToken token, java.lang.String string)
decodeEscapeSequence(java.text.StringCharacterIterator)
.
token
- the token from which the string originatedstring
- to be decoded
string
without any escapes replacedprotected char decodeEscapeSequence(java.text.StringCharacterIterator i)
\b | : backspace BS |
\t | : horizontal tab HT |
\n | : line feed LF |
\f | : form feed FF |
\r | : carriage return CR |
\" | ": double quote " |
\' | ': single quote ' |
\\ | \: backslash \ |
\xhh | \u00hh: hex byte |
\uhhhh | \uhhhh: hex code point |
\7$ | \u000o: octal byte |
\77 | \u00ff: octal byte |
\37$ | \u00ff: octal byte |
\377 | \u00ff: octal byte |
h | hex digit (0-9, a-f, A-F) |
7 | octal digit (0-7) |
3 | octal prefix digit (0-3) |
$ | end of string or non-octal digit next letter |
i
- character iterator pointing at first character after the introducer
protected int decodeHexCharacter(char c)
c
- potentially hex character
protected int decodeOctalCharacter(java.text.StringCharacterIterator i)
c
- potentially octal character
public abstract java.lang.String[] orderedTerminalSymbols()
public abstract int numTokenKinds()
public abstract DerivedPrsStream getIPrsStream()
parseStream
public abstract void reset(lpg.runtime.ILexStream lexStream)
lexStream
lexStream
- public abstract CSTNode parser()
lex
and parse
streams
CSTNode
which results from the parsing processpublic abstract CSTNode parser(lpg.runtime.Monitor monitor)
lex
and parse
streams
using the given Monitor
CSTNode
which results from the parsing processpublic abstract CSTNode parser(int error_repair_count)
lex
and parse
streams
using a given error_repair_count (useful for a backtracking parser)
CSTNode
which results from the parsing processpublic abstract CSTNode parser(lpg.runtime.Monitor monitor, int error_repair_count)
lex
and parse
streams
using the given Monitor
and error_repair_count (useful for a backtracking parser)
CSTNode
which results from the parsing processpublic abstract lpg.runtime.ParseTable getParseTable()
ParseTable
used by the parserprotected abstract java.lang.Object getRhsSym(int i)
protected abstract int getRhsTokenIndex(int i)
protected abstract lpg.runtime.IToken getRhsIToken(int i)
protected abstract int getRhsFirstTokenIndex(int i)
protected abstract lpg.runtime.IToken getRhsFirstIToken(int i)
protected abstract int getRhsLastTokenIndex(int i)
protected abstract lpg.runtime.IToken getRhsLastIToken(int i)
protected abstract int getLeftSpan()
protected abstract lpg.runtime.IToken getLeftIToken()
protected abstract int getRightSpan()
protected abstract lpg.runtime.IToken getRightIToken()
protected abstract int getRhsErrorTokenIndex(int i)
protected abstract lpg.runtime.ErrorToken getRhsErrorIToken(int i)
protected abstract void setResult(java.lang.Object object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |