Download NQC Programmer`s Guide

Transcript
NQC Programmer's Guide
2.1.2 Whitespace
Whitespace (spaces, tabs, and newlines) is used to separate tokens and to make programs
more readable. As long as the tokens are distinguishable, adding or subtracting
whitespace has no effect on the meaning of a program. For example, the following lines
of code both have the same meaning:
x=2;
x
=
2
;
Some of the C++ operators consist of multiple characters. In order to preserve these
tokens whitespace must not be inserted within them. In the example below, the first line
uses a right shift operator ('>>'), but in the second line the added space causes the '>'
symbols to be interpreted as two separate tokens and thus generate an error.
x = 1 >> 4; // set x to 1 right shifted by 4 bits
x = 1 > > 4; // error
2.1.3 Numerical Constants
Numerical constants may be written in either decimal or hexadecimal form. Decimal
constants consist of one or more decimal digits. Hexadecimal constants start with 0x or
0X followed by one or more hexadecimal digits.
x = 10;
// set x to 10
x = 0x10; // set x to 16 (10 hex)
2.1.4 Identifiers and Keywords
Identifiers are used for variable, task, and function names. The first character of an
identifier must be an upper or lower case letter or the underscore ('_'). Remaining
characters may be letters, numbers, an underscore.
A number of potential identifiers are reserved for use in the NQC language itself. These
reserved words are call keywords and may not be used as identifiers. A complete list of
keywords appears below:
__event_src
__res
__taskid
abs
__nolist
__sensor
__type
acquire
Page 3