-
Notifications
You must be signed in to change notification settings - Fork 25
/
openscad.bnf
114 lines (94 loc) · 3.01 KB
/
openscad.bnf
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<input> ::=
<empty>
<use> <input>
<statement> <input>
<body> ::=
<empty>
<statement> <body>
<statement> ::=
';'
--Null operation statement is superfluous
'{' <body> '}'
<module_instantiation>
<identifier> '=' <expression> ';'
"module" <identifier> '(' <parameters> <optional_commas> ')' <statement>
"function" <identifier> '(' <parameters> <optional_commas> ')' '=' <expression> ';'
--Optional commas in the above two seem strange to me. We can have for e.g. module foo(a,,,,,,b){} how on earth can this be useful?
--I agree that is makes sence for a module instantiation because we might want to pass undef, but for declarations its just a way
--of ensuring we don't have access to unnamed module parameters, so why have them at all?
<children_instantiation> ::=
<module_instantiation>
'{' <module_instantiation_list> '}'
<if_statement> ::=
"if" '(' <expression> ')' <children_instantiation>
-- why can't we just have statements in our if why is the following invalid!? if(true) { a=1; cube([10,a,10]); }
<ifelse_statement> ::=
<if_statement>
<if_statement> "else" <children_instantiation>
<module_instantiation> ::=
<single_module_instantiation> ';'
<single_module_instantiation> <children_instantiation>
<ifelse_statement>
<module_instantiation_list> ::=
<empty>
<module_instantiation_list> <module_instantiation>
<single_module_instantiation> ::=
<identifier> '(' <arguments> ')'
<identifier> ':' <single_module_instantiation>
-- this is interesting, you can have a label before a module instantiation e.g. foo: cube([10,10,10]); although what this is for I have no idea.
'!' <single_module_instantiation>
'#' <single_module_instantiation>
'%' <single_module_instantiation>
'*' <single_module_instantiation>
<expression> ::=
"true"
"false"
"undef"
<identifier> --variable
<expression> '.' <identifier>
<string>
<number>
'[' <expression> ':' <expression> ']'
'[' <expression> ':' <expression> ':' <expression> ']'
'[' <optional_commas> ']'
'[' <vector_expression> <optional_commas> ']'
<expression> '*' <expression>
<expression> '/' <expression>
<expression> '%' <expression>
<expression> '+' <expression>
<expression> '-' <expression>
<expression> '<' <expression>
<expression> "<=" <expression>
<expression> "==" <expression>
<expression> "!=" <expression>
<expression> ">=" <expression>
<expression> '>' <expression>
<expression> "&&" <expression>
<expression> "||" <expression>
'+' <expression>
'-' <expression>
'!' <expression>
'(' <expression> ')'
<expression> '?' <expression> ':' <expression>
<expression> '[' <expression> ']'
<identifier> '(' <arguments> ')'
<optional_commas> ::=
<empty>
',' <optional_commas>
<vector_expr> ::=
<expression>
<vector_expr> ',' <optional_commas> <expression>
<parameters> ::=
<empty>
<parameter>
<parameters> ',' <optional_commas> <parameter>
<parameter> ::=
<identifier>
<identifier> '=' <expression>
<arguments> ::=
<empty>
<argument>
<arguments> ',' <optional_commas> <argument>
<argument> ::=
<expression>
<identifier> '=' <expression>