Next: Method Structure
Prev: Example Method
C-- methods are character sequences called
tokens. There are many different types of tokens, ranging from
single characters to lines of text. C-- methods are assembled
from sequences of tokens.
The following characters and pairs of characters are tokens:
{ } [ ] #[ %[ ( ) (| |) (> <) .. ; , = !
- + * / % == != > >= < <= . || && ? | : @
These tokens are used as operators and as punctuation in various types
of expressions.
You can use identifiers as tokens and as parts of tokens. An
identifier is a sequence of alphabetical and numeric characters or
underlines beginning with an alphabetical character or an underline.
Identifiers in C-- are case-sensitive, so the identifiers
car and CAr are not equivalent. The following are valid
identifiers:
we_3_kings obj aBy themselves, identifiers usually represent variables. However, certain identifiers have special meanings to the parser. These reserved words are used in writing certain kinds of statements and expressions. They are:
var if else while for switch case default break continue return catch any with handler pass to in fork atomic non_atomic(
fork, atomic, and non_atomic are not actually used
by the current version of Coldmud, but are reserved for future use.)
There are several kinds of tokens for denoting literal expressions of various data types. These are integers, denoted by a sequence of digits; strings, denoted by a sequence of characters enclosed in double quotes; dbrefs, denoted by a sharp (#) and a number; symbols, denoted by a single forward quote (') and an identifier or string; and error codes, denoted by a tilde (~) and an identifier or string. These literals are described more fully in Data Types, along with the data types they represent.
A name token is a dollar sign ($) followed by an identifier or string. Names refer to objects indirectly; see Names.
Tokens which contain identifiers but begin with a distinguishing
character (that is, symbol tokens, error code tokens, and name tokens)
relax the restriction that identifiers not begin with an integer. Thus,
$23a is a valid name token, even though 23a is not an
identifier.
Finally, a comment token is any text on a line after a pair of slashes (//). Comment tokens can be used as statements in methods; such statements are ignored by the interpreter.