Annotated King Reference Manual/Lexical Elements

Lexical Elements

Items

Each lexical element is formed from a sequence of characters, and is either a delimiter, an identifier, a reserved word, a numeric_literal, a character_literal, a string_literal, or a comment.

The text of a compilation is divided into lines.

Separators code points are: 16#20# (SPACE, except within a comment, a string_literal, or a character_literal), 16#0A# (LINE FEED), 16#0D# (CARRIAGE RETURN).

Rationale

A compilation is a sequence of lines, conceptually terminated by a line terminator. King does not specify what character(s), if any, make up a line terminator in a compilation text. Common text file formats on the kinds of systems that King is intended to be used on use one or two characters (CR, LF) as line terminators, so this is probably correct in practice (if King is ever implemented).

Discussion

-

Delimiters

Single

&    '    (    )    *    +    ,    -    .    /    :    ;    <    =    >    @    [    ]    |    {    }    ^    \

Compound

=>    ..    <-    /=    >=    <=     <>

Rationale

-

Discussion

-

Identifiers

Examples

Invalid

V_String

Is_Empty

Latin_1_String

Syntax

identifier ::= identifier_start {underline identifier_extend}

identifier_start ::= letter_uppercase {letter_uppercase | number_decimal}
                     {letter_lowercase | number_decimal}

identifier_extend ::= identifier_start | number_decimal {letter_uppercase | number_decimal}
                      {letter_lowercase | number_decimal}

Once built as above, specifics rules (see TBD) are enforced to define a valid identifier.

Rationale

An identifier is made up of words separated by underlines. There is an initial word and zero or more subsequent words. The initial word must begin with a capital letter. Subsequent words can begin with a capital letter or a digit.

Discussion

-

Reserved Words

List

all and

begin body

case constant

declare delta digits

else else_if end exit

for function

hidden

if in is

loop

macro map module

new not null

of or others out

procedure

range record renames return reverse

select separate sequence set some subtype

task then type

use

wait when with

xor

Rationale

-

Discussion

-

Numeric Literals

Examples

universal_integer

99

478E70

16#CAFE#

universal_real

3.14

0.0

0.25

16#F.FF#E+2

36#THE_QUICK_BROWN_FOX_JUMPS.OVER_THE_LAZY_DOG#

Syntax

numeric_literal ::= decimal_literal | based_literal

decimal_literal ::= numeral [.numeral] [exponent]

numeral ::= digit {[underline] digit}

exponent ::= E [+] numeral | E - numeral

digit ::= number_decimal

based_literal ::= base # based_numeral [.based_numeral] # [exponent]

base ::= numeral

based_numeral ::= extended_digit {[underline] extended_digit}

extended_digit ::= digit | letter_uppercase

Rationale

-

Discussion

-

Character Literals

Examples

'@'

'Δ'

' '

'''

Syntax

character_literal ::= 'graphic_character'

Rationale

-

Discussion

-

String Literals

Examples

"une soirée passée à étudier les mathématiques ℕ⊂𝕂..." -- Unicode characters

" " -- Space character

"" -- Null string

(See expressions for examples of building strings with quotation mark)

Syntax

string_literal ::= "{string_element}"

string_element ::= non_quotation_mark_graphic_character

Rationale

-

Discussion

-

Comments

Examples

-- Returns the number of Elements in List

Syntax

comment ::= --{non_end_of_line_graphic_character}

Rationale

-

Discussion

-