public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
475be6e0a1b9eb41a235f65e7e161aecc525a88f blob 4624 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
 
(* Entry Point *)
<translation-unit> ::= (<ows> (<external-declaration> | <comment>) <ows> (<end-of-statement> | <end-of-file>))*

(* Translation Unit *)
<external-declaration> ::= <common-statement> | <function-definition>

(* Variables *)
<variable-definition>  ::= 'var' <ws> <variable-name> <ows> ':' <ows> <type> <ows> <variable-initializer>?
<constant-definition>  ::= 'const' <ws> <variable-name> <ows> ':' <ows> <type> <ows> <variable-initializer>
<variable-name>        ::= <identifier>
<variable-initializer> ::= '=' <ows> <expression>

(* Functions *)
<function-definition> ::= 'fn' <ws> <function-name> <ows> '(' ( <ows> | <ows> <function-params> <ows> ) ')' <ows> ':' <ows> <return-type> <ows> <function-body>
<function-name>       ::= <identifier>
<function-params>     ::= <identifier> <ows> ':' <ows> <type> ( <ows> ',' <ows> <function-params>)*
<return-type>         ::= <type>
<function-body>       ::= <block>
<block>               ::= '{' <ows> <statement> <ows> <comment>? (<end-of-statement> <ows> <statement> <ows>)* <end-of-statement>? <ows> '}'
<function-args>       ::= <expression> (<ows> ',' <ows> <function-args>)*
<function-call>       ::= <function-name> <ows> '(' ( <ows> | <ows> <function-args> <ows> ) ')'
<statement>           ::= <common-statement> | <if-statement> | <while-statement> | <return-statement> | <function-call> | <comment>
<if-statement>        ::= 'if' <ws> <expression> <ows> <block> ( <ows> 'else' ( <ows> <block> | <ows> <if-statement> ) )?
<while-statement>     ::= 'while' <ws> <expression> <ows> <block>
<return-statement>    ::= 'return' <ws> <expression>

(* Statements *)
<end-of-statement>    ::= ';' | <line-break>
<common-statement>    ::= <variable-definition> | <constant-definition> | <expression>
<assignment-operator> ::= '='
                        | '*='
                        | '/='
                        | '%='
                        | '+='
                        | '-='
                        | '<<='
                        | '>>='
                        | '&='
                        | '^='
                        | '|='

(* Expressions *)
<expression>                ::= <binary-expression>
<binary-expression>         ::= <assignment-expression>
<assignment-expression>     ::= <logical-or-expression> (<ows> <assignment-operator> <ows> <logical-or-expression>)*
<logical-or-expression>     ::= <logical-and-expression> (<ows> '||' <ows> <logical-and-expression>)*
<logical-and-expression>    ::= <bitwise-or-expression> (<ows> '&&' <ows> <bitwise-or-expression>)*
<bitwise-or-expression>     ::= <bitwise-xor-expression> (<ows> '|' <ows> <bitwise-xor-expression>)*
<bitwise-xor-expression>    ::= <bitwise-and-expression> (<ows> '^' <ows> <bitwise-and-expression>)*
<bitwise-and-expression>    ::= <cmp-equality-expression> (<ows> '&' <ows> <cmp-equality-expression>)*
<cmp-equality-expression>   ::= <cmp-relational-expression> (<ows> ('==' | '!=') <ows> <cmp-relational-expression>)*
<cmp-relational-expression> ::= <bitwise-shift-expression> (<ows> ('<' | '>' | '<=' | '>=') <ows> <bitwise-shift-expression>)*
<bitwise-shift-expression>  ::= <additive-expression> (<ows> ('<<' | '>>') <ows> <additive-expression>)*
<additive-expression>       ::= <multiplicative-expression> (<ows> ('+' | '-') <ows> <multiplicative-expression>)*
<multiplicative-expression> ::= <unary-expression> (<ows> ('*' | '/' | '%') <ows> <unary-expression>)*
<unary-expression>          ::= (<unary-operator> <ows>)* <primary-expression>
<unary-operator>            ::= '&'
                              | '*'
                              | '+'
                              | '-'
                              | '~'
                              | '!'
<primary-expression>        ::= <integer-literal>
                              | <variable-name>
                              | <function-call>
                              | '(' <ows> <expression> <ows> ')'

(* Identifiers *)
<type>       ::= ('u8' | 'u16' | 'u32' | 'u64') (<ows> '*')*

<identifier> ::= (<alpha> | '_') (<alpha> | <digit> | '_')*

(* Literals *)
<integer-literal> ::= <integer-base10> | <integer-base16>
<integer-base10>  ::= #'[1-9]' (<digit> | '_')* | '0'
<integer-base16>  ::= #'0[Xx]' <hex-digit> (<hex-digit> | '_')*

(* Utilities *)
<comment>      ::= '#' #'[^\n]*'
<ws>           ::= <white-space>+
<ows>          ::= <white-space>*
<white-space>  ::= <linear-space> | <line-break>
<line-break>   ::= #'[\n\v\f\r]' | '\r\n'
<linear-space> ::= #'[ \t]'
<alpha>        ::= #'[a-zA-Z]'
<digit>        ::= #'[0-9]'
<hex-digit>    ::= <digit> | #'[a-fA-F]'
<end-of-file>  ::= #'$'
debug log:

solving 475be6e ...
found 475be6e in http://lists.johnnyrichard.com/olang/20241015225750.211129-2-carlos@maniero.me/
found 791c6f0 in https://git.johnnyrichard.com/olang.git
preparing index
index prepared:
100644 791c6f0fe08ad5f69a391651d9746b120b988aa7	docs/info/olang.ebnf

applying [1/1] http://lists.johnnyrichard.com/olang/20241015225750.211129-2-carlos@maniero.me/
diff --git a/docs/info/olang.ebnf b/docs/info/olang.ebnf
index 791c6f0..475be6e 100644

Checking patch docs/info/olang.ebnf...
Applied patch docs/info/olang.ebnf cleanly.

index at:
100644 475be6e0a1b9eb41a235f65e7e161aecc525a88f	docs/info/olang.ebnf

Code repositories for project(s) associated with this public inbox

	https://git.johnnyrichard.com/olang.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox