summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dimension/common.rules6
-rw-r--r--dimension/parse.c52
-rw-r--r--dimension/parse.h3
-rw-r--r--tests/dimension/demo.pov4
4 files changed, 63 insertions, 2 deletions
diff --git a/dimension/common.rules b/dimension/common.rules
index 72480c0..c03eee8 100644
--- a/dimension/common.rules
+++ b/dimension/common.rules
@@ -397,6 +397,12 @@ ARITH_EXPR: FLOAT_LITERAL
}
| "(" ARITH_EXPR ")" { $$ = $2; }
| IDENTIFIER
+ | "x" { $$ = dmnsn_new_ast_ivector(1, 0, 0, 0, 0); }
+ | "u" { $$ = dmnsn_new_ast_ivector(1, 0, 0, 0, 0); }
+ | "y" { $$ = dmnsn_new_ast_ivector(0, 1, 0, 0, 0); }
+ | "v" { $$ = dmnsn_new_ast_ivector(0, 1, 0, 0, 0); }
+ | "z" { $$ = dmnsn_new_ast_ivector(0, 0, 1, 0, 0); }
+ | "t" { $$ = dmnsn_new_ast_ivector(0, 0, 0, 1, 0); }
;
/* Colors */
diff --git a/dimension/parse.c b/dimension/parse.c
index a4a4c43..5756659 100644
--- a/dimension/parse.c
+++ b/dimension/parse.c
@@ -76,6 +76,58 @@ dmnsn_new_ast_float(double value)
}
dmnsn_astnode
+dmnsn_new_ast_ivector(long x, long y, long z, long f, long t)
+{
+ dmnsn_astnode astnode = dmnsn_new_astnode(DMNSN_AST_VECTOR);
+ astnode.children = dmnsn_new_array(sizeof(dmnsn_astnode));
+
+ dmnsn_astnode comp;
+
+ comp = dmnsn_new_ast_integer(x);
+ dmnsn_array_push(astnode.children, &comp);
+
+ comp = dmnsn_new_ast_integer(y);
+ dmnsn_array_push(astnode.children, &comp);
+
+ comp = dmnsn_new_ast_integer(z);
+ dmnsn_array_push(astnode.children, &comp);
+
+ comp = dmnsn_new_ast_integer(f);
+ dmnsn_array_push(astnode.children, &comp);
+
+ comp = dmnsn_new_ast_integer(t);
+ dmnsn_array_push(astnode.children, &comp);
+
+ return astnode;
+}
+
+dmnsn_astnode
+dmnsn_new_ast_vector(double x, double y, double z, double f, double t)
+{
+ dmnsn_astnode astnode = dmnsn_new_astnode(DMNSN_AST_VECTOR);
+ astnode.children = dmnsn_new_array(sizeof(dmnsn_astnode));
+
+ dmnsn_astnode comp;
+
+ comp = dmnsn_new_ast_float(x);
+ dmnsn_array_push(astnode.children, &comp);
+
+ comp = dmnsn_new_ast_float(y);
+ dmnsn_array_push(astnode.children, &comp);
+
+ comp = dmnsn_new_ast_float(z);
+ dmnsn_array_push(astnode.children, &comp);
+
+ comp = dmnsn_new_ast_float(f);
+ dmnsn_array_push(astnode.children, &comp);
+
+ comp = dmnsn_new_ast_float(t);
+ dmnsn_array_push(astnode.children, &comp);
+
+ return astnode;
+}
+
+dmnsn_astnode
dmnsn_new_ast_string(const char *value)
{
dmnsn_astnode astnode = dmnsn_new_astnode(DMNSN_AST_STRING);
diff --git a/dimension/parse.h b/dimension/parse.h
index 8a5bb93..2d946b6 100644
--- a/dimension/parse.h
+++ b/dimension/parse.h
@@ -125,6 +125,9 @@ typedef dmnsn_array dmnsn_astree;
dmnsn_astnode dmnsn_new_ast_array();
dmnsn_astnode dmnsn_new_ast_integer(long value);
dmnsn_astnode dmnsn_new_ast_float(double value);
+dmnsn_astnode dmnsn_new_ast_ivector(long x, long y, long z, long f, long t);
+dmnsn_astnode dmnsn_new_ast_vector(double x, double y, double z,
+ double f, double t);
dmnsn_astnode dmnsn_new_ast_string(const char *value);
void dmnsn_delete_astnode(dmnsn_astnode astnode);
diff --git a/tests/dimension/demo.pov b/tests/dimension/demo.pov
index 1419e35..3ecc36f 100644
--- a/tests/dimension/demo.pov
+++ b/tests/dimension/demo.pov
@@ -25,7 +25,7 @@ camera {
right <1.6, 0, 0>
look_at <0, 0, 0>
- rotate <0, 53, 0>
+ rotate 53*y
}
background {
@@ -39,7 +39,7 @@ light_source {
box {
<-1, -1, -1>, <1, 1, 1>
- rotate <45, 0, 0>
+ rotate 45*x
texture {
pigment {