| Literals | Assigment | Operator | Instanceof | Delegates | Lambda |
Literals are hard coded values of basic or component types.
LiteralExpression
: IntegerLiteral
| BoolLiteral
| FloatLiteral
| NilLiteral
| StringLiteral
| CharLiteral
| ArrayLiteral
| PropsLiteral
;
BoolLiteral
: 'true'
| 'false'
;
IntegerLiteral
: '0x'(0-F)+
| 0(0-7)+
| (0-9)+ [IntegerLiteralTypeSuffix]
;
IntegerLiteralTypeSuffix
: 'b'
| 'B'
| 's'
| 'S'
| 'i'
| 'I'
| 'l'
| 'L'
;
FloatLiteral
: (0-9)+ '.' (0-9)+[ 'e' (0-9)+] [d|D|f|F]
;
NilLiteral
: 'Nil'
| 'nil'
| 'null'
;
A Nil literal represends an uninitialized (via new ) Object variable.
acdk.lang.Object obj;
obj == Nil;
obj = new String("");
obj != Nil;
obj = Nil; // free reference to object
obj == Nil;
|
String literals in CfgScript followings the rules of String in C/C++
with following exceptions:
- Automatic String concanating is not supported yet.
- String literals can be in multiple lines. The resulting string contains the new lines
s1 = "Hello\nWorld";
s2 = "Hello
World";
s1.equals(s2) == true;
|
CfgScript supports also unicode characters using \uxxxx escape sequence.
The xxxx is a hexdecimal number identifying the character.
Please refer also to charts.
A sample converting ü ä ö to upper case:
String s = "ue=\u00fc; ae=\u00e4; oe=\u00f6"; //
String us = s.toUpperCase();
out.println("lc: " + s + "; uc: " + us + "; = " + "UE=\u00dc; AE=\u00c4; OE=\u00d6");
|
The standard C escape codes ("\n\t\r\b" ) are also supported.
With the BacktickOperator it
is possible to expand variable inline in the string, similar to perl, tcl or sh.
Single Character are quoted with single '.
char c1 = 'c';
char c2 = '\0';
char c3 = 'A';
|
Unicode characters are supported using \uxxxx escape sequence.
UnicodeCharacter.toUpperCase('\u00e4') == '\u00c4'
|
|