summaryrefslogtreecommitdiff
path: root/src/map/magic-interpreter-parser.ypp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2012-08-30 17:37:27 -0700
committerBen Longbons <b.r.longbons@gmail.com>2012-09-03 16:23:10 -0700
commit31544d2b6973931be7fdec898ea3672bea831de2 (patch)
treedcf946429b406f39297404be662b0a840094e477 /src/map/magic-interpreter-parser.ypp
parent41974ae5265fbc23a06f276f9e008d5dad020e0b (diff)
downloadtmwa-31544d2b6973931be7fdec898ea3672bea831de2.tar.gz
tmwa-31544d2b6973931be7fdec898ea3672bea831de2.tar.bz2
tmwa-31544d2b6973931be7fdec898ea3672bea831de2.tar.xz
tmwa-31544d2b6973931be7fdec898ea3672bea831de2.zip
Fix compiler errors of C++ conversion
Diffstat (limited to 'src/map/magic-interpreter-parser.ypp')
-rw-r--r--src/map/magic-interpreter-parser.ypp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/map/magic-interpreter-parser.ypp b/src/map/magic-interpreter-parser.ypp
index 2648be9..5fe2646 100644
--- a/src/map/magic-interpreter-parser.ypp
+++ b/src/map/magic-interpreter-parser.ypp
@@ -1,9 +1,13 @@
-%{
-#include "magic-interpreter.hpp"
+%code requires {
#include "magic-expr.hpp"
+}
+%code{
+#include "magic-interpreter-parser.hpp"
+
+#include "magic-interpreter.hpp"
#include <stdarg.h>
-magic_conf_t magic_conf;
+#define YYLEX_PARAM 0, 0
static int
intern_id(const char *id_name);
@@ -49,8 +53,7 @@ add_teleport_anchor(teleport_anchor_t *anchor, int line_nr);
static effect_t *
op_effect(char *name, int args_nr, expr_t **args, int line, int column);
-int
-magic_frontend_lex(void);
+int magic_frontend_lex(YYSTYPE *, YYLTYPE *);
static void
install_proc(proc_t *proc);
@@ -64,8 +67,7 @@ bind_constant(char *name, val_t *val, int line_nr);
static val_t *
find_constant(char *name);
-
-%}
+}
%name-prefix="magic_frontend_"
@@ -678,7 +680,7 @@ effect : '(' effect_list ')'
}
| SCRIPT_DATA
{ $$ = new_effect(EFFECT_SCRIPT);
- $$->e.e_script = parse_script((unsigned char *) $1, @1.first_line);
+ $$->e.e_script = parse_script($1, @1.first_line);
free($1);
if ($$->e.e_script == NULL)
fail(@1.first_line, @1.first_column, "Failed to compile script\n");
@@ -771,8 +773,8 @@ add_teleport_anchor(teleport_anchor_t *anchor, int line_nr)
}
-static void
-fail(int line, int column, const char *fmt, ...)
+static __attribute__((format(printf, 3, 4)))
+void fail(int line, int column, const char *fmt, ...)
{
va_list ap;
fprintf(stderr, "[magic-init] L%d:%d: ", line, column);
@@ -1030,13 +1032,14 @@ find_constant(char *name)
extern FILE *magic_frontend_in;
-int
-magic_init(char *conffile) // must be called after itemdb initialisation
+// must be called after itemdb initialisation
+int magic_init(const char *conffile)
{
int error_flag = 0;
magic_conf.vars_nr = 0;
- magic_conf.var_name = (char **)malloc(1);
+ // can these be left NULL ? I'm afraid to change anything.
+ magic_conf.var_name = (const char **)malloc(1);
magic_conf.vars = (val_t *)malloc(1);
magic_conf.obscure_chance = 95;