Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Namespaces

One important feature of IQL is the integration of Java types. The DSL can refer to Java types from Java standard libraries, Odysseus Bundles or other external libraries. Namespaces are useful in this context to refer Java types by a simple name and not by a fully qualified name. The static-keyword allows the static methods of a java class to be referenced without qualifying the class name.

Code Block
titleGrammar
ID            

Class, Interface

Code Block
titleGrammar
Class                  ::= "class" ID ("extends" QName)? ("implements" QName ("," QName)*)? "{" (Attribute | Method)* "}". 
Interface              ::= ("interface" ID ("extends" QName ("," QName)*)? "{" (MethodDeclaration)* "}".
Attributea".."z"|"A".."Z"|"_")("a".."z"|"A".."Z"|"_"|"0".."9")*.
QName                   ::= VariableDeclarationID (VariableInit)? ";".
VariableDeclaration    ::= Type" ID.)*
TypeNamespace                   ::= (PrimitiveType | QName)"use" ("[static")? QualifiedNameWithWildcard "];")*.
PrimitiveType     QualifiedNameWildcard     ::= QualifiedName ("::*")?
Code Block
titleExample
use java::util::*;
use de::uniol::inf::is::odysseus::core::ISubscription;
use com::google::common::collect::ImmutableMap;

Class, Interface

Besides the integration of Java types it is also possible to create your own classes and interfaces.

Code Block
titleGrammar
Class         "boolean" | "byte" | "char" | "short" | "int" | "float" | "long" | "double".
Method         ::= "class" ID ("extends" QName)? ("implements"  QName ::= ("override," QName)*)? MethodDeclaration StatementBlock.  
MethodDeclaration"{" (Attribute | Method)* "}". 
Interface      ::= ID (MethodParameters)? (":" Type)?.
MethodParameters       ::= "interface" ID ("extends" (VariableDeclarationQName ("," VariableDeclarationQName)*)? "{" (MethodDeclaration)* ".
Code Block
titleExample Class
class Point implements IPoint{
}".
Attribute       int x;
    int y;
 ::= VariableDeclaration (VariableInit)? ";".
VariableDeclaration    Point(int x, int y) {
::= Type ID.
Type        this.x = x;
        this.y ::= y;
(PrimitiveType | QName)  }
("[" "]")*.
PrimitiveType    
    override getX() : int{
        return this.x;
    }
:= "boolean" | "byte" | "char" | "short" | "int" | "float" | "long" | "double".
Method    
    override getY() : int{
      ::=  return this.y;
    }    
}
Code Block
titleExample Interface
interface IPoint {
	getX() : int;
    getY() : int;
}

...

("override")? MethodDeclaration StatementBlock.  
MethodDeclaration      ::= ID (MethodParameters)? (":" Type)?.
MethodParameters       ::= "(" (VariableDeclaration ("," VariableDeclaration)*)? ")".
Code Block
titleGrammarExample Class
Statementclass Point implements IPoint{
    int x;
    int y;
 ::= ( StatementBlock |
 IfStatement | SwitchStatement | WhileStatement | DoWhileStatement | ForStatement | ForEachStatement
Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
    
  | VariableStatement |override ConstructorStatementgetX() |: ExpressionStatementint{
 | BreakStatement |   ContinueStatement | ReturnStatementreturn )this.x;
StatementBlock    }
    
   ::= "{" (Statement)* "}".
IfStatement override getY() : int{
        return this.y;
    }    
}
Code Block
titleExample Interface
interface IPoint {
	getX() : int;
    getY() : int;
}

Statements

Methods, constructors and other blocks are sequences of statements. They can be divided into atomic and compound statements. Atomic statements are not made up of other statements and ends with a semicolon (e.g. VariableStatement). Compound statements (also called control structures) contain other statements (e.g. WhileStatement).

Code Block
titleGrammar
Statement     ::= "if" "(" Expression ")" Statement ("else" Statement)?.
SwitchStatement        ::= "switch" "(" Expression ")" "{" ("case" Expression ":" (Statement)*)* ("default" ":" (Statement)*)? "}"
WhileStatement         ::= "while" "(" Expression ")" Statement.
DoWhileStatement       ::= "do" Statement "while" "(" Expression ")" ";".
ForStatement( StatementBlock | IfStatement | SwitchStatement | WhileStatement | DoWhileStatement | ForStatement | ForEachStatement
                  ::= "for" "(" VariableDeclaration ";" Expression ";" Expression ")" Statement.
ForEachStatement       ::= "for" "(" VariableDeclaration ":" Expression ")" Statement.
VariableStatement | VariableStatement | ConstructorStatement | ExpressionStatement | BreakStatement | ContinueStatement | ReturnStatement ).
StatementBlock         ::= VariableDeclaration VariableInit"{" (Statement)* ";}".
ConstructorStatementIfStatement     ::= ("super" | "this")       ::= "if" "(" (ArgsList)?Expression ")" Statement (";else".
ExpressionStatement    ::= Expression ";".
BreakStatement Statement)?.
SwitchStatement         ::= "breakswitch" ";(".
ContinueStatement Expression     ::= "continue" ";".
ReturnStatement")" "{" ("case" Expression ":" (Statement)*)* ("default" ":" (Statement)*)? "}"
WhileStatement         ::= "returnwhile" "(" Expression)? ";)".
Code Block
titleExample if-Statement
int i = 2;
if (i>2) {
        Statement.
DoWhileStatement       ::= "do" Statement "while" "(" Expression ")" ";".
ForStatement     
}
Code Block
titleExample switch-Statement
int i = 2;   ::=   
switch(i) {
	case 2 :
		return true;
	case 4 : 
		return true;
	default :
		return false;
}
Code Block
titleExample while-Statement
int i = 2;   "for" "(" VariableDeclaration ";" Expression ";" Expression ")" Statement.
ForEachStatement       ::= "for" "(" VariableDeclaration ":" Expression ")" Statement.
VariableStatement      ::= VariableDeclaration 
while (i>2) {
VariableInit ";".
ConstructorStatement            
} 

do {
   ::= ("super" | "this") "(" (ArgsList)? ")" ";".
ExpressionStatement    ::= Expression ";".
BreakStatement         
} while (i>2);   ::= "break" ";".
ContinueStatement      ::= "continue" ";".
ReturnStatement         
::= "return" (Expression)? ";".
Code Block
titleExample forif-Statement
for (int ji = 02; j<10; j++
if (i>2) {

} 
        
List list = [1,2,3];
for (Object element : list) {
}
}
Code Block
titleExample object initialization
// Constructor Call
Point p1 = new Point(2, 5);
Point p2(2,5);

// Assigning attribute values
Point p3 = new Point{x = 2, y = 5};
Point p4{x = 2, y = 5};

Expressions

switch-Statement
int i = 2;      
switch(i) {
	case 2 :
		return true;
	case 4 : 
		return true;
	default :
		return false;
}
Code Block
titleExample while-Statement
int i = 2;
Code Block
titleGrammar
Expression           ::=
while (i>2) AssignmentExpression{
  | LogicalExpression | EqualityExpression | ArithmeticExpression | UnaryExpression |  
} 

do {
            
} while (i>2);            
Code Block
titleExample for-Statement
for (int j = 0; j<10; j++) {

} 
        
List list = [1,2,3];
for (Object element : list) {

}

 

A new object can be created by calling a constructor. It is also possible to assign values to attributes in this context. This makes it easier to configure operators when building a query with QDL because it is not necessary to create a new statement for each parameter.

Code Block
titleExample object initialization
// Constructor Call
Point p1 = new Point(2, 5);
Point p2(2,5);

// Assigning attribute values
Point p3 = new Point{x = 2, y = 5};
Point p4{x = 2, y = 5};

Expressions

An expression is used as part of other expressions or statements and produces a value as result.

Code Block
titleGrammar
Expression           ::= ( AssignmentExpression | LogicalExpression | EqualityExpression | ArithmeticExpression | UnaryExpression | CastExpression
							| PrefixExpression | PostfixExpression | InstanceOfExpression | CreateExpression | AttributeExpression | MethodExpression
							| ArrayExpression | "this" | "super" | ID | LiteralExpression | ("(" Expression ")").
AssignmentExpression ::= Expression ("=" | "+=" | "-=" | "*=" | "/=" | "%=") Expression.
LogicalExpressionCastExpression
							| PrefixExpression | PostfixExpression | InstanceOfExpression | CreateExpression | AttributeExpression | MethodExpression
							| ArrayExpression | "this" | "super" | ID | LiteralExpression | ("(" Expression ")").
AssignmentExpression ::= Expression ("=" | "+=" | "-=" | "*=" | "/=" | "%=") Expression.
LogicalExpression    ::= Expression ("&&" | "||") Expression.
EqualityExpression   ::= Expression ("==" | "!=" | ">" | ">=" | "<" | "<=") Expression.
ArithmeticExpression ::= Expression ("+" | "-" | "*" | "/"| "%") Expression.                      
UnaryExpression      ::= ("+" | "-" | "!") Expression.
CastExpression       ::= "(" Type ")" Expression.
PrefixExpression     ::= ("++" | "--") Expression.
PostfixExpression    ::= Expression ("++&&" | "--||").
InstanceOfExpression ::= Expression "instanceof" Type.
NewExpressionEqualityExpression        ::= "new" QNameExpression (("[==" | "]!=") | (("(>" (ArgsList)?| ")")? ("{" ArgsMap "}")?)).
MemberCallExpression>=" | "<" | "<=") Expression.
ArithmeticExpression ::= (ExpressionExpression ("+" | ".-")? ID| ("(*" (ArgsList)? | "/"| ")%")?.
ArrayExpression Expression.          ::= Expression ("[" ArgsList "]")+.
LiteralExpression    ::= Integer | Double |
UnaryExpression Boolean | Char | String | Range::= ("+" | List"-" | Map | Null
VariableInit "!") Expression.
CastExpression        ::= ((("(" (ArgsList)?Type ")")? Expression.
PrefixExpression     ::= ("{++" ArgsMap| "}")?)--") Expression.
PostfixExpression    ::= Expression ("++" | ("=--" Expression)).
ArgsListInstanceOfExpression ::= Expression "instanceof" Type.
NewExpression         ::= Expression"new" QName ((",[" Expression)*.
ArgsMap             "]") | (("(" (ArgsList)? ")")? ("{" ArgsMap "}")?)).
MemberCallExpression ::= ArgsMapKeyValue (Expression ".")? ID (",(" ArgsMapKeyValue)*(ArgsList)? ")")?.
ArgsMapKeyValueArrayExpression      ::= IDExpression ("[" ArgsList "=" Expression

Metadata

Code Block
titleGrammar
Metadata               ::= ID "=" MetadataValue.
MetadataValue]")+.
LiteralExpression    ::= Integer | Double | Boolean | Char | String | Range | List | Map | Null
VariableInit          ::= MetadataValueSingle | MetadataValueList | MetadataValueMap.
MetadataValueSingle    ::= INTEGER | Double | CHAR | STRING | BOOLEAN | QName.
MetadataValueList((("(" (ArgsList)? ")")? ("{" ArgsMap "}")?) | ("=" Expression)).
ArgsList             ::= "["Expression (MetadataValue ("," MetadataValueExpression)*)? "]".
MetadataValueMapArgsMap              ::= "[" (MetadataValueMapEntryArgsMapKeyValue ("," MetadataValueMapEntryArgsMapKeyValue)*)? "]".
MetadataValueMapEntryArgsMapKeyValue      ::= MetadataValue ":" MetadataValue.

See operators in ODL or queries in QDL for examples.

...

ID "=" Expression

If a data type has a getter- or setter-method there will always be a corresponding attribute to access. So it is often possible to use assignment expressions instead of method calls.

Metadata

Code Block
titleGrammar
IntegerMetadata               ::= ID ::"= (0..9)+" MetadataValue.
DoubleMetadataValue          ::= MetadataValueSingle | MetadataValueList | MetadataValueMap.
MetadataValueSingle    ::= (0..9)* "." (0..9)+.
Boolean        INTEGER | Double | CHAR | STRING | BOOLEAN | QName.
MetadataValueList         ::= "[" (MetadataValue ("true" |," MetadataValue)*)? "false]").
CharMetadataValueMap       ::= "[" (MetadataValueMapEntry ("," MetadataValueMapEntry)*)? "]".
MetadataValueMapEntry  ::= MetadataValue ":" MetadataValue.

See operators in ODL or queries in QDL for examples.

Literals

Literals are sequence of characters that represent constant values to be stored in variables.

Code Block
titleGrammar
Integer    ::= "'" Unicode-Character "'".
String                  ::= '"' (Unicode-Character)* '"'.   
Range (0..9)+.
Double                  ::= (0..9)+* ".." (0..9)+.
ListBoolean                    ::= ("[true" (Expression| (",false" Expression)*)? "]".  
Map Char                    ::= "['" (MapKeyValueUnicode-Character (",'" MapKeyValue)*)? "]".
MapKeyValue.
String                  ::= Expression ":" Expression.
Null  '"' (Unicode-Character)* '"'.   
Range                   ::= "null".
Code Block
titleExample
Range r = 1..10;
List l  = [1, 2, 3];
Map m   = ["key1":1, "key2":2];

Identifier, Qualified Name, Namespace

Code Block
titleGrammar
ID (0..9)+ ".." (0..9)+.
List                    ::= "[" (Expression ("," Expression)*)? "]".  
Map                     ::= ("a".."z"|"A".."Z"|"_")("a".."z"|"A".."Z"|"_"|"0".."9")*.
QName[" (MapKeyValue ("," MapKeyValue)*)? "]".
MapKeyValue             ::= Expression ":" Expression.
Null                       ::= ID ("::" ID)*
Namespace              ::= "use" QualifiedNameWithWildcard ";".
QualifiedNameWildcard  ::= QualifiedName ("::*")?
Code Block
titleExample
use java::util::*;
use de::uniol::inf::is::odysseus::core::ISubscription;
use com::google::common::collect::ImmutableMap;

Java-Code

::= "null".
Code Block
titleExample
Range r = 1..10;
List l  = [1, 2, 3];
Map m   = ["key1":1, "key2":2];
Tuple t = [5, true, 3.4];
IPunctuation p = 100;

 

Java-Code

IQL-code is always translated into Java-code. Sometimes it might be useful to write Java-code directly instead of IQL-code.

Code Blockcode
titleGrammar
GPLCode                ::= "$*" GPL Code "*$"
Code Block
titleExample
$*
public static void main(String[] args) {
         
}
*$

Comments

IQL supports single- and multi-line comments.

Code Block
titleGrammar
Comment                 ::= SingeLineComment | MultiLineComment.
SingeLineComment        ::= "//" Text (("\r")? "\n")?.
MultiLineComment        ::= "/*" Text "*/".

...