summaryrefslogtreecommitdiffhomepage
path: root/mixlib/mix_scanner.l
diff options
context:
space:
mode:
Diffstat (limited to 'mixlib/mix_scanner.l')
-rw-r--r--mixlib/mix_scanner.l58
1 files changed, 41 insertions, 17 deletions
diff --git a/mixlib/mix_scanner.l b/mixlib/mix_scanner.l
index e85b6c8..fd47d92 100644
--- a/mixlib/mix_scanner.l
+++ b/mixlib/mix_scanner.l
@@ -86,12 +86,12 @@
yy_push_state (EVAL); \
} while (FALSE)
-#define ENTER_WEVAL() \
+#define ENTER_WEVAL(s) \
do { \
wexpr_val = MIX_WORD_ZERO; \
wexpr_val_tmp = MIX_WORD_ZERO; \
is_fp = FALSE; \
- yyless (0); \
+ yyless (s); \
yy_push_state (WEVAL); \
} while (FALSE)
@@ -133,7 +133,7 @@ static void unput_word_ (mix_word_t word);
%s EQU
%s END
-ws [ \t]+
+ws [ \t]
digit [0-9]
letter [A-Z]
number [+-]?{digit}+
@@ -164,6 +164,9 @@ wexpr {expr}({fpart})?(,{expr}({fpart})?)*
ins.address = 0;
ins.index = 0;
parser->err_line = 0;
+#ifdef FLEX_DEBUG
+ yy_flex_debug = getenv("FLEX_DEBUG");
+#endif
yyin = mix_file_to_FILE (parser->in_file);
%}
@@ -231,14 +234,14 @@ wexpr {expr}({fpart})?(,{expr}({fpart})?)*
}
<OP>{
- {ws} /* eat leading whitespace */
+ {ws}+ /* eat leading whitespace */
\n RETURN_ERROR (MIX_PERR_NOOP, NULL);
ORIG{ws}+ BEGIN (ORIG);
CON{ws}+ BEGIN (CON);
EQU{ws}+ BEGIN (EQU);
END{ws}+ BEGIN (END);
- ALF{ws}+\"{mixchar}{5,}\"{ws}+.*\n |
- ALF{ws}+\"{mixchar}{5,}\"{ws}*\n {
+ ALF{ws}+\"{mixchar}{0,5}\"{ws}+.*\n |
+ ALF{ws}+\"{mixchar}{0,5}\"{ws}*\n {
mix_byte_t bytes[5];
mix_word_t value;
guint k, j = 4;
@@ -247,22 +250,42 @@ wexpr {expr}({fpart})?(,{expr}({fpart})?)*
for ( k = j; k < 5+j && yytext[k] != '\"'; ++k )
bytes[k-j] = mix_ascii_to_char (yytext[k]);
if ( k-j < 5 )
- mix_parser_log_error (parser, MIX_PERR_SHORT_ALF, lineno, NULL, TRUE);
+ {
+ mix_parser_log_error (parser, MIX_PERR_SHORT_ALF, lineno, NULL, TRUE);
+ /* Fill with spaces */
+ for (; k < 5+j; k++)
+ bytes[k-j] = mix_ascii_to_char (' ');
+ }
else if ( yytext[k] != '\"' )
mix_parser_log_error (parser, MIX_PERR_LONG_ALF, lineno, NULL, TRUE);
value = mix_bytes_to_word (bytes, 5);
-
ADD_RAW (value, FALSE);
}
- ALF{ws}+.*\n {
- gchar* msg;
- guint k = 4;
- while ( isspace(yytext[k]) ) k++;
- msg = g_strdup_printf("\"%5s\"", g_strchomp (yytext + k));
- mix_parser_log_error (parser, MIX_PERR_UNQUOTED_ALF, lineno, msg, FALSE);
- g_free (msg);
+ ALF{ws}*\n {
+ mix_byte_t bytes[5];
+ memset (bytes, mix_ascii_to_char (' '), 5);
+ mix_word_t value = mix_bytes_to_word (bytes, 5);
+ ADD_RAW (value, FALSE);
+ }
+ ALF{ws}+({mixchar}{1,5}) {
+ mix_byte_t bytes[5];
+ mix_word_t value;
+ int i, n;
+ for (n = 3; n < yyleng; n++)
+ if (!isspace (yytext[n]))
+ break;
+
+ for (i = 0; i < 5 && n < yyleng; i++, n++)
+ bytes[i] = mix_ascii_to_char (yytext[n]);
+
+ for (; i < 5; i++)
+ bytes[i] = mix_ascii_to_char (' ');
+
+ value = mix_bytes_to_word (bytes, 5);
+ ADD_RAW (value, FALSE);
}
+ /* ALF " " */
[A-Z0-9]+{ws}*/\n |
[A-Z0-9]+{ws}+ {
mix_ins_id_t id = mix_get_id_from_string (g_strchomp (yytext));
@@ -324,7 +347,7 @@ wexpr {expr}({fpart})?(,{expr}({fpart})?)*
}
<ORIG,CON,EQU,END>{
- {wexpr} ENTER_WEVAL ();
+ {wexpr} ENTER_WEVAL (0);
. RETURN_ERROR (MIX_PERR_INV_OP, yytext);
}
@@ -334,6 +357,7 @@ wexpr {expr}({fpart})?(,{expr}({fpart})?)*
<ADDRESS>{
=/[+-]?{number}= lsf = TRUE;
=/{expr}= lsf = TRUE;
+ ={wexpr}= { lsf = TRUE; ENTER_WEVAL (1); }
[+-]?{number}={ws}*\n |
[+-]?{number}={ws}+.*\n {
if (!lsf) RETURN_ERROR (MIX_PERR_INV_ADDRESS, yytext);
@@ -494,7 +518,7 @@ wexpr {expr}({fpart})?(,{expr}({fpart})?)*
{number}/[,()\n\t ] wexpr_val = mix_word_new (atol (yytext));
{expr}/[,()\n\t ] ENTER_EVAL ();
,/{expr} /* eat comma if followed by expression */
- [\n\t ] { /* ok if not inside an f-part */
+ [=\n\t ] { /* ok if not inside an f-part */
if ( is_fp ) {
mix_parser_log_error (parser, MIX_PERR_MIS_PAREN, lineno, NULL, FALSE);
yy_pop_state ();