public class Rapids
extends java.lang.Object
Rapids is an interpreter of abstract syntax trees.
This file contains the AstRoot parser and parser helper functions. AstRoot Execution starts in the AstExec file, but spreads throughout Rapids.
Trees have a Lisp-like structure with the following "reserved" special characters:
In the above, attached_token signals that the special char has extra chars that must be parsed separately. These are variable names (in the case of %), doubles (in the case of #), Strings (in the case of ' and "), or number lists (in the case of '[' till ']').
Variables are lexically scoped inside 'let' expressions or at the top-level looked-up in the DKV directly (and must refer to a known type that is valid on the execution stack).
Modifier and Type | Class and Description |
---|---|
static class |
Rapids.IllegalASTException |
Modifier | Constructor and Description |
---|---|
protected |
Rapids(java.lang.String rapidsStr)
Primary constructor
|
Modifier and Type | Method and Description |
---|---|
static Val |
exec(java.lang.String rapids)
Execute a single rapids call in a short-lived session
|
static Val |
exec(java.lang.String rapids,
Session session)
Compute and return a value in this session.
|
static boolean |
isQuote(char c) |
java.lang.String |
match(char c) |
double |
number() |
AstRoot |
parse()
Parse an expression
'(' a nested function application expression ')
'{' a nested function definition expression '}'
'#' a double: attached_token
'[' a numeric list expression, till ']'
'"' a String (double quote): attached_token
"'" a String (single quote): attached_token
digits: a double
letters or other specials: an ID
|
static AstRoot |
parse(java.lang.String rapids)
Parse a Rapids expression string into an Abstract Syntax Tree object.
|
char |
skipWS() |
AstRoot |
throwErr(java.lang.String msg) |
java.lang.String |
token() |
Rapids |
xpeek(char c) |
protected Rapids(java.lang.String rapidsStr)
rapidsStr
- String containing a Rapids expression.public static AstRoot parse(java.lang.String rapids)
rapids
- expression to parsepublic static Val exec(java.lang.String rapids)
rapids
- expression to parsepublic static Val exec(java.lang.String rapids, Session session)
rapids
- expression to parsepublic AstRoot parse()
public Rapids xpeek(char c)
public char skipWS()
public java.lang.String token()
public double number()
public java.lang.String match(char c)
public static boolean isQuote(char c)
public AstRoot throwErr(java.lang.String msg)