The LPC Reference Manual
Copyright © 1995 - 1997 BeeHive Internet technologies, Inc.
1. Introduction
1.1. Purpose
This document is a formal description of the LPC programming language.
The LPC programming language is derived from C and named after its primary
creator, Lars Pensjö. Several dialects of LPC exist; the programming
language described here is the one used in Dworkin's Generic Driver
(DGD) version 1.1.
1.2. History
2. Environment
3. Language
In the syntax notation of this document, syntactic catagories are
indicated by italic type.
3.1. Lexical elements
3.1.1. Tokens
A token is the minimal lexical element of the language. The
categories of tokens are:
identifiers,
keywords,
constants,
operators and
punctuators. Tokens are separated by
white space: blanks, horizontal and vertical tabs, newlines, carriage returns,
formfeeds and comments.
3.1.2. Comments
A comment is a sequence of characters starting with the characters /*
and terminated by the characters */. All characters in between are
part of the comment. Comments count as whitespace separating tokens, and
may not be nested. The sequence /* does not start a comment if it
is part of a string.
An identifier is an arbitrary long sequence of letters, digits and
underscores. The first character must be a letter or underscore. Upper- and
lower-case letters are different. Only the first 1023 characters of
identifiers are significant.
The following identifiers are reserved for use as keywords:
atomic do int return void
break else mapping rlimits while
case float mixed static
catch for nomask string
continue if object switch
default inherit private varargs
The keyword atomic is reserved, but currently unused.
A constant is either an
integer constant,
floating constant,
string constant or
character constant.
An integer constant is a decimal constant, octal constant
or hexadecimal constant.
A sequence of digits is taken to be a decimal constant (base ten)
unless it begins with 0. A sequence of digits starting with 0
and not including 8 or 9 is an octal constant
(base 8). A sequence of digits and upper- or lower-case letters in range
A through F, preceded by 0x or 0X is a
hexadecimal constant (base 16, where A through F
have the decimal values 10 through 15).
Integer constants are represented by 32 bit 2's complement arithmetic,
and range from -2147483648 through 2147483647. It is an error to specify a
decimal constant that is too large to be represented. Octal
constants and hexadecimal constants, when too large, are
truncated to the lower 32 bits.
A floating constant consists of an integer part, a decimal point, a
fraction part, and an exponent part, consisting of an e or E
and an optionally signed integer exponent. Either the integer part or the
fraction part, but not both, may be missing. Either the decimal point and
fraction part, or the exponent part, but not both, may be missing.
Floating constants represent a floating point number in the range of
-1.79769313485E308 through 1.79769313485E308, the smallest possible number
being -2.22507385851E-308. It is an error to specify a floating constant
that is too large to be represented. Numbers which are too small are
flushed to zero.
A string constant is a sequence of zero or more characters enclosed
in double quotes. All characters, with the exception of newline, can be used in
a string constant. A backslash character \ introduces an
escape sequence, which consists of at least 2 and at most 5 characters
(including the backslash), and which is translated into a single character in
the string. The following escape sequences can be used:
\a = 007 (bell) \o
\b = 010 (backspace) \oo
\f = 014 (form feed) \ooo
\n = 012 (newline) \xh
\r = 015 (carriage return) \xhh
\t = 011 (horizontal tab) \xhhh
\v = 013 (vertical tab) \c
The value of \a, \b, \f, \n, \r,
\t and \v is the octal value shown. \o,
\oo and \ooo constitute an integer of at most 3 octal
digits, the octal value of which specifies a single character. \xh,
\xhh and \xhhh constitute an integer of at most 3 hexadecimal
digits, the hexadecimal value of which specifies a single character. All other
escape sequences \c specify the character c (any character
except a, b, f, n, r, t,
v, x, or a digit), which itself is not interpreted in any
special way.
A character constant consists of a single character or escape sequence,
enclosed in single quotes. All characters except newline can be used.
Escape sequences are handled as with string
constants.
The following are operators:
[ ] ( ) ->
++ -- + - ~ ! ... catch
* / % << >> < > <= >= == != & ^ | && ||
? :
= *= /= %= += -= <<= >>= &= ^= |=
,
3.2. Expressions
3.3. Constant expressions
3.4. Declarations
3.5. Statements
3.6. Inheritance
3.7. Preprocessing directives
|
System information
History
Rules
Wizards
Wizards agreement
LPC
Historical
|