public class Rapids
extends java.lang.Object
Rapids is an interpreter of abstract syntax trees.
This file contains the AST parser and parser helper functions. AST 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 | Field and Description |
|---|---|
protected java.lang.String |
_str |
protected int |
_x |
| 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 ses)
Compute and return a value in this session.
|
AST |
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 AST |
parse(java.lang.String rapids)
Parse a Rapids expression string into an Abstract Syntax Tree object.
|
protected Rapids(java.lang.String rapidsStr)
rapidsStr - String containing a Rapids expression.public static AST 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 ses)
rapids - expression to parsepublic AST parse()