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.Stringcodeprotected java.util.LinkedListcommentsan identifier for the script file.charEndOfTermprotected java.util.LinkedListerrorsa list of all of the comments from the script fileprotected BlockexecuteMea list of all of the statementsprotected GeneratedStepsfactorythe factory to use when generating Sleep codeprotected ImportManagerimportsprotected java.lang.Stringnamethe actual "code" for the script file.protected java.util.LinkedListstatementsprotected TokenListtokensa list of all of the parser warningsprotected java.util.LinkedListwarningsa 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 voidaddComment(java.lang.String text)voidaddStatement(Statement state)java.lang.ClassfindImportedClass(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 existImportManagergetImportManager()obtain the import manager, used for managing imported packages.java.lang.StringgetName()returns the identifier representing the source of the script we're parsingBlockgetRunnableBlock()java.util.LinkedListgetStatements()booleanhasErrors()booleanhasWarnings()voidimportPackage(java.lang.String packagez, java.lang.String from)Used by Sleep to import statement to save an imported package name.static voidmain(java.lang.String[] args)voidparse()voidparse(StringIterator siter)voidreportError(java.lang.String description, Token responsible)voidreportError(SyntaxError error)voidreportErrorWithMarker(java.lang.String description, Token responsible)voidreportWarning(java.lang.String description, Token responsible)voidsetCodeFactory(GeneratedSteps s)set the code factory to be used to generated Sleep codevoidsetEndOfTerm(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)
-
-