Class Jasic


  • public class Jasic
    extends Object
    • Constructor Detail

      • Jasic

        public Jasic()
        Constructs a new Jasic instance. The instance stores the global state of the interpreter such as the values of all of the variables and the current statement.
    • Method Detail

      • interpret

        public void interpret​(String source)
        This is where the magic happens. This runs the code through the parsing pipeline to generate the AST. Then it executes each statement. It keeps track of the current line in a member variable that the statement objects have access to. This lets "goto" and "if then" do flow control by simply setting the index of the current statement. In an interpreter that didn't mix the interpretation logic in with the AST node classes, this would be doing a lot more work.
        Parameters:
        source - A string containing the source code of a .jas script to interpret.