[Home] DMelt member access. Java source code: net.sourceforge.plantuml.jasic.Jasic
package net.sourceforge.plantuml.jasic;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* This defines a single class that contains an entire interpreter for a
* language very similar to the original BASIC. Everything is here (albeit in
* very simplified form): tokenizing, parsing, and interpretation. The file is
* organized in phases, with each appearing roughly in the order that they
* occur when a program is run. You should be able to read this top-down to walk
* through the entire process of loading and running a program.
*
* Jasic language syntax
* ---------------------
*
* Comments start with ' and proceed to the end of the line:
*
* print "hi there" ' this is a comment
*
* Numbers and strings are supported. Strings should be in "double quotes", and
* only positive integers can be parsed (though numbers are double internally).
*
* Variables are identified by name which must start with a letter and can
* contain letters or numbers. Case is significant for names and keywords.
*
* Each statement is on its own line. Optionally, a line may have a label before
* the statement. A label is a name that ends with a colon:
*
* foo:
*
*
* The following statements are supported:
*
* =
* Evaluates the expression and assigns the result to the given named
* variable. All variables are globally scoped.
*
* pi = (314159 / 10000)
*
* print
* Evaluates the expression and prints the result.
*
* print "hello, " + "world"
*
* input
* Reads in a line of input from the user and stores it in the variable with
* the given name.
*
* input guess
*
* goto