Section 2: Lexical Structure
This chapter will describe the lexical structure of Keli. Most of the information on this page can be ignored during the first reading of this report.

2.1 Notational Conventions

The following notations are used to described the grammar of Keli (for more info, lookup EBNF):
Notation
Meaning
[ pattern ]
optional
{ pattern }
repetition
( pattern )
grouping
pattern1 | pattern2
choice
pattern1
difference; elements of pattern1 except those of pattern2
hello
terminal syntax in typewriter font

2.2 Abbreviations

The following abbreviations will be used to describe the lexical structure of Keli.
Abbreviation
Meaning
id
identifier
op
operator
alnum
alphanumeric

2.3 Lexical Program Structure

Term
Definition
program
{ lexeme | whitespace }
lexeme
id | literal | reservedOp
id
alnumId | symbolicId
alnumId
( # | ? | _ | alphabet ) { alphabet | digit |# | ? | - | _}
operator
( ~ | ! | @ | $ | % | ^ | & | * | - | = | + | / | < | > | : | \ )
alphabet
a | ... |z | A | ... | Z
digit
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
literal
integer | float | string
integer
decimal
float
decimal . decimal
decimal
digit { digit }
string
" { space | escape | gap } "
reservedOp
=
whitespace
whitestuff { whitestuff }
whitestuff
whitechar | comment
whitechar
newline | vertab | space | tab | unicodeWhitespace
newline
return linefeed | return | linefeed | formfeed
return
a carriage return
linefeed
a line feed
vertab
a vertical tab
formfeed
a form feed
space
a space
tab
horizontal tab
unicodeWhitespace
any Unicode character defined as whitespace
comment
slashes [ nonnewline { nonnewline }] newline
slashes
/ / { / }

2.4 Comments

Comments are actually whitespaces. Comments starts with 2 slahses and extends until before the following newline. For example:
1
// this is a comment
Copied!

2.5 Constant Identifiers

A constant identifier is any sequences of characters that satisfy the following grammar:
( $ | _ | alphabet ) { alphabet | digit | - | _}
For example:
Term
Validity
hello
Valid
_
Valid
true
Valid
snake_case
Valid
aVariable
Valid
x123
Valid
crazy_stuff_lol
Valid
Content-Type
Valid
12x
Invalid
Constant identifiers are used for identifying:
    1.
    Function parameter
    2.
    Type
    3.
    Object property
    4.
    Type variable

2.6 Function identifiers

Function identifiers are used for identifying functions, they can be any sequences of characters that satisfy the following grammar:
constId | ({operator }) <reservedOp>
In layman term, a function identifier can be a constant identifiers OR a sequences of symbols that are not reserved operator.
Examples of function identifiers:
Term
Validity
plus
Valid
toString
Valid
+
Valid
->
Valid
==
Valid
=
Invalid, reserved operator
Last modified 2yr ago