summaryrefslogtreecommitdiffstats
path: root/dimension/common.rules
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-04-07 01:17:28 -0400
committerTavian Barnes <tavianator@gmail.com>2010-04-07 01:17:28 -0400
commit7d6663eeb68bf9d0a3dff86128827c0c1d85df69 (patch)
tree7e9c5775d78e0868bf315eeadcfcadacec784707 /dimension/common.rules
parent2a6bb6c6e0c7d5019e484ab4393941b8801d63ea (diff)
downloaddimension-7d6663eeb68bf9d0a3dff86128827c0c1d85df69.tar.xz
Implement CSG in front-end.
Diffstat (limited to 'dimension/common.rules')
-rw-r--r--dimension/common.rules51
1 files changed, 51 insertions, 0 deletions
diff --git a/dimension/common.rules b/dimension/common.rules
index d5e8994..e477df5 100644
--- a/dimension/common.rules
+++ b/dimension/common.rules
@@ -114,6 +114,7 @@ CAMERA_MODIFIER: "angle" FLOAT {
/* Objects */
OBJECT: FINITE_SOLID_OBJECT
+ | CSG_OBJECT
| LIGHT_SOURCE
| "object" "{"
IDENTIFIER
@@ -196,6 +197,56 @@ SPHERE: "sphere" "{"
}
;
+CSG_OBJECT: UNION
+ | INTERSECTION
+ | DIFFERENCE
+ | MERGE
+;
+
+UNION: "union" "{"
+ OBJECTS
+ OBJECT_MODIFIERS
+ "}"
+ {
+ $$ = dmnsn_new_astnode2(DMNSN_AST_UNION, @$, $3, $4);
+ }
+;
+
+INTERSECTION: "intersection" "{"
+ OBJECTS
+ OBJECT_MODIFIERS
+ "}"
+ {
+ $$ = dmnsn_new_astnode2(DMNSN_AST_INTERSECTION, @$, $3, $4);
+ }
+;
+
+DIFFERENCE: "difference" "{"
+ OBJECTS
+ OBJECT_MODIFIERS
+ "}"
+ {
+ $$ = dmnsn_new_astnode2(DMNSN_AST_DIFFERENCE, @$, $3, $4);
+ }
+;
+
+MERGE: "merge" "{"
+ OBJECTS
+ OBJECT_MODIFIERS
+ "}"
+ {
+ $$ = dmnsn_new_astnode2(DMNSN_AST_MERGE, @$, $3, $4);
+ }
+;
+
+OBJECTS: OBJECT OBJECT {
+ $$ = dmnsn_new_astnode2(DMNSN_AST_ARRAY, @$, $1, $2);
+ }
+ | OBJECTS OBJECT {
+ $$ = $1;
+ dmnsn_array_push($$.children, &$2);
+ }
+
LIGHT_SOURCE: "light_source" "{"
VECTOR "," COLOR
"}"