Annotated King Reference Manual/Lexical Elements
Lexical Elements
editItems
editEach 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
editA 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
editSingle
edit& ' ( ) * + , - . / : ; < = > @ [ ] | { } ^ \
Compound
edit=> .. <- /= >= <= <>
Rationale
edit-
Discussion
edit-
Identifiers
editExamples
editInvalid
V_String
Is_Empty
Latin_1_String
Syntax
editidentifier ::= 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
editAn 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
editList
editall 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
editExamples
edituniversal_integer
edit99
478E70
16#CAFE#
universal_real
edit3.14
0.0
0.25
16#F.FF#E+2
36#THE_QUICK_BROWN_FOX_JUMPS.OVER_THE_LAZY_DOG#
Syntax
editnumeric_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
editExamples
edit'@'
'Δ'
' '
'''
Syntax
editcharacter_literal ::= 'graphic_character'
Rationale
edit-
Discussion
edit-
String Literals
editExamples
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
editstring_literal ::= "{string_element}" string_element ::= non_quotation_mark_graphic_character
Rationale
edit-
Discussion
edit-
Comments
editExamples
edit-- Returns the number of Elements in List
Syntax
editcomment ::= --{non_end_of_line_graphic_character}
Rationale
edit-
Discussion
edit-