Package sleep.parser
Class Parser
- java.lang.Object
-
- sleep.parser.Parser
-
public class Parser extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
code
protected java.util.LinkedList
comments
an identifier for the script file.char
EndOfTerm
protected java.util.LinkedList
errors
a list of all of the comments from the script fileprotected Block
executeMe
a list of all of the statementsprotected GeneratedSteps
factory
the factory to use when generating Sleep codeprotected ImportManager
imports
protected java.lang.String
name
the actual "code" for the script file.protected java.util.LinkedList
statements
protected TokenList
tokens
a list of all of the parser warningsprotected java.util.LinkedList
warnings
a list of all of the parser errors
-
Constructor Summary
Constructors Constructor Description Parser(java.lang.String _code)
initialize the parser with the code you want me to work withParser(java.lang.String _name, java.lang.String _code)
initialize the parser with the code you want me to work withParser(java.lang.String _name, java.lang.String _code, ImportManager imps)
initialize the parser with the code you want me to work with plus a shared import manager
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addComment(java.lang.String text)
void
addStatement(Statement state)
java.lang.Class
findImportedClass(java.lang.String name)
Attempts to find a class, starts out with the passed in string itself, if that doesn't resolve then the string is appended to each imported package to see where the class might existImportManager
getImportManager()
obtain the import manager, used for managing imported packages.java.lang.String
getName()
returns the identifier representing the source of the script we're parsingBlock
getRunnableBlock()
java.util.LinkedList
getStatements()
boolean
hasErrors()
boolean
hasWarnings()
void
importPackage(java.lang.String packagez, java.lang.String from)
Used by Sleep to import statement to save an imported package name.static void
main(java.lang.String[] args)
void
parse()
void
parse(StringIterator siter)
void
reportError(java.lang.String description, Token responsible)
void
reportError(SyntaxError error)
void
reportErrorWithMarker(java.lang.String description, Token responsible)
void
reportWarning(java.lang.String description, Token responsible)
void
setCodeFactory(GeneratedSteps s)
set the code factory to be used to generated Sleep codevoid
setEndOfTerm(char c)
-
-
-
Field Detail
-
code
protected java.lang.String code
-
name
protected java.lang.String name
the actual "code" for the script file.
-
comments
protected java.util.LinkedList comments
an identifier for the script file.
-
errors
protected java.util.LinkedList errors
a list of all of the comments from the script file
-
warnings
protected java.util.LinkedList warnings
a list of all of the parser errors
-
tokens
protected TokenList tokens
a list of all of the parser warnings
-
statements
protected java.util.LinkedList statements
-
executeMe
protected Block executeMe
a list of all of the statements
-
EndOfTerm
public char EndOfTerm
-
imports
protected ImportManager imports
-
factory
protected GeneratedSteps factory
the factory to use when generating Sleep code
-
-
Constructor Detail
-
Parser
public Parser(java.lang.String _code)
initialize the parser with the code you want me to work with
-
Parser
public Parser(java.lang.String _name, java.lang.String _code)
initialize the parser with the code you want me to work with
-
Parser
public Parser(java.lang.String _name, java.lang.String _code, ImportManager imps)
initialize the parser with the code you want me to work with plus a shared import manager
-
-
Method Detail
-
getImportManager
public ImportManager getImportManager()
obtain the import manager, used for managing imported packages.
-
setCodeFactory
public void setCodeFactory(GeneratedSteps s)
set the code factory to be used to generated Sleep code
-
importPackage
public void importPackage(java.lang.String packagez, java.lang.String from)
Used by Sleep to import statement to save an imported package name.
-
findImportedClass
public java.lang.Class findImportedClass(java.lang.String name)
Attempts to find a class, starts out with the passed in string itself, if that doesn't resolve then the string is appended to each imported package to see where the class might exist
-
setEndOfTerm
public void setEndOfTerm(char c)
-
addStatement
public void addStatement(Statement state)
-
getStatements
public java.util.LinkedList getStatements()
-
getName
public java.lang.String getName()
returns the identifier representing the source of the script we're parsing
-
parse
public void parse() throws YourCodeSucksException
- Throws:
YourCodeSucksException
-
parse
public void parse(StringIterator siter) throws YourCodeSucksException
- Throws:
YourCodeSucksException
-
reportError
public void reportError(java.lang.String description, Token responsible)
-
reportErrorWithMarker
public void reportErrorWithMarker(java.lang.String description, Token responsible)
-
reportError
public void reportError(SyntaxError error)
-
getRunnableBlock
public Block getRunnableBlock()
-
reportWarning
public void reportWarning(java.lang.String description, Token responsible)
-
hasErrors
public boolean hasErrors()
-
hasWarnings
public boolean hasWarnings()
-
addComment
public void addComment(java.lang.String text)
-
main
public static void main(java.lang.String[] args)
-
-