summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-04-16 14:06:31 -0400
committerTavian Barnes <tavianator@gmail.com>2010-04-16 14:06:31 -0400
commit23229722b2abd0021c697e3f6e43f74b51e4ee41 (patch)
tree85111795e08a24a46788afc90b4b2d98620705a4
parent7577a2b69f9a77962912753b6768b38db4e3c454 (diff)
downloaddimension-23229722b2abd0021c697e3f6e43f74b51e4ee41.tar.xz
Implement image_{width,height}.
-rw-r--r--dimension/common.rules8
-rw-r--r--dimension/common.terminals4
-rw-r--r--dimension/lexer.l2
-rw-r--r--dimension/main.c2
-rw-r--r--tests/dimension/csg.pov2
-rwxr-xr-xtests/dimension/csg.sh4
-rw-r--r--tests/dimension/demo.pov2
-rwxr-xr-xtests/dimension/demo.sh2
8 files changed, 19 insertions, 7 deletions
diff --git a/dimension/common.rules b/dimension/common.rules
index 732a277..075b276 100644
--- a/dimension/common.rules
+++ b/dimension/common.rules
@@ -669,6 +669,14 @@ ARITH_EXPR: FLOAT_LITERAL
| "vrotate" "(" ARITH_EXPR "," ARITH_EXPR ")" {
$$ = dmnsn_new_astnode2(DMNSN_AST_VROTATE, @$, $3, $5);
}
+ | "image_height" {
+ $$ = dmnsn_new_astnode(DMNSN_AST_IDENTIFIER, @$);
+ $$.ptr = dmnsn_strdup("image_height");
+ }
+ | "image_width" {
+ $$ = dmnsn_new_astnode(DMNSN_AST_IDENTIFIER, @$);
+ $$.ptr = dmnsn_strdup("image_width");
+ }
| "pi" { $$ = dmnsn_new_astnode(DMNSN_AST_PI, @$); }
| "true" { $$ = dmnsn_new_astnode(DMNSN_AST_TRUE, @$); }
| "on" { $$ = dmnsn_new_astnode(DMNSN_AST_TRUE, @$); }
diff --git a/dimension/common.terminals b/dimension/common.terminals
index 05ab8b8..fd62320 100644
--- a/dimension/common.terminals
+++ b/dimension/common.terminals
@@ -225,10 +225,10 @@
%token DMNSN_T_HYPERCOMPLEX
%token DMNSN_T_HOLLOW
%token DMNSN_T_IFF
-%token DMNSN_T_IMAGE_HEIGHT
+%token DMNSN_T_IMAGE_HEIGHT "image_height"
%token DMNSN_T_IMAGE_MAP "image_map"
%token DMNSN_T_IMAGE_PATTERN
-%token DMNSN_T_IMAGE_WIDTH
+%token DMNSN_T_IMAGE_WIDTH "image_width"
%token DMNSN_T_INITIAL_CLOCK
%token DMNSN_T_INITIAL_FRAME
%token DMNSN_T_INSIDE
diff --git a/dimension/lexer.l b/dimension/lexer.l
index 18b4202..2684868 100644
--- a/dimension/lexer.l
+++ b/dimension/lexer.l
@@ -199,7 +199,9 @@ unsigned long wchar;
"gray" RETURN_TOKEN(DMNSN_T_GRAY);
"grey" RETURN_TOKEN(DMNSN_T_GRAY);
"green" RETURN_TOKEN(DMNSN_T_GREEN);
+"image_height" RETURN_TOKEN(DMNSN_T_IMAGE_HEIGHT);
"image_map" RETURN_TOKEN(DMNSN_T_IMAGE_MAP);
+"image_width" RETURN_TOKEN(DMNSN_T_IMAGE_WIDTH);
"int" RETURN_TOKEN(DMNSN_T_INT);
"interior" RETURN_TOKEN(DMNSN_T_INTERIOR);
"intersection" RETURN_TOKEN(DMNSN_T_INTERSECTION);
diff --git a/dimension/main.c b/dimension/main.c
index 2bd4e10..1ea8a72 100644
--- a/dimension/main.c
+++ b/dimension/main.c
@@ -196,6 +196,8 @@ main(int argc, char **argv) {
dmnsn_symbol_table *symtable = dmnsn_new_symbol_table();
dmnsn_declare_symbol(symtable, "$file", dmnsn_new_ast_string(input));
dmnsn_declare_symbol(symtable, "version", dmnsn_new_ast_float(3.6));
+ dmnsn_declare_symbol(symtable, "image_width", dmnsn_new_ast_integer(width));
+ dmnsn_declare_symbol(symtable, "image_height", dmnsn_new_ast_integer(height));
/* Debugging option - output the abstract syntax tree as an S-expression */
if (parse) {
diff --git a/tests/dimension/csg.pov b/tests/dimension/csg.pov
index 046510f..aa3373e 100644
--- a/tests/dimension/csg.pov
+++ b/tests/dimension/csg.pov
@@ -22,7 +22,7 @@
camera {
perspective
location -4*z
- right 1.6*x
+ right x*image_width/image_height
look_at 0
}
diff --git a/tests/dimension/csg.sh b/tests/dimension/csg.sh
index 325aaba..7f4732c 100755
--- a/tests/dimension/csg.sh
+++ b/tests/dimension/csg.sh
@@ -19,13 +19,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-csg=$(${top_builddir}/dimension/dimension --parse ${srcdir}/csg.pov)
+csg=$(${top_builddir}/dimension/dimension -w768 -h480 --parse ${srcdir}/csg.pov)
csg_exp="$(echo -n \
'((camera
perspective
(location (vector (integer 0) (integer 0) (integer -4)
(integer 0) (integer 0)))
- (right (vector (float 1.6) (float 0) (float 0) (float 0) (float 0)))
+ (right (vector (float 1.6) (integer 0) (integer 0) (integer 0) (integer 0)))
(look_at (vector (integer 0) (integer 0) (integer 0)
(integer 0) (integer 0))))
(background
diff --git a/tests/dimension/demo.pov b/tests/dimension/demo.pov
index 4f558c5..4175b77 100644
--- a/tests/dimension/demo.pov
+++ b/tests/dimension/demo.pov
@@ -22,7 +22,7 @@
camera {
perspective
location <0, 0.25, -4>
- right <1.6, 0, 0>
+ right x*image_width/image_height
look_at <0, 0, 0>
rotate 53*y
diff --git a/tests/dimension/demo.sh b/tests/dimension/demo.sh
index f047f55..4ea0a1e 100755
--- a/tests/dimension/demo.sh
+++ b/tests/dimension/demo.sh
@@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-demo=$(${top_builddir}/dimension/dimension --parse ${srcdir}/demo.pov)
+demo=$(${top_builddir}/dimension/dimension -w768 -h480 --parse ${srcdir}/demo.pov)
demo_exp=$(echo -n \
'((camera
perspective