Grammar
Notation
To describe the grammar fo Whistle, extended Backus-Naur form (EBNF) is used. The following table describes all of the used notations in the grammar specification of Whistle.
usage | notation |
---|---|
definition | = |
concatination | , |
alteration | | |
optional | [ , ] |
repetition | { , } |
grouping | ( , ) |
string | " , " |
exception | - |
range | ... |
comment | // |
comment | /* , */ |
Characters, letters and digits
There are a few predefined values that could not easily be written as valid EBNF, these are instead written with the value of a comment which describes its content.
Whitespace
In Whistle whitespace serves no purpose but to separate tokens and if included in a literal that explicitly allows it (string and character literals).
Comments
Just like whitespace comments get ignored unless it is in a literal that explicitly allows it. Whistle provides two comment types: line comments and multiline/inline comments.
Identifiers
Identifiers are mainly used in Whistle to name certain entities such as types, functions and variables. Some identifiers however are reserved as keywords and are not allowed for naming.
Keywords
The following identifiers reserved as keywords in Whistle are currently:
And here are some of the planned keywords:
Operators
Operators are defined by one or more operator characters coming after each other.
Literals
Literals in Whistle represent a fixed value.
Tips
Tips are in Whistle similar to macros. They tell the compiler certain stuff and are very useful for a plethera of reasons. There are two types of tips in Whistle: line tips and multiline/inline tips.
Expressions
Expressions specify the computation of a value by applying operators to an operands.
Disclaimers:
- The syntax for conditionals in Whistle is still undecided
- Both index and slice array accessing is not ready along with arrays which is why it is commented
Statements
Statements control the execution and flow of the program.
Grammar
Finally the grammar of the Whistle programming language can be described as zero or more statement
s repeating.