Bartels User Language defines spacing, identifier, constant, reserved word and operator token classes.
2.2.1 Spacing
The spacing token class includes blanks, tabulators, newlines and comments. Comments start with the token
/* and end with
*/ ; they do not nest. Another type of comment starts with the token
// and extends to the end of line. Spacings are ignored by the Compiler except as they serve to separate adjacent identifiers, reserved words and constants.
2.2.2 Identifiers
An identifier is the name of a variable, a function or a symbolic constant. Each Identifier consists of a sequence of letters and digits. The first identifier character must be a letter. The underscore
(_ ) is treated as a letter. The
User Language Compiler distinguishes between upper case letters and lower case letters (case-sensitivity). Identifiers must differ from reserved words (see below).
Examples:
X_coord value P4 File_Name _euklid
2.2.3 Constants and Constant Expressions
This section describes the
Bartels User Language constant types.
Integer Constants
Numeric integer constants are associated with the data type
int . They consist of a sequence of digits, and they are usually interpreted as decimal numbers. A constant integer specification is interpreted as octal number (in base 8), if it starts with
0 (digit zero), in which case the digits 8 and 9 are not allowed. A constant integer specification is interpreted as hexadecimal number (in base 16), if it starts with
0x or
0X (digit zero followed by letter
x ) in which case the letters
a to
A through
f to
F correspond to the hexadecimal digit values 10 through 15. Negative integer constants are not provided (the minus sign rather works as operator in order to form negative constant integer expressions; see below).
Examples:
1432 073 0xF4A5 9
Floating Point Constants
Floating point constants are associated with the data type
double . They consist of an integer part, a decimal point
(. ), a fraction part, an
e or
E character (letter
e ), and an optionally signed integer exponent. Either the integer part or fraction part (not both) can be missing; or otherwise either the decimal point or the e letter and the exponent (not both) can be missing.
Examples:
2.54 .78 4. 4.1508E-3 0.81037e6 17228E5
Character Constants
Character constants are associated with the data type
char . They consist of a single character enclosed by single quotes (apostrophes). The value of a character constant accords to the corresponding numeric value of the character in the machine's character set.
The escape character
\ (backslash) can be used for specifying special characters.
Table 2-1 contains a list of characters represented by escape sequences.
Table 2-1: Character Escape Sequences
Backspace | BS | \b |
Horizontal Tabulator | HT | \t |
Line Feed | LF | \n |
Form Feed | FF | \f |
Carriage Return | CR | \r |
Escape Character | \ | \\ |
Apostrophe | ' | \' |
Null Character | NUL | \0 |
Arbitrary bit patterns consisting of an escape symbol followed by up to three octal digits can be specified to represent the value of the desired character; the null character (NUL,
\0 ) is a special case of this construction.
String Constants
String constants are associated with the data type
string . They consist of a sequence of characters enclosed by double quotes (quotation marks). The
Bartels User Language Compiler automatically appends a null character (NUL,
\0 ) to the end of string constants; this convention is utilized by the
Bartels User Language Interpreter to match the end of constant strings. Quotation marks included with a constant string must be preceded by the escape character
(\ ); in addition the same escape character sequences as for character constants (see above) are permitted.
Examples:
"IC1" "4.8 kOhm" "This is a string with Newline\n"
Constant Expressions
A constant expression is an expression, which is composed of constant values and operators. Constant expressions are evaluated at compile time already (CEE, Constant Expression Evaluation), i.e., they do not have to be calculated by the Interpreter at runtime. This means, that wherever constants are required, corresponding constant expressions can be used without disadvantages regarding to the program memory or runtime requirements.
Examples:
int i=19-(010+0x10); CEE: int i=-5;
double d=-(4.7+2*16.3); CEE: double d=-37.3;
string s="Part"+' '+"IC1"; CEE: string s="Part IC1";
2.2.4 Terminal Symbols
Reserved Words
Table 2-2 contains the list of
Bartels User Language identifiers reserved for use as keywords. These identifiers can only be used in their predefined meaning.
Table 2-2: Reserved Words
#bnf |
#define |
#else |
#endif |
#if |
#ifdef |
#ifndef |
#include |
#undef |
break |
case |
char |
continue |
default |
do |
double |
else |
for |
forall |
if |
index |
int |
of |
return |
static |
string |
struct |
switch |
typedef |
void |
where |
while |
Operators
Table 2-3 lists the
Bartels User Language operators. These operators activate special operations regarding to the current program context.
Table 2-3: Operators
! |
!= |
% |
%= |
& |
&& |
&= |
( |
) |
* |
*= |
+ |
++ |
+= |
, |
- |
-- |
-= |
. |
/ |
/= |
: |
; |
< |
<< |
<<= |
<= |
= |
== |
> |
>= |
>> |
>>= |
? |
[ |
] |
^ |
^= |
{ |
| |
|= |
|| |
} |
~ |
Lexical Conventions • © 1985-2024 Oliver Bartels F+E • Updated: 29 October 2008, 12:56 [UTC]
|