Package sleep.parser

Class 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 file
      protected Block executeMe
      a list of all of the statements
      protected GeneratedSteps factory
      the factory to use when generating Sleep code
      protected 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 warnings
      protected 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 with
      Parser​(java.lang.String _name, java.lang.String _code)
      initialize the parser with the code you want me to work with
      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
    • 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
      • 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
      • 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)