Logo
The Glaux Operating System Project

Glaux High Level Language Specification

Draft 2017-01-29

Introduction

The Glaux High Level Language Specification specifies the syntax and semantics of the Glaux High Level programming language. However, this page is an early draft and is subject to changes.

Target Audience

The Glaux High Level Language Specification is targeted at programmers writing programs in the Glaux High Level programming language and programmers writing compilers for the Glaux High Level programming language.

Philosophy

The philosophy behind the Glaux High Level programming language is that the programmer should write safe and correct code, regardless of the computing aspect. For this reason, the Glaux High Level programming language enforces semantics and thorough compile-time proofs in order to ensure that the input code is correct.

Errata

There are no array constructs. Parentheses that specify expression precedence are not in the general syntax.

Syntax

The general syntax of the Glaux High Level programming language is described in this section.

<decimal> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
<binary> ::= "0" | "1"
<octal> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7"
<hexadecimal> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "A" | "B" | "C" | "D" | "E" | "F" | "a" | "b" | "c" | "d" | "e" | "f"
<upper> ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
<lower> ::= "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
<letter> ::= <upper> | <lower>

<identifier> ::= "_" | <letter> | <identifier> "_" | <identifier> <letter> | <identifier> <decimal>

<integer_decimal> ::= <decimal> | "0d" <decimal> | "0D" <decimal> | <integer_decimal> <decimal>
<integer_binary> ::= "0b" <binary> | "0B" <binary> | <integer_binary> <binary>
<integer_octal> ::= "0o" <octal> | "0O" <octal> | <integer_octal> <octal>
<integer_hexadecimal> ::= "0x" <hexadecimal> | "0X" <hexadecimal> | <integer_hexadecimal> <hexadecimal>
<integer> ::= <integer_decimal> | <integer_binary> | <integer_octal> | <integer_hexadecimal>

<boolean_true> ::= "TRUE"
<boolean_false> ::= "FALSE"
<boolean> ::= <boolean_true> | <boolean_false>

<operator_unary> ::= "*" | "&" | "+" | "-" | "!"
<operator_binary> ::= "*" | "/" | "+" | "-" | "&" | "|" | "^" | "<<" | ">>" | "==" | "!=" | "<" | ">" | "<=" | ">=" | "&&" | "||" | "^^"
<operator_range> ::= "&" | "|" | "^"

<expression> ::= <integer> | <boolean> | <identifier> | <operator_unary> <expression> | <expression> <operator_binary> <expression>

<range_including_including> ::= "[" <expression> "," <expression> "]"
<range_including_excluding> ::= "[" <expression> "," <expression> ")"
<range_excluding_including> ::= "(" <expression> "," <expression> "]"
<range_excluding_excluding> ::= "(" <expression> "," <expression> ")"
<range_elements_main> ::= <expression> | <range_elements_main> "," <expression>
<range_elements> ::= "{" <range_elements_main> "}"
<range_builtin> ::= "U8_RANGE" | "I8_RANGE" | "U16_RANGE" | "I16_RANGE" | "U32_RANGE" | "I32_RANGE" | "U64_RANGE" | "I64_RANGE" | "USIZE_RANGE" | "ISIZE_RANGE"
<range> ::= <range_including_including> | <range_including_excluding> | <range_excluding_including> | <range_excluding_excluding> | <range_elements> | <range> <operator_range> <range>

<modifier_var> ::= "global" | "local"
<modifier_type> ::= "const" | "values" "(" <range> ")" | "indexes" "(" <range> ")"
<modifiers_type> ::= TODO

<type_builtin_int> ::= "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "u64" | "i64" | "usize" | "isize"
<type_builtin_bool> ::= "bool"
<type_builtin> ::= <type_builtin_int> | <type_builtin_bool>

<type_userdef> ::= <identifier>

<type> ::= <type_builtin> | <type_userdef>

<type_definition> ::= "typedef" <type> <modifiers_type> <type_userdef>

<assignment_left> ::= <expression> | <assignment_left> "," <expression>
<assignment_right> ::= <function> | <expression> | <assignment_right> "," <function> | <assignment_right> "," <expression>
<assignment> ::= <assignment_left> "=" <assignment_right>

<var_definition_left> ::= TODO
<var_definition_right> ::= <function> | <expression> | <var_definition_right> "," <function> | <var_definition_right> "," <expression>
<var_definition> ::= <var_definition_left> "=" <var_definition_right>

<var_declaration> ::= TODO

Identifiers

Identifiers are used for naming variables, functions, user-defined types and user-defined modifiers. An identifier may contain all of the letters of the latin alphabet, uppercase and lowercase, number digits and underscores. The identifier shall not start from a number digit.

Numerals

Decimal Numerals

Binary Numerals

Octal Numerals

Hexadecimal Numerals