From 1c67dd553c547d330c2a248d29a359f946915a2f Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Tue, 20 Sep 2005 00:26:00 +0000 Subject: Sergey Poznyakoff's patches improving MIXAL compliance. --- doc/mdk_ack.texi | 11 ++++++---- doc/mdk_tut.texi | 18 +++++++++------- mixlib/mix_scanner.l | 58 +++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 59 insertions(+), 28 deletions(-) diff --git a/doc/mdk_ack.texi b/doc/mdk_ack.texi index 52f9a23..807e276 100644 --- a/doc/mdk_ack.texi +++ b/doc/mdk_ack.texi @@ -1,10 +1,10 @@ @c -*-texinfo-*- @c This is part of the GNU MDK Reference Manual. -@c Copyright (C) 2000, 2001, 2002, 2003, 2004 +@c Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 @c Free Software Foundation, Inc. @c See the file mdk.texi for copying conditions. -@c $Id: mdk_ack.texi,v 1.14 2004/08/05 21:19:25 jao Exp $ +@c $Id: mdk_ack.texi,v 1.15 2005/09/20 00:26:00 jao Exp $ @node Acknowledgments, Installing MDK, Introduction, Top @comment node-name, next, previous, up @@ -32,6 +32,9 @@ bug fixes. @item Michael Scholz is the author of the German translation of @sc{mdk}'s user interface. +@item Sergey Poznyakoff +provided patches to mixlib/mix_scanner.l improving MIXAL compliance. + @item Francesc Xavier Noria kindly and thoroughly reviewed the @sc{mdk} documentation, providing insightful advice. @@ -44,10 +47,10 @@ enhancements to the source code. ported @sc{mdk} to different platforms, and created and/or maintain packages for it. -@item Jason Uhlenkott, Andrew Hood, Aleix Conchillo, Radu Butnaru, Ruslan Batdalov and WeiZheng +@item Jason Uhlenkott, Andrew Hood, Aleix Conchillo, Radu Butnaru, Ruslan Batdalov, WeiZheng and Sascha Wilde reported bugs and suggested fixes to them. -@item Eli Bendersky and Milan Bella reported bugs on the documentation. +@item Eli Bendersky, Milan Bella and Jens Seidel reported bugs on the documentation. @item Christoph von Nathusius, Stephen Ramsay and Johan Swanljung tested @sc{mdk} on different platforms, and helped fix the configuration diff --git a/doc/mdk_tut.texi b/doc/mdk_tut.texi index 70f8804..0fabe89 100644 --- a/doc/mdk_tut.texi +++ b/doc/mdk_tut.texi @@ -1,10 +1,10 @@ @c -*-texinfo-*- @c This is part of the GNU MDK Reference Manual. -@c Copyright (C) 2000, 2001, 2002, 2003, 2004 +@c Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 @c Free Software Foundation, Inc. @c See the file mdk.texi for copying conditions. -@c $Id: mdk_tut.texi,v 1.13 2004/06/12 01:12:59 jao Exp $ +@c $Id: mdk_tut.texi,v 1.14 2005/09/20 00:26:00 jao Exp $ @node MIX and MIXAL tutorial, Getting started, Installing MDK, Top @comment node-name, next, previous, up @@ -1050,11 +1050,15 @@ it will assign to the memory cell number 1150 the contents @w{- 00 06 61 11 49} (which corresponds to the decimal value -1823473). Finally, the @code{ALF} directive let's you specify the memory contents -as a set of five (quoted) characters, which are translated by the -assembler to their byte values, conforming in that way the binary word -that is to be stored in the corresponding memory cell. This directive -comes in handy when you need to store printable messages in a memory -address, as in the following example: +as a set of five (optionally quoted) characters, which are translated by +the assembler to their byte values, conforming in that way the binary +word that is to be stored in the corresponding memory cell. This +directive comes in handy when you need to store printable messages in a +memory address, as in the following example @footnote{In the original +MIXAL definition, the @code{ALF} argument is not quoted. You can write +the operand (as the @code{ADDRESS} field) without quotes, but, in this +case, you must follow the alignment rules of the original MIXAL +definition (namely, the @code{ADDRESS} must start at column 17).}: @example OUT MSG MSG is not yet defined here (future reference) 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})?)* } { - {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})?)* } { - {wexpr} ENTER_WEVAL (); + {wexpr} ENTER_WEVAL (0); . RETURN_ERROR (MIX_PERR_INV_OP, yytext); } @@ -334,6 +357,7 @@ wexpr {expr}({fpart})?(,{expr}({fpart})?)*
{ =/[+-]?{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 (); -- cgit v1.2.3