The JEQL Language Specification
Functions and Commands
Functions and commands are the primary way of providing extensible computation in JEQL.
Built-in functions and commands provide a rich set of functionality.
Functions and commands are one of the primary extension points for JEQL.
New functions and commands may be supplied as Java classes.
These are loaded dynamically via import statements.
Functions
|
function-call ::= |
function-name
(
[ expr ]
{ , expr }
)
|
|
function-name ::= |
[ Identifier Classname . ]
Identifier Function name
|
Functions are components of expressions.
They accept zero or more values as arguments, and compute a return value.
They are executed at the point they are encountered during the execution
of an expression.
There are several kinds of functions, which have different semantics and can be used
in different locations in scripts.
- Standard functions behave like conventional programming language functions.
They always evaluate all of
their arguments, and return a result based on the values of the arguments.
These functions can be used anywhere an expression is permitted.
Standard functions are specified using a Classname, which allows overloading
function names for different purposes.
Within a given Classname, function names may not be overloaded.
- Query functions are used only in expressions evaluated in the context of a query.
They may or may not evaluate all of their arguments.
The return value may depend on the values of
the current or previous rows in the query inputs.
Query functions do not use a Classname
- Aggregate functions are used only in the context of a query.
They compute an aggregated value of a single argument expression.
The argument expression will normally contain references to the columns
of the tables forming the basis of the query.
Aggregate functions do not use a Classname.
Functions may throw exceptions.
Many of JEQL's built-in functions map directly to methods in common Java classes and libraries.
Since JEQL is not object-oriented, a JEQL function which maps
to a Java method takes the Java class object as the first parameter.
Commands
|
command ::= |
command-name
[ parameter-arg ]
{ parameter }
|
|
command-name ::= |
Identifier
|
|
parameter ::= |
Identifier:
[
parameter-arg
]
|
|
parameter-arg ::= |
expr
|
query-expr
|
Commands are statements. They are executed at the point they are encountered in a script.
Commands provide a syntactically flexible and convenient way
to interface to external procedures and Java classes,
since they provide named, optional parameters and multiple return values.
Command names are always capitalized, and may use camel-case.
Commands take zero or more named parameters.
Parameters may be either mandatory or optional.
If optional parameters are not supplied, the command may use a default value.
Parameters take zero or one arguments.
The argument is an expression.
In addition to its named parameters, a command may accept an anonymous parameter.
Anonymous parameters allow a more compact syntax
for commonly supplied parameters.
This parameter does not require a name to be specified.
The argument to the anonymous parameter is supplied immediately following the
command name.
There are three kinds of parameters:
- Input parameters pass the value of the argument expression.
For parameters which take an argument of type boolean, the argument is optional.
If no argument is supplied, the default value is true.
- Output parameters update the value of a variable with a value computed by the command.
- Input-Output parameters combine both of these operations.
Their argument must be a single variable name. Its value is provided as
input to the argument, and the command may supply a new value for the variable as output.
Commands may throw exceptions if an error
is encountered during their execution.