summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-01-14 20:18:51 -0500
committerTavian Barnes <tavianator@gmail.com>2010-01-14 20:18:51 -0500
commitf35aff5caddcff9ac62d485b78ef2bdfe1dd7c75 (patch)
treef0e3dcdd8f0b6e8930c5b29af9c49ccdfddc72e9
parenta6eb991ac03c62128470ca6700aab43ce46d709e (diff)
downloaddimension-f35aff5caddcff9ac62d485b78ef2bdfe1dd7c75.tar.xz
Fix rgb, rgbf, etc. color specifiers.
-rw-r--r--dimension/grammar.y37
1 files changed, 33 insertions, 4 deletions
diff --git a/dimension/grammar.y b/dimension/grammar.y
index 8b744b0..7cc0ce1 100644
--- a/dimension/grammar.y
+++ b/dimension/grammar.y
@@ -1176,11 +1176,40 @@ COLOR_BODY: COLOR_VECTOR %dprec 1
| COLOR_KEYWORD_GROUP %dprec 2
;
-COLOR_VECTOR: "rgb" VECTOR { $$ = $2; }
- | "rgbf" VECTOR { $$ = $2; }
- | "rgbt" VECTOR {
+COLOR_VECTOR: "rgb" VECTOR {
+ dmnsn_astnode f, t;
+ dmnsn_array_get($2.children, 3, &f);
+ dmnsn_array_get($2.children, 4, &t);
+ dmnsn_delete_astnode(f);
+ dmnsn_delete_astnode(t);
+
+ dmnsn_array_resize($2.children, 3);
+
+ $$ = dmnsn_eval_vector($2, symtable);
+ dmnsn_delete_astnode($2);
+ }
+ | "rgbf" VECTOR {
+ dmnsn_astnode t;
+ dmnsn_array_get($2.children, 4, &t);
+ dmnsn_delete_astnode(t);
+
+ dmnsn_array_resize($2.children, 4);
+
+ $$ = dmnsn_eval_vector($2, symtable);
+ dmnsn_delete_astnode($2);
+ }
+ | "rgbt" VECTOR {
+ /* Chop off the fifth component */
+ dmnsn_astnode t;
+ dmnsn_array_get($2.children, 4, &t);
+ dmnsn_delete_astnode(t);
+
+ dmnsn_array_resize($2.children, 4);
+
+ $$ = dmnsn_eval_vector($2, symtable);
+ dmnsn_delete_astnode($2);
+
/* Swap the transmit and filter components */
- $$ = $2;
dmnsn_astnode temp;
dmnsn_array_get($$.children, 4, &temp);
dmnsn_array_set($$.children, 4, dmnsn_array_at($$.children, 3));