From de56533ebd3a6022e4ad0b15978f676d683f5eef Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Tue, 27 May 2003 22:50:50 +0000 Subject: new error message for missing ALF operand quotes (bug #3750 fixed) --- mixlib/mix_parser.c | 87 +++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 43 deletions(-) (limited to 'mixlib/mix_parser.c') diff --git a/mixlib/mix_parser.c b/mixlib/mix_parser.c index 2087f15..e2c7e3f 100644 --- a/mixlib/mix_parser.c +++ b/mixlib/mix_parser.c @@ -1,23 +1,23 @@ /* -*-c-*- -------------- mix_parser.c : - * Implementation of the functions declared in mix_parser.h and + * Implementation of the functions declared in mix_parser.h and * xmix_parser.h * ------------------------------------------------------------------ - * Copyright (C) 2000, 2001 Free Software Foundation, Inc. - * + * Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * */ #include @@ -57,7 +57,8 @@ static const gchar * const ERR_MESSAGE_[] = { N_("symbol is an instruction name"), N_("failed write access to code file"), N_("operand of ALF pseudo instruction has less than 5 chars"), - N_("operand of ALF pseudo instruction has more than 5 chars") + N_("operand of ALF pseudo instruction has more than 5 chars"), + N_("operand of ALF pseudo instruction must be quoted") }; static const guint NO_OF_MESSAGES_ = sizeof(ERR_MESSAGE_)/sizeof (gchar*); @@ -68,13 +69,13 @@ mix_parser_err_string (mix_parser_err_t error) return (error < NO_OF_MESSAGES_) ? _(ERR_MESSAGE_[error]) : NULL; } -guint +guint mix_parser_err_count (const mix_parser_t *parser) { return (parser) ? parser->err_count : 0; } -guint +guint mix_parser_warning_count (const mix_parser_t *parser) { return (parser) ? parser->warn_count : 0; @@ -104,7 +105,7 @@ compare_shorts_ (gconstpointer s1, gconstpointer s2) return mix_short_magnitude (a) - mix_short_magnitude (b); else if ( mix_short_magnitude (a) == 0 && mix_short_magnitude (b) == 0 ) return 0; - else if ( mix_short_is_positive (a) ) + else if ( mix_short_is_positive (a) ) return 1; return -1; } @@ -113,9 +114,9 @@ mix_parser_t * mix_parser_new (const gchar *in_file) { mix_parser_t *result; - mix_file_t *f = mix_file_new_with_def_ext (in_file, mix_io_READ, + mix_file_t *f = mix_file_new_with_def_ext (in_file, mix_io_READ, MIX_SRC_DEFEXT); - + if ( f == NULL ) return NULL; result = g_new (mix_parser_t, 1); result->symbol_table = mix_symbol_table_new (); @@ -193,16 +194,16 @@ update_future_refs_value_ (mix_parser_t *parser, const gchar *name, { GSList *list = NULL; gpointer key; - + g_assert (parser != NULL && name != NULL); - if ( g_hash_table_lookup_extended (parser->future_refs, name, &key, + if ( g_hash_table_lookup_extended (parser->future_refs, name, &key, (gpointer *)&list) ) { GSList *tmp = list; ins_node_ *node; while ( tmp != NULL ) { - node = + node = (ins_node_ *)g_tree_lookup (parser->ins_table,tmp->data); g_assert (node); if (mix_get_ins_address (node->ins) == 1) { @@ -230,7 +231,7 @@ update_ls_ (gpointer symbol, gpointer value, gpointer parser) mix_ins_t ins; mix_word_t w = (mix_word_t) GPOINTER_TO_UINT (value); mix_parser_t *par = (mix_parser_t *) parser; - + mix_word_to_ins_uncheck (w, ins); mix_parser_add_ins (par, &ins, 0); update_future_refs_ (par, (const gchar *)symbol); @@ -245,16 +246,16 @@ mix_parser_compile (mix_parser_t *parser) g_return_val_if_fail (parser->symbol_table != NULL, MIX_PERR_INTERNAL); g_return_val_if_fail (parser->future_refs != NULL, MIX_PERR_INTERNAL); g_return_val_if_fail (parser->ins_table != NULL, MIX_PERR_INTERNAL); - + parser->status = mix_flex_scan (parser); if ( parser->status == MIX_PERR_OK ) { - mix_symbol_table_foreach (parser->ls_table, update_ls_, + mix_symbol_table_foreach (parser->ls_table, update_ls_, (gpointer)parser); - g_hash_table_foreach_remove (parser->future_refs, + g_hash_table_foreach_remove (parser->future_refs, undef_warning_, (gpointer)parser); } - + return parser->status; } @@ -275,7 +276,7 @@ write_code_ (gpointer address, gpointer ins_node, gpointer context) desc.address = (mix_address_t)GPOINTER_TO_UINT (address); if ( mix_code_file_write_ins (cntx->file, &desc) ) return FALSE; - else + else { cntx->parser->status = MIX_PERR_NOWRITE; return TRUE; @@ -283,14 +284,14 @@ write_code_ (gpointer address, gpointer ins_node, gpointer context) } mix_parser_err_t -mix_parser_write_code (mix_parser_t *parser, const gchar *code_file, +mix_parser_write_code (mix_parser_t *parser, const gchar *code_file, gboolean debug) { struct write_code_context_ context; const gchar *cfname = (code_file) ? code_file : mix_file_base_name (parser->in_file); gchar *source_path; - + g_return_val_if_fail (parser != NULL, MIX_PERR_INTERNAL); if (parser->status != MIX_PERR_OK ) return parser->status; context.parser = parser; @@ -303,13 +304,13 @@ mix_parser_write_code (mix_parser_t *parser, const gchar *code_file, } else source_path = g_strdup (mix_file_base_name (parser->in_file)); - + context.file = mix_code_file_new_write (cfname, parser->start, source_path, debug, parser->symbol_table); g_free (source_path); if (context.file == NULL) return MIX_PERR_NOOUT; - g_tree_traverse (parser->ins_table, write_code_, + g_tree_traverse (parser->ins_table, write_code_, G_IN_ORDER, (gpointer)&context); mix_code_file_delete (context.file); return parser->status; @@ -344,21 +345,21 @@ mix_parser_write_listing (mix_parser_t *parser, const gchar *list_file) FILE *file; mix_file_t *mfile; const gchar *name; - + g_return_val_if_fail (parser != NULL, MIX_PERR_INTERNAL); if (parser->status != MIX_PERR_OK ) return parser->status; name = (list_file) ? list_file : mix_file_base_name (parser->in_file); mfile = mix_file_new_with_def_ext (name, mix_io_WRITE, MIX_LIST_DEFEXT); if ( mfile == NULL ) return MIX_PERR_NOOUT; file = mix_file_to_FILE (mfile); - fprintf (file, _("*** %s%s: compilation summary ***\n\n"), - mix_file_base_name (parser->in_file), + fprintf (file, _("*** %s%s: compilation summary ***\n\n"), + mix_file_base_name (parser->in_file), mix_file_extension (parser->in_file)); fputs ( _("*** Address / Compiled word / Symbolic rep / Source file line\n"), file); - g_tree_traverse (parser->ins_table, write_listing_, + g_tree_traverse (parser->ins_table, write_listing_, G_IN_ORDER, (gpointer)file); - fprintf (file, _("\n*** Start address: %d\n"), + fprintf (file, _("\n*** Start address: %d\n"), mix_short_magnitude (parser->start)); fprintf (file, _("\n*** Symbol table\n")); mix_symbol_table_print (parser->symbol_table, MIX_SYM_ROWS, file, TRUE); @@ -372,7 +373,7 @@ static gint load_vm_ (gpointer address, gpointer ins, gpointer vm) { mix_vm_set_addr_contents ((mix_vm_t*)vm, - (mix_address_t)GPOINTER_TO_UINT (address), + (mix_address_t)GPOINTER_TO_UINT (address), ((ins_node_ *)ins)->ins); return FALSE; } @@ -410,12 +411,12 @@ mix_parser_err_t mix_parser_define_symbol_value (mix_parser_t *parser, const gchar *name, mix_word_t value) { - g_assert (parser != NULL && name != NULL); - + g_assert (parser != NULL && name != NULL); + switch (mix_symbol_table_add (parser->symbol_table, name, value)) { - case MIX_SYM_OK: - if ( parser->status == MIX_PERR_NOCOMP ) + case MIX_SYM_OK: + if ( parser->status == MIX_PERR_NOCOMP ) update_future_refs_value_ (parser, name, value); return MIX_PERR_OK; case MIX_SYM_LONG: return MIX_PERR_LONG_SYMBOL; @@ -449,10 +450,10 @@ mix_parser_manage_local_symbol (mix_parser_t *parser, const gchar *name, { gchar ref[3]; ref[2] = 0; - + g_assert (parser != NULL && name != NULL); g_assert (strlen(name) == 2); - + switch (name[1]) { case 'f': case 'F': @@ -461,10 +462,10 @@ mix_parser_manage_local_symbol (mix_parser_t *parser, const gchar *name, case 'h': case 'H': ref[0] = name[0]; ref[1] = 'F'; - if ( parser->status == MIX_PERR_NOCOMP ) + if ( parser->status == MIX_PERR_NOCOMP ) update_future_refs_value_ (parser, ref, value); ref[1] = 'B'; - mix_symbol_table_insert (parser->symbol_table, ref, + mix_symbol_table_insert (parser->symbol_table, ref, mix_short_to_word_fast (value)); break; default: @@ -484,7 +485,7 @@ mix_parser_define_ls (mix_parser_t *parser, mix_word_t value) /* Compilation */ void -mix_parser_add_ins (mix_parser_t *parser, const mix_ins_t *new_ins, +mix_parser_add_ins (mix_parser_t *parser, const mix_ins_t *new_ins, guint lineno) { g_assert (parser != NULL && new_ins != NULL); @@ -506,7 +507,7 @@ mix_parser_add_raw (mix_parser_t *parser, mix_word_t word, guint lineno) } /* Error handling */ -void +void mix_parser_log_error (mix_parser_t *parser, mix_parser_err_t error, gint lineno, const gchar *comment, gboolean warn) { @@ -519,9 +520,9 @@ mix_parser_log_error (mix_parser_t *parser, mix_parser_err_t error, parser->err_line = lineno; parser->status = error; } - + fprintf (stderr, "%s%s:%d: %s: %s", - mix_file_base_name (parser->in_file), + mix_file_base_name (parser->in_file), mix_file_extension (parser->in_file), lineno, warn ? _("warning"):_("error"), _(ERR_MESSAGE_[error])); -- cgit v1.2.3