|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.overturetool.vdmj.syntax.SyntaxReader
public abstract class SyntaxReader
The parent class of all syntax readers.
| Field Summary | |
|---|---|
protected BindReader |
bindReader
A BindReader, if created. |
protected ClassReader |
classReader
A ClassReader, if created. |
protected DefinitionReader |
definitionReader
A DefinitionReader, if created. |
protected Dialect |
dialect
The dialect of VDM that we're parsing. |
protected ExpressionReader |
expressionReader
An ExpressionReader, if created. |
protected PatternReader |
patternReader
A PatternReader, if created. |
protected LexTokenReader |
reader
The lexical analyser. |
protected StatementReader |
statementReader
A StatementReader, if created. |
protected TypeReader |
typeReader
A TypeReader, if created. |
| Constructor Summary | |
|---|---|
protected |
SyntaxReader()
|
protected |
SyntaxReader(LexTokenReader reader)
Create a reader with the given lexical analyser and VDM++ flag. |
| Method Summary | |
|---|---|
protected void |
checkFor(Token tok,
int number,
java.lang.String message)
If the last token is as expected, advance, else raise an error. |
void |
close()
|
protected BindReader |
getBindReader()
|
protected ClassReader |
getClassReader()
|
java.lang.String |
getCurrentModule()
|
protected DefinitionReader |
getDefinitionReader()
|
int |
getErrorCount()
|
java.util.List<VDMError> |
getErrors()
|
protected ExpressionReader |
getExpressionReader()
|
protected PatternReader |
getPatternReader()
|
protected StatementReader |
getStatementReader()
|
protected TypeReader |
getTypeReader()
|
int |
getWarningCount()
|
java.util.List<VDMWarning> |
getWarnings()
|
protected LexNameToken |
idToName(LexIdentifierToken id)
Convert an identifier into a name. |
protected boolean |
ignore(Token tok)
If the last token is the one passed, advance by one, else do nothing. |
protected LexIdentifierToken |
lastIdToken()
Return the last token, converted to a LexIdentifierToken. |
protected LexNameToken |
lastNameToken()
Return the last token, converted to a LexNameToken. |
protected LexToken |
lastToken()
Return the last token read by the lexical analyser without advancing. |
protected LexToken |
nextToken()
Read the next token from the lexical analyser, and advance by one token. |
void |
printErrors(java.io.PrintWriter out)
Print errors and warnings to the PrintWriter passed. |
void |
printWarnings(java.io.PrintWriter out)
|
protected LexIdentifierToken |
readIdToken(java.lang.String message)
Return the last token as an identifier, and advance by one token. |
protected LexNameToken |
readNameToken(java.lang.String message)
Return the last token as a name, and advance by one token. |
protected LexToken |
readToken()
Return the last token read, and also advance by one token. |
protected void |
report(LocatedException error,
Token[] after,
Token[] upto)
Raise a syntax error and attempt to recover. |
void |
setCurrentModule(java.lang.String module)
Set the name of the current module or class. |
protected void |
throwMessage(int number,
java.lang.String message)
Raise a ParserException at the current location. |
protected void |
throwMessage(int number,
java.lang.String message,
LexToken token)
Raise a ParserException at the location of the token passed in. |
java.lang.String |
toString()
|
protected void |
warning(int no,
java.lang.String msg,
LexLocation location)
Report a warning. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final LexTokenReader reader
protected final Dialect dialect
protected DefinitionReader definitionReader
protected ExpressionReader expressionReader
protected PatternReader patternReader
protected TypeReader typeReader
protected BindReader bindReader
protected StatementReader statementReader
protected ClassReader classReader
| Constructor Detail |
|---|
protected SyntaxReader(LexTokenReader reader)
protected SyntaxReader()
| Method Detail |
|---|
protected LexToken nextToken()
throws LexException
LexException
protected LexToken lastToken()
throws LexException
LexException
protected LexToken readToken()
throws LexException
lastToken() followed by
nextToken(), but returning the result of lastToken.
LexExceptionpublic void setCurrentModule(java.lang.String module)
idToName(org.overturetool.vdmj.lex.LexIdentifierToken).
module - public java.lang.String getCurrentModule()
protected LexNameToken idToName(LexIdentifierToken id)
id - The identifier to convert
protected LexIdentifierToken lastIdToken()
throws ParserException,
LexException
LexIdentifierToken. If
the last token is not an identifier token, an exception is thrown
with the message passed in.
LexException
ParserException
protected LexNameToken lastNameToken()
throws LexException,
ParserException
LexNameToken. If
the last token is not a name token, or an identifier token that can
be converted to a name, an exception is thrown with the message
passed in.
LexException
ParserException
protected LexIdentifierToken readIdToken(java.lang.String message)
throws LexException,
ParserException
lastIdToken() followed by nextToken, and
returning the result of the lastIdToken.
message - The message to throw if the last token is not an id.
LexException
ParserException
protected LexNameToken readNameToken(java.lang.String message)
throws LexException,
ParserException
lastNameToken() followed by nextToken, and
returning the result of the lastNameToken.
message - The message to throw if the last token is not a name.
LexException
ParserExceptionprotected DefinitionReader getDefinitionReader()
protected ExpressionReader getExpressionReader()
protected PatternReader getPatternReader()
protected TypeReader getTypeReader()
protected BindReader getBindReader()
protected StatementReader getStatementReader()
protected ClassReader getClassReader()
public void close()
throws java.io.IOException
java.io.IOException
protected void checkFor(Token tok,
int number,
java.lang.String message)
throws LexException,
ParserException
tok - The token type to check for.number - The error number.message - The error message to raise if the token is not as expected.
LexException
ParserException
protected boolean ignore(Token tok)
throws LexException
tok - The token type to check for.
LexException
protected void throwMessage(int number,
java.lang.String message)
throws ParserException,
LexException
ParserException at the current location.
number - The error number.message - The error message.
ParserException
LexException
protected void throwMessage(int number,
java.lang.String message,
LexToken token)
throws ParserException
ParserException at the location of the token passed in.
number - The error number.message - The error message.token - The location of the error.
ParserException
protected void report(LocatedException error,
Token[] after,
Token[] upto)
error - The exception that caused the error.after - A list of tokens to recover to, and step one beyond.upto - A list of tokens to recover to.
protected void warning(int no,
java.lang.String msg,
LexLocation location)
public int getErrorCount()
public java.util.List<VDMError> getErrors()
public int getWarningCount()
public java.util.List<VDMWarning> getWarnings()
public void printErrors(java.io.PrintWriter out)
public void printWarnings(java.io.PrintWriter out)
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||