Imp
[using it]
Interface Manipulation Package v4.0 (2008-06-25) a-projector ©copyright Author


imp.core
Class Expression

java.lang.Object
  extended by imp.core.Value
      extended by imp.core.Structure
          extended by imp.core.Expression
All Implemented Interfaces:
Cloneable, Comparable<Value>

public class Expression
extends Structure

Implements a expression.

An expression is a logical-structure written in this context:
name{field_1 = value_1, field_2 = value_2 ..}(element_1, element_2 ..)
thus equivalent to the XML construct:
<name field_1="value_1" field_2="value_2" ..> element_1, element_2 .. </name>
Functional terms and operators.A functional-term is a construct of the form name(element_1, ..) i.e. a logical-structure without fields. As a syntax extension usual prefix, infix, or postfix operators of different class are understood:
[a] algebraic operators
+ - * / % for sum, subtraction, product, division and remainder, ^ for power
[l] logical operators
& means and, i.e. conjunction, | means or, i.e. disjunction, ! means not, i.e. negation
[r] relational operators
== != < > <= >= for inequalities, v @ min .. max means between min and max, v @ s means in a set
[f] functional definitions
pattern -> result defines a recursion equation, $variable : type defines a variable, $variable = value defines a value, pattern ; condition defines a boolean condition in a pattern,
$name denotes a variable
[f] path definitions
? means once or not at all, ?* means zero or more times, ?+ means zero or more times, | means either-or,
$name denotes a variable, @name denotes a field
Summarizing:
Symbol.
->
=
:
:=
;
|
&
!
==
!=
>=
<=
>
<
@
..
+
-
*
/
%
^
.
-
#
$
?
?*
?+
Type.
infix
infix
infix
infix
infix
infix
infix
prefix
infix
infix
infix
infix
infix
infix
infix
infix
infix
infix
infix
infix
infix
infix
infix
prefix
prefix
prefix
postfix
postfix
postfix
Class.
[f]
[f]
[f]
[f]
[f]
[l]
[l]
[l]
[r]
[r]
[r]
[r]
[r]
[r]
[r]
[r]
[a]
[a]
[a]
[a]
[a]
[a]
[a]
[a]
[f]
[f]
[f]
[f]
[f]
shown here in precedence decreasing order and corresponding to usual functional term (e.g.: a+b represents '+'(a ,b)).
Additional constructs.
Conditional expressions:
if condition then true-expression else false-expression
corresponds to the term if(condition, true-expression, false-expression)
has also an extended form if c_1 then e_1 elif c_2 then e_2 .. else e_0
Indexed iteration:
for index from begin-value by step-value to end while condition do statement
corresponds to the term for-to(index, begin-value, step-value, end-value, condition, statement)
may have the: from begin-value (1 by default), by step-value (1 by default), while condition (true by default) part omitted
Set iteration:
for field in set while condition do statement
corresponds to the term for-in(field, set, condition, statement)
may have the: while condition (true by default) part omitted
List:
[element_1, element_2 .. ]
corresponds to the term list(element_1, element_2 ..)


Field Summary
 
Fields inherited from class imp.core.Value
NULL
 
Constructor Summary
Expression(String type)
          Constructs an expression of the given type.
 
Method Summary
static Value create(String value)
          Creates an expression from a string definition and return it.
static String toString(Value expression)
          Returns the expression as a String.
 
Methods inherited from class imp.core.Structure
clear, indexOf, setType, sort
 
Methods inherited from class imp.core.Value
cloneThis, get, getWrapping, isCyclic, isName, load, main, save, toString, wrappedObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Expression

public Expression(String type)
Constructs an expression of the given type.
This a simple short-hand for new Expression(type).

Parameters:
type - [optional, default is imp:expression] Expression type
Method Detail

create

public static final Value create(String value)
                          throws IllegalArgumentException
Creates an expression from a string definition and return it.

Parameters:
value - The value defined as an XML string.
Throws:
IllegalArgumentException - If the value can not be parsed.

toString

public static String toString(Value expression)
Returns the expression as a String.