Back Home Up Next


1.1 Character Set
1.2 Identifiers
1.3 Literals
1.4 Delimiters
1.6 Layout Characters

This chapter describes the lexical elements of the language. Lexical elements are identifiers, literals, and delimiters. They are the basic elements used to build language constructs such as expressions, definitions, and so on. Lexical elements are composed of characters of a basic character set.

1.1 Character Set

All characters used in a program must be part of the basic character set. The characters of the basic character set are subdivided in five categories:

lower-case letters a, b, ..., z
upper-case letters A, B, ..., Z
digits 0, 1, ..., 9
special characters such as + - * / < > = : ( ) , ;
layout characters

Layout characters are used to control the layout of a program and may be used to separate adjacent lexical elements (see Section 1.6).

1.2 Identifiers

Identifiers are used as names to identify definitions, parameters, variables, and other program entities. An identifier consists of a sequence of letters, digits, and the underscore (_) character. The first character of an identifier may not be a digit. Examples of valid identifiers are:

a A123 Triangle count Page_Count

Uppercase and lowercase letters are distinct, so Count and count are different identifiers.

As a convention, all identifiers which have a predefined meaning in the language, such as keywords, basic type names and built-in definitions, are in lowercase. That means that you can define uppercase versions for other purposes. For example, If is different from if. However, in most situations it is unwise to choose identifiers that differ only slightly from each other.

Identifiers starting with underscore are reserved for special facilities related to the implementation and the run-time environment, so it is not recommended to use such identifiers for other purposes.


Keywords are identifiers with a special meaning. In Elisa there are two categories of keywords: reserved keywords, and context dependent keywords.

Reserved keywords are reserved identifiers with a predefined and fixed meaning in the language. They may not be used for other purposes. Examples of reserved keywords are:

if then else evaldef
intrinsic when repeat refdef

Context dependent keywords are identifiers which have a specific meaning within a given context. They may also be used for different purposes within other contexts where the meaning can be established unambiguously. However, it is often unwise to choose identifiers with the same name but with different meanings. The following identifiers are examples of context dependent keywords:

begin category component end

include multi nothing optional

phrase ready return single

subtype type use var

1.3 Literals

A literal represents a constant value. The form of the literal determines the value and its type. There are four types of literals: integer-literals, real-literals, character-literals and text-literals. The types integer, real, character and text are predefined in the language and are discussed later on.

An integer literal consists of one or more digits, representing an unsigned integer number. Examples are: 0, 21, 3456, 32767.

A real literal represents an unsigned real number and consists of an integer portion, a decimal point followed by a fractional portion, and an optional exponent. At least one digit should be specified before the decimal point (the integer portion). You may omit the digits after the decimal point (the fractional portion). The optional exponent specifies the power of ten by which the preceding number is to be multiplied to obtain the value. Examples of real literals are: 0.0, 123., 123.45, 3.142, 3142.0E-3.

A character literal represents one character and is formed by enclosing a single character from the basic character set within single quotation marks. The following examples illustrate some character-literals:

' '   Single space
'A'   Uppercase A
'a'   Lowercase a
'?'   Question mark

To represent non-displayable characters, quotation marks and layout characters, an escape sequence must be used. An escape sequence consists of a backslash(\) followed by a letter or an integer constant. An escape sequence is regarded as a single character and should represent a valid character value.

A text literal represents a string of characters and is of the predefined type text. It consists of a string of characters from the basic character set enclosed in double quotation marks. All characters, except the first and last quotation marks, are part of the text. An empty text-literal is represented by two adjacent double quotation marks("").

To represent non-displayable characters, quotation marks and layout characters, an escape sequence may be used in the same way as has been described for character literals.

The following examples illustrate some text-literals:


"it's John's book"

"" empty string

"\"" double quotation mark

Escape Sequences

Escape sequences are described in the following table.

Escape Sequence Meaning
\n New Line
\t Horizontal Tab
\v Vertical Tab
\f Form Feed
\b Backspace
\r Carriage Return
\a Alert (Bell)
\' Single quote
\" Double quote
\\ Backslash
\ddd Character in decimal notation

Table of Escape Sequences

The following examples illustrate some character-literals with escape characters:

'\''   Single quotation mark
'\n'   New Line
'\\'   Backslash
'\065'   letter A

If a backslash precedes a character that does not appear in the table, the backslash is ignored. The sequence \ddd allows you to specify any character in the basic character set as a three-digit integer character code. For example, you can give the backspace character as \008. The numeric value of the character code may not exceed 255.

1.4 Delimiters

A delimiter consists of one or two special characters from the basic character set. Delimiters are used as separators and operators. Separators are to used for separation and grouping of language elements. Examples are ( ) , [ ] { } ;. Examples of operator symbols are <, <=, >, >=, +, -, *, /, **. The operator symbols and their names are listed in the following table.

Operator Name
= is defined as
:= becomes
-> returns
=> is a
.. from .. to ..
== is equal to
<> is not equal to
< is less than
<= is less than or equal to
> is greater than
>= is greater than or equal to
+ plus
- minus
| or
& and
~ not
* times
/ divided by
** to the power of
: is type of
. sub

Table of Operator Symbols


Comments are used for documentation purposes; they do not affect the meaning of a program. Comments may be inserted between any two adjacent lexical elements. Comment are distinguished from the rest of the program by being enclosed in special brackets << and >>, as in:

<< This is comment >>

Comments may be nested by using balanced << >> pairs, as in:

<< This is << nested >> comment >>

In a comment, the characters can include any combination of characters from the basic character set, including layout characters, but excluding the end-comment symbols.

1.6 Layout Characters

Layout characters like blanks, tabs, carriage returns, line feeds may be used for the physical layout of a program.

Adjacent lexical elements may be separated by layout characters or comments. A name or a literal must be separated in this way from an adjacent name or literal. Layout characters can not occur within names or literals, excepting text-literals.

Because line separations also act as separators, lexical elements such as names, integer-literals, real-literals, character-literals and double character delimiters may not be written on two successive lines but must always be kept on one line. Text-literals and comments may extend over more than one line.

Top of Page   Part 1: Language Description   Chapter 1: Lexical Elements


Home | Highlights of Elisa | Integrating Different Paradigms | Getting Started with Elisa | Demo's  | What is Domain Orientation | Bibliography | Copyright | News | Contact | Contents

Language Description:

Lexical Elements | Basic Data Types and Expressions | Definitions | Streams | Backtracking | Statements and Special Expressions | Arrays | Lists | Descriptors | Components | Collections | Generic Components | Terms | Categories | Types | Built-in Definitions | Higher-order Definitions | External Interfaces | Index 

Data Structures: Sequences | Examples involving Lists | Trees | Graphs | Searching State Spaces | Language Processing | Knowledge Representations
Domain Modeling:

Domain Modeling | Concepts | Domain Definitions | Domain Operations | Domain Implementations | Systems | Case study: an Order processing system | Case study: an Airport Support system | Domain Orientation versus Object Orientation

Design Patterns:

Introduction | Abstract Factory | Builder | Factory Method | Prototype | Singleton | Adapter | Bridge | Composite | Decorator | Facade | Flyweight | Proxy | Chain of Responsibility | Command | Interpreter | Iterator | Mediator | Memento | Observer | State | Strategy | Template Method | Visitor 


click tracking


Send me your comments


This page was last modified on 27-09-2012 13:32:15   

free hit counter