summaryrefslogtreecommitdiffhomepage
path: root/mixlib
diff options
context:
space:
mode:
Diffstat (limited to 'mixlib')
-rw-r--r--mixlib/mix_parser.c1
-rw-r--r--mixlib/mix_scanner.l14
-rw-r--r--mixlib/testsuite/Makefile.am2
-rw-r--r--mixlib/testsuite/mix_parser_t.c31
4 files changed, 19 insertions, 29 deletions
diff --git a/mixlib/mix_parser.c b/mixlib/mix_parser.c
index 0dfcf81..a00886f 100644
--- a/mixlib/mix_parser.c
+++ b/mixlib/mix_parser.c
@@ -118,6 +118,7 @@ mix_parser_new (const gchar *in_file)
MIX_SRC_DEFEXT);
if ( f == NULL ) return NULL;
+
result = g_new (mix_parser_t, 1);
result->symbol_table = mix_symbol_table_new ();
result->ls_table = mix_symbol_table_new ();
diff --git a/mixlib/mix_scanner.l b/mixlib/mix_scanner.l
index 1ad8eaa..db76057 100644
--- a/mixlib/mix_scanner.l
+++ b/mixlib/mix_scanner.l
@@ -168,7 +168,7 @@ wexpr {expr}({fpart})?(,{expr}({fpart})?)*
yy_flex_debug = getenv("FLEX_DEBUG");
#endif
yyin = mix_file_to_FILE (parser->in_file);
-
+ yyrestart (yyin);
%}
@@ -180,13 +180,19 @@ wexpr {expr}({fpart})?(,{expr}({fpart})?)*
<INITIAL>{
^\*.* /* eat comments */
. {
- if ( end ) return parser->status;
+ if (end)
+ {
+ return parser->status;
+ }
yyless (0);
BEGIN (LOC);
}
\n {
++lineno;
- if ( end ) return parser->status;
+ if (end)
+ {
+ return parser->status;
+ }
}
}
@@ -342,6 +348,8 @@ wexpr {expr}({fpart})?(,{expr}({fpart})?)*
parser->end = parser->loc_count;
end = TRUE;
if ( parser->status == MIX_PERR_NOCOMP ) parser->status = MIX_PERR_OK;
+ RESET ();
+ BEGIN (INITIAL);
return parser->status;
}
}
diff --git a/mixlib/testsuite/Makefile.am b/mixlib/testsuite/Makefile.am
index e297988..349a320 100644
--- a/mixlib/testsuite/Makefile.am
+++ b/mixlib/testsuite/Makefile.am
@@ -17,7 +17,7 @@ LDADD = $(top_builddir)/mixlib/libmix.a
check_PROGRAMS = mixtypest mixinstest mixvminstest mixparsertest mixdevtest mixevaltest
TESTS = $(check_PROGRAMS)
-MIXAL_FILES= "\"primes\",\"isamixinstruction\",\"tests/bt\",\"tests/cbp\",\"tests/ldan\",\"tests/stress0\",\"hello\",\"echo\","
+MIXAL_FILES= "\"tests/bt\",\"tests/cbp\",\"tests/stress0\",\"tests/stress1\",\"tests/stress2\",\"tests/stress4\",\"tests/stress5\",\"tests/stress6\",\"tests/ldan\",\"tests/lockonw\",\"tests/negwrite\",\"hello\",\"echo\",\"primes\",\"isains\""
AM_CFLAGS = -DMIX_TEST_MIXAL_FILES=$(MIXAL_FILES) -DMIX_TEST_SAMPLES_DIR="\"$(top_srcdir)/samples\""
diff --git a/mixlib/testsuite/mix_parser_t.c b/mixlib/testsuite/mix_parser_t.c
index 4008309..80f2cd1 100644
--- a/mixlib/testsuite/mix_parser_t.c
+++ b/mixlib/testsuite/mix_parser_t.c
@@ -20,9 +20,9 @@
*/
+#include <mix_parser.h>
#include <stdlib.h>
-#include <mix_parser.h>
/* Define VERBOSE_TEST if you want to get prints of the test */
/* #define VERBOSE_TEST */
@@ -36,13 +36,12 @@ static const size_t FILE_NO_ = sizeof(FILES_)/sizeof(FILES_[0]);
static void
test_code_ (const gchar *name)
{
-
mix_code_file_t *code;
mix_parser_err_t err;
+
gchar *real_name = g_strdup_printf ("%s/%s", MIX_TEST_SAMPLES_DIR, name);
- g_print (real_name);
- g_print ("\n");
+ gchar *code_name = g_path_get_basename (name);
mix_parser_t *parser = mix_parser_new (real_name);
@@ -58,32 +57,14 @@ test_code_ (const gchar *name)
g_assert (err == MIX_PERR_OK);
- err = mix_parser_write_code (parser, real_name, FALSE);
- code = mix_code_file_new_read (real_name);
+ err = mix_parser_write_code (parser, code_name, FALSE);
+ code = mix_code_file_new_read (code_name);
g_assert (code);
-#ifdef VERBOSE_TEST
- g_message ("%s: Version: %d.%d", name, mix_code_file_major_version (code),
- mix_code_file_minor_version (code));
-
- mix_short_print (mix_code_file_get_start_addr (code), "Start address: ");
- g_print ("\n");
-
- mix_ins_desc_t ins;
- while (mix_code_file_get_ins (code, &ins))
- {
- mix_ins_t i;
- mix_word_to_ins_uncheck (ins.ins, i);
- mix_short_print (ins.address, "addr: ");
- g_print (" : ");
- mix_ins_print (&i);
- g_print ("\n");
- }
-#endif
-
mix_parser_delete (parser);
mix_code_file_delete (code);
g_free (real_name);
+ g_free (code_name);
}
int