Next: , Previous: , Up: Grammar   [Contents][Index]

4.1 Primitives

At the lowest level, coNCePTuaL programs are composed of identifiers, strings, and integers (and a modicum of punctuation). Identifiers consist of a letter followed by zero or more alphanumerics or underscores. ‘potato’, ‘x’, and ‘This_is_program_123’ are all examples of valid identifiers. Identifiers are used for two purposes: variables and keywords. Variables—referred to in the formal grammar as <ident>s—can be bound but not assigned. That is, once a variable is given a value it retains that value for the entire scope although it may be given a different value within a subordinate scope for the duration of that scope. All variables are of integer type. There are a number of variables that are predeclared and maintained automatically by coNCePTuaL. These are listed and described in Predeclared variables. Predeclared variables can be used by coNCePTuaL programs but cannot be redeclared; an attempt to do so will result in a compile-time error message.

Keywords introduce actions. For example, SEND and RECEIVE are keywords. (A complete list of coNCePTuaL keywords is presented in Keywords.) Most keywords can appear in multiple forms. For example, OUTPUT and OUTPUTS are synonymous, as are COMPUTE and COMPUTES, A and AN, and TASK and TASKS. The intention is for programs to use whichever sounds better in an English-language sentence. Keywords may not be used as variable names; an attempt to do so will cause the compiler to output a parse error.

As a special case to increase program readability, a single ‘-’ preceding a keyword is treated as a whitespace character. Hence, ‘INTEGER-SIZED PAGE-ALIGNED MESSAGE’ is equivalent to ‘INTEGER SIZED PAGE ALIGNED MESSAGE’ and ‘10 64-BYTE MESSAGES’ is equivalent to ‘10 64 BYTE MESSAGES’. However, ‘x-3’ and ‘3-x’ still represent subtraction operations.

Although identifiers are case insensitive—‘SEND’ is the same as ‘send’ is the same as ‘sENd’—to increase clarity, this manual presents keywords in uppercase and variables in lowercase.

Strings consist of double-quoted text. Within a string—and only within a string—whitespace and case are significant. In particular, a literal newline is honored but can be suppressed by preceding it with a backslash as in the following example:

"This string\
contains some
newline characters."

⇒ This string contains some
newline characters.

Use ‘\"’ for a double-quote character, ‘\\’ for a backslash, ‘\t’ for a tab character, ‘\r’ for a carriage-return character, and ‘\n’ for a newline character. All other escape sequences produce a warning message and are discarded. As examples of valid escape-sequence usage, the string "April 2015" represents the text “April 2015” and "I store \"stuff\" in C:\\MyStuff." represents the text “I store "stuff" in C:\MyStuff.”

Integers consist of an optional ‘+’ or ‘-11 followed by one or more digits followed by an optional multiplier. This multiplier is unique to coNCePTuaL and consists of one of the following four letters:

K’ (kilo)

multiplies the integer by 1,024

M’ (mega)

multiplies the integer by 1,048,576

G’ (giga)

multiplies the integer by 1,073,741,824

T’ (tera)

multiplies the integer by 1,099,511,627,776

A multiplier can also be ‘E’ (exponent) followed by a positive integer. An ‘E’ multiplier multiplies the base integer by 10 raised to the power of the positive integer following the ‘E’.

Integers can also be written as ordinals, with an ‘ST’, ‘ND’, ‘RD’, or ‘TH’ suffix. These suffixes are ignored by the lexer but can make the PERCENTILE aggregate function (see Aggregate functions) look more English-like (as in, ‘THE 95TH PERCENTILE’).

Some examples of valid integers include ‘2015’, ‘-42’, ‘64K’ (= 65,536), 8E3’ (= 8,000) , and ‘38TH’.



From the lexer’s perspective, integers are always unsigned and ‘+’ or ‘-’ are merely operators (see Arithmetic expressions). The parser, however, applies unary operators to integer literals. This alteration is evident in the output of the dot_ast backend (see The dot_ast backend).

Next: , Previous: , Up: Grammar   [Contents][Index]

Scott Pakin,