Package net.sourceforge.plantuml.jasic
Class Jasic
java.lang.Object
net.sourceforge.plantuml.jasic.Jasic
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
An assignment statement evaluates an expression and stores the result in a variable.static interface
Base interface for an expression.class
A "goto" statement jumps execution to another place in the program.class
An if then statement jumps execution to another place in the program, but only if an expression evaluates to something other than 0.class
An "input" statement reads input from the user and stores it in a variable.class
A numeric value.class
An operator expression evaluates two expressions and then performs some arithmetic operation on the results.class
A "print" statement evaluates an expression, converts the result to a string, and displays it to the user.static interface
Base interface for a Jasic statement.class
A string value.static interface
This is the base interface for a value.class
A variable expression evaluates to the current value stored in that variable. -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
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 Details
-
interpret
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.
-