blob: c6b4e0187260950c0c36342acb32e37ee20e449e (
plain)
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
|
Polyp = { Statement ";" } .
Statement = Declaration | Call .
Declaration = VariableDeclaration | FunctionDeclaration .
VariableDeclaration = [ "var" ] VariableList ":=" ExpressionList .
FunctionDeclaration = [ "def" ] Function ":=" Expression .
VariableList = variable { "," variable } .
ExpressionList = Expression { "," Expression } .
// ForLoop = "for" Condition Block .
// Block = "{" Polyp "}" .
Function = identifier Parameters .
Parameters = "(" [ ParameterList ] ")" .
ParameterList = variable { "," variable } .
Call = identifier "(" [ ExpressionList ] ")" .
BuiltinCall = identifier "(" [ ExpressionList ] ")" .
Expression = Expr { log_op Expr } .
Expr = UnaryExpr | Expr binary_op UnaryExpr .
UnaryExpr = [ "(" ] PrimaryExpr [ ")" ] | unary_op [ "(" ] PrimaryExpr [ ")" ] .
PrimaryExpr = BuiltinCall | Call | Expr | Operand .
Operand = Literal | identifier .
Literal = int_lit | float_lit .
binary_op = rel_op | math_op .
log_op = "|" | "&" .
rel_op = "=" | "!=" | "<" | ">" | "<=" | ">=" | "<>" .
math_op = "+" | "-" | "*" | "/" | "%" | "^" | "**" .
unary_op = "+" | "-" | "!" | "¬" | "~" .
// Boolean = true | false .
// true = "True" .
// false = "False" .
// none = "None" .
variable = identifier .
identifier = letter { letter | unicode_digit } .
unicode_letter = "a" ... "z" | "A" ... "Z" .
unicode_digit = decimal_digit .
letter = unicode_letter | "_" .
decimal_digit = "0" ... "9" .
octal_digit = "0" ... "7" .
hex_digit = "0" ... "9" | "A" ... "F" | "a" ... "f" .
int_lit = decimal_lit | octal_lit | hex_lit .
decimal_lit = ( "1" ... "9" ) { decimal_digit } | "0" .
octal_lit = "0" octal_digit { octal_digit } .
hex_lit = "0" ( "x" | "X" ) hex_digit { hex_digit } .
float_lit = decimals "." [ decimals ] [ exponent ] |
decimals exponent |
"." decimals [ exponent ] |
[ "+" | "-" ] "nan" | [ "+" | "-" ] "inf" .
decimals = decimal_digit { decimal_digit } .
exponent = ( "e" | "E" ) [ "+" | "-" ] decimals .
// char_lit = "'" ( unicode_value | byte_value ) "'" .
// unicode_value = unicode_char | little_u_value | big_u_value | escaped_char .
// byte_value = octal_byte_value | hex_byte_value .
// octal_byte_value = `\` octal_digit octal_digit octal_digit .
// hex_byte_value = `\` "x" hex_digit hex_digit .
// little_u_value = `\` "u" hex_digit hex_digit hex_digit hex_digit .
// big_u_value = `\` "U" hex_digit hex_digit hex_digit hex_digit
// hex_digit hex_digit hex_digit hex_digit .
// escaped_char = `\` ( "a" | "b" | "f" | "n" | "r" | "t" | "v" | `\` | "'" | `"` ) .
// StringLit = string_lit { string_lit } .
// string_lit = raw_string_lit | interpreted_string_lit .
// raw_string_lit = "`" { unicode_char } "`" .
// interpreted_string_lit = `"` { unicode_value | byte_value } `"` .
|