-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgrammar.ebnf
More file actions
50 lines (48 loc) · 991 Bytes
/
Copy pathgrammar.ebnf
File metadata and controls
50 lines (48 loc) · 991 Bytes
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
program =
function_definition | statement | expression
;
expression =
function_call | boolean | math_expression | string | number | identifier
;
statement =
(function_return | variable_define), ";"
;
function_call =
identifier, arguments
;
math_expression = l1;
l1 = l2, l1_infix;
l1_infix = ("+" | "-"), l2;
l2 = l3, l2_infix;
l2_infix = ("*" | "/"), l3;
l3 = l4, l3_infix;
l3_infix = "^", l4;
l4 = parenthetical_expression | number | identifier | function_call;
parenthetical_expression = "(", expression, ")";
function_definition =
"fn ", identifier, arguments, " { ", (statement | expression), " } "
;
variable_define =
"let ", identifier, " = ", expression
;
function_return =
"return ", expression
;
(* Defined by alphanumeric1 *)
identifier =
(0-9) | (a-z) | (A-Z)
;
arguments =
"(", [","]expression, ")"
;
boolean =
"true" | "false"
;
string =
"\"", (identifier | " "), "\""
;
(* Defined by digit1 *)
number =
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
;
comment = identifier;