Annotated King Reference Manual/Lexical Elements

Lexical Elements

edit

Items

edit

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

edit

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

edit

-

Delimiters

edit

Single

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

Compound

edit

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

Rationale

edit

-

Discussion

edit

-

Identifiers

edit

Examples

edit
Invalid

V_String

Is_Empty

Latin_1_String

Syntax

edit
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

edit

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

edit

-

Reserved Words

edit

List

edit

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

edit

-

Discussion

edit

-

Numeric Literals

edit

Examples

edit

universal_integer

edit
99

478E70

16#CAFE#

universal_real

edit
3.14

0.0

0.25

16#F.FF#E+2

36#THE_QUICK_BROWN_FOX_JUMPS.OVER_THE_LAZY_DOG#

Syntax

edit
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

edit

-

Discussion

edit

-

Character Literals

edit

Examples

edit
'@'

'Δ'

' '

'''

Syntax

edit
character_literal ::= 'graphic_character'

Rationale

edit

-

Discussion

edit

-

String Literals

edit

Examples

edit
"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

edit
string_literal ::= "{string_element}"

string_element ::= non_quotation_mark_graphic_character

Rationale

edit

-

Discussion

edit

-

Comments

edit

Examples

edit
-- Returns the number of Elements in List

Syntax

edit
comment ::= --{non_end_of_line_graphic_character}

Rationale

edit

-

Discussion

edit

-