summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-03-08 23:21:31 -0500
committerTavian Barnes <tavianator@gmail.com>2010-03-08 23:21:31 -0500
commitdf0f06adcddb9c40b7cfe736a1a106a874f3513e (patch)
tree5c5a83749e6d348e4086fba65308a504bf89c08c
parent533a684f0ec4d9afa3940ba5c4f516711015ed00 (diff)
downloaddimension-df0f06adcddb9c40b7cfe736a1a106a874f3513e.tar.xz
Don't treat colors and vectors as different types.
This allows things like 0.5*White, where White was #defined to be a color. POV-Ray's colors.inc almost parses now.
-rw-r--r--dimension/common.rules6
-rw-r--r--dimension/grammar.epilogue2
-rw-r--r--dimension/parse.h2
-rw-r--r--dimension/realize.c4
-rwxr-xr-xtests/dimension/demo.sh14
-rwxr-xr-xtests/dimension/directives.sh8
6 files changed, 14 insertions, 22 deletions
diff --git a/dimension/common.rules b/dimension/common.rules
index cc7411f..72480c0 100644
--- a/dimension/common.rules
+++ b/dimension/common.rules
@@ -403,11 +403,9 @@ ARITH_EXPR: FLOAT_LITERAL
COLOR: COLOR_BODY {
$$ = $1;
- $$.type = DMNSN_AST_COLOR;
}
| "color" COLOR_BODY {
$$ = $2;
- $$.type = DMNSN_AST_COLOR;
}
;
@@ -477,7 +475,7 @@ COLOR_KEYWORD_ITEM: "identifier" {
"Unbound identifier '%s'", $1);
free($1);
YYERROR;
- } else if (symbol->type != DMNSN_AST_COLOR) {
+ } else {
dmnsn_astnode eval = dmnsn_eval_vector(*symbol, symtable);
if (eval.type == DMNSN_AST_NONE) {
free($1);
@@ -486,8 +484,6 @@ COLOR_KEYWORD_ITEM: "identifier" {
dmnsn_copy_children($<astnode>0, eval);
dmnsn_delete_astnode(eval);
- } else {
- dmnsn_copy_children($<astnode>0, *symbol);
}
free($1);
diff --git a/dimension/grammar.epilogue b/dimension/grammar.epilogue
index 877b876..6ea459d 100644
--- a/dimension/grammar.epilogue
+++ b/dimension/grammar.epilogue
@@ -181,8 +181,6 @@ dmnsn_astnode_string(dmnsn_astnode_type astnode_type)
dmnsn_astnode_map(DMNSN_AST_DOT_T, ".t");
dmnsn_astnode_map(DMNSN_AST_DOT_TRANSMIT, ".transmit");
- dmnsn_astnode_map(DMNSN_AST_COLOR, "color");
-
dmnsn_astnode_map(DMNSN_AST_IDENTIFIER, "identifier");
dmnsn_astnode_map(DMNSN_AST_STRING, "string");
diff --git a/dimension/parse.h b/dimension/parse.h
index 9511eab..8a5bb93 100644
--- a/dimension/parse.h
+++ b/dimension/parse.h
@@ -95,8 +95,6 @@ typedef enum {
DMNSN_AST_AND,
DMNSN_AST_OR,
- DMNSN_AST_COLOR,
-
DMNSN_AST_IDENTIFIER,
DMNSN_AST_STRING,
diff --git a/dimension/realize.c b/dimension/realize.c
index e5dfcb4..c41ac93 100644
--- a/dimension/realize.c
+++ b/dimension/realize.c
@@ -59,7 +59,7 @@ dmnsn_realize_vector(dmnsn_astnode astnode)
static dmnsn_color
dmnsn_realize_color(dmnsn_astnode astnode)
{
- dmnsn_assert(astnode.type == DMNSN_AST_COLOR, "Expected a color.");
+ dmnsn_assert(astnode.type == DMNSN_AST_VECTOR, "Expected a vector.");
dmnsn_astnode rnode, gnode, bnode, fnode, tnode;
dmnsn_array_get(astnode.children, 0, &rnode);
@@ -349,7 +349,7 @@ dmnsn_realize_pigment(dmnsn_astnode astnode)
case DMNSN_AST_NONE:
break;
- case DMNSN_AST_COLOR:
+ case DMNSN_AST_VECTOR:
color = dmnsn_realize_color(color_node);
pigment = dmnsn_new_solid_pigment(color);
if (!pigment) {
diff --git a/tests/dimension/demo.sh b/tests/dimension/demo.sh
index 55274d0..f294a4f 100755
--- a/tests/dimension/demo.sh
+++ b/tests/dimension/demo.sh
@@ -31,10 +31,10 @@ demo_exp=$(echo -n \
(rotate (vector (integer 0) (integer 53) (integer 0)
(integer 0) (integer 0))))
(background
- (color (integer 0) (float 0.1) (float 0.2) (float 0.1) (integer 0)))
+ (vector (integer 0) (float 0.1) (float 0.2) (float 0.1) (integer 0)))
(light_source
(vector (integer -15) (integer 20) (integer 10) (integer 0) (integer 0))
- (color (integer 1) (integer 1) (integer 1) (integer 0) (integer 0)))
+ (vector (integer 1) (integer 1) (integer 1) (integer 0) (integer 0)))
(box
(vector (integer -1) (integer -1) (integer -1) (integer 0) (integer 0))
(vector (integer 1) (integer 1) (integer 1) (integer 0) (integer 0))
@@ -43,12 +43,12 @@ demo_exp=$(echo -n \
(integer 0) (integer 0)))
(texture
(pigment
- (color (integer 0) (integer 0) (integer 1)
- (float 0.25) (float 0.5)))
+ (vector (integer 0) (integer 0) (integer 1)
+ (float 0.25) (float 0.5)))
(finish
(reflection
- (color (float 0.5) (float 0.5) (float 0.5) (float 0.5) (float 0.5))
- (color (float 0.5) (float 0.5) (float 0.5) (float 0.5) (float 0.5))
+ (vector (float 0.5) (float 0.5) (float 0.5) (float 0.5) (float 0.5))
+ (vector (float 0.5) (float 0.5) (float 0.5) (float 0.5) (float 0.5))
reflection-items)))
(interior
(ior (float 1.1)))))
@@ -58,7 +58,7 @@ demo_exp=$(echo -n \
(object-modifiers
(texture
(pigment
- (color (integer 0) (integer 1) (integer 0) (integer 0) (integer 0)))
+ (vector (integer 0) (integer 1) (integer 0) (integer 0) (integer 0)))
(finish
(phong (float 0.2))
(phong_size (float 40)))))))' \
diff --git a/tests/dimension/directives.sh b/tests/dimension/directives.sh
index 5ecf574..74bde02 100755
--- a/tests/dimension/directives.sh
+++ b/tests/dimension/directives.sh
@@ -55,14 +55,14 @@ $(echo -n \
(vector (integer 0) (integer 0) (integer 0) (integer 0) (integer 0))
(integer 1)
(object-modifiers
- (pigment (color (integer 1) (integer 1) (integer 1)
- (integer 0) (integer 0)))))
+ (pigment (vector (integer 1) (integer 1) (integer 1)
+ (integer 0) (integer 0)))))
(sphere
(vector (integer 0) (integer 1) (integer 0) (integer 0) (integer 0))
(integer 1)
(object-modifiers
- (pigment (color (integer 1) (integer 1) (integer 1)
- (integer 0) (integer 0))))))' \
+ (pigment (vector (integer 1) (integer 1) (integer 1)
+ (integer 0) (integer 0))))))' \
| tr '\n' ' ' | sed -r 's/[[:space:]]+/ /g')"
if [ "$directives" != "$directives_exp" ]; then