summaryrefslogtreecommitdiffstats
path: root/dimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-12-17 03:24:36 -0500
committerTavian Barnes <tavianator@gmail.com>2009-12-17 03:24:36 -0500
commit2b320283ef67cc8ea72cf1ef4749206ec112681c (patch)
treeb189328c3124d0cda034eebf6d5107bc0ad3bdee /dimension
parentc66148484cad66972348ffe850fd23bc9dca60f9 (diff)
downloaddimension-2b320283ef67cc8ea72cf1ef4749206ec112681c.tar.xz
Preliminary dmnsn_realize_string(), just in case.
Diffstat (limited to 'dimension')
-rw-r--r--dimension/lexer.l8
-rw-r--r--dimension/realize.c13
-rw-r--r--dimension/realize.h1
3 files changed, 21 insertions, 1 deletions
diff --git a/dimension/lexer.l b/dimension/lexer.l
index b8bfbb0..5001d3a 100644
--- a/dimension/lexer.l
+++ b/dimension/lexer.l
@@ -17,7 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
-%option reentrant stack yylineno noyywrap prefix="dmnsn_yy" outfile="lex.yy.c"
+%option reentrant
+%option stack
+%option yylineno
+%option noyywrap
+%option never-interactive
+%option prefix="dmnsn_yy"
+%option outfile="lex.yy.c"
%{
#include "parse.h"
diff --git a/dimension/realize.c b/dimension/realize.c
index 7ca3ae2..bbbe4e7 100644
--- a/dimension/realize.c
+++ b/dimension/realize.c
@@ -17,10 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
+#define _GNU_SOURCE /* For fmemopen */
+
#include "realize.h"
#include "parse.h"
#include "utility.h"
#include <math.h>
+#include <stdio.h>
static double
dmnsn_realize_float(dmnsn_astnode astnode)
@@ -617,3 +620,13 @@ dmnsn_realize(FILE *file, const char *filename)
}
return dmnsn_realize_astree(astree);
}
+
+dmnsn_scene *
+dmnsn_realize_string(const char *str)
+{
+ FILE *file = fmemopen((void *)str, strlen(str), "r");
+ if (!file) {
+ return NULL;
+ }
+ return dmnsn_realize(file, "<string>");
+}
diff --git a/dimension/realize.h b/dimension/realize.h
index dbd71df..f9b4d61 100644
--- a/dimension/realize.h
+++ b/dimension/realize.h
@@ -23,5 +23,6 @@
#include "../libdimension/dimension.h"
dmnsn_scene *dmnsn_realize(FILE *file, const char *filename);
+dmnsn_scene *dmnsn_realize_string(const char *str);
#endif /* REALIZE_H */