Exemplo n.º 1
0
static void	common_main()
{
#ifndef NO_MESSAGE_CATALOG
  if (uil_catd == NULL)
    uil_catd = catopen("Uil", NL_CAT_LOCALE);
#endif

  /* Initialize the X toolkit. */
  XtToolkitInitialize(); 
  
    /* use the user supplied data base instead */
    if (Uil_cmd_z_command.v_database)
	db_incorporate();

    /* initialize the diagnostic system */
    diag_initialize_diagnostics();

    /* initialize the symbol table */
    sym_initialize_storage();

    /* initialize the source */
    src_initialize_source();

    /* open listing file if requested */
    if (Uil_cmd_z_command.v_listing_file)
	lst_open_listing();

    /* initialize the lexical analyzer */
    lex_initialize_analyzer();

    /* initialize the keyword table */
    key_initialize();

    /* initialize the sar data structures */
    sar_initialize();

    /* call YACC to parse the source file */
    /* return 0 for success, 1 for failure */
    /* Make sure the root entry sections pointer is filled in */
    if (yyparse() != 0)
    	diag_issue_diagnostic
	    (d_inv_module, diag_k_no_source, diag_k_no_column);
    sym_az_root_entry->sections = sym_az_current_section_entry;

    /* call forward reference resolver */
    sem_resolve_forward_refs();

    /* call semantic validation */
    sem_validation ();

    /* call the output phase if requested */
    if (Uil_cmd_z_command.v_resource_file)
	sem_output_uid_file();

    /* call symbol table dumper - if requested */
#if debug_version
    if (uil_v_dump_symbols == TRUE)
	sym_dump_symbols();
#endif


    /* write compilation summary */
    diag_issue_summary();


    /* write listing file if requested */
    if (Uil_cmd_z_command.v_listing_file)
	lst_output_listing();

    /* Storage is not cleaned up, since we will exit */
    uil_exit( uil_l_compile_status );

}
Exemplo n.º 2
0
void	diag_issue_diagnostic
( int d_message_number, src_source_record_type *az_src_rec,
  int l_start_column, ...)

{
    va_list	ap;			/* ptr to variable length parameter */
    int		severity;		/* severity of message */
    int		message_number;		/* message number */
    char	msg_buffer[132];	/* buffer to construct message */
    char	ptr_buffer[buf_size];	/* buffer to construct pointer */
    char	loc_buffer[132];	/* buffer to construct location */
    char	src_buffer[buf_size];	/* buffer to hold source line */

    /*
    **	check if we are in a loop issuing errors
    */

    if (issuing_diagnostic)
    {
        _debug_output( "nested diagnostics issued" );
        Uil_message_count[ uil_k_severe_status ]++;
        uil_exit( uil_k_severe_status );
    }

    issuing_diagnostic = TRUE;

    /*
    **	determine the severity of the error.  For d_submit_spr we issue
    **	the fix previous error diagnostic, if we encountered prior errors;
    **  otherwise we let it thru.
    */

    message_number = d_message_number;

    if (message_number == d_submit_spr)
        if (Uil_message_count[ uil_k_error_status ] > 0)
            message_number = d_prev_error;

    severity = diag_rz_msg_table[ message_number ].l_severity;

    /*
    **	check if messages of this severity are to be reported.
    */

    switch (severity)
    {
    case uil_k_info_status:
        if (Uil_cmd_z_command.v_report_info_msg)
            break;

        issuing_diagnostic = FALSE;
        return;

    case uil_k_warning_status:
        if (Uil_cmd_z_command.v_report_warn_msg)
            break;

        issuing_diagnostic = FALSE;
        return;

    default:
        ;
    }

    Uil_message_count[ severity ]++;
    if (severity > uil_l_compile_status)
        uil_l_compile_status = severity;

    /*
    **	Diagnostic format varies considerably
    **	   1) no source
    **		message
    **	   2) source but no column
    **		source line
    **		message
    **		location in source message
    **	   3) source and column
    **		source line
    **		column pointer
    **		message
    **		location in source message
    **	   4) source and column but no access key
    **		message
    **		location in source message
    */

    /*
    **	substitute any parameters into the error message placing the
    **	resultant string in msg_buffer
    */

    va_start(ap, l_start_column);

#ifndef NO_MESSAGE_CATALOG
    vsnprintf( msg_buffer, sizeof(msg_buffer),
               catgets(uil_catd, UIL_SET1, msg_cat_table[ message_number ],
                       diag_rz_msg_table[ message_number ].ac_text),
               ap );
#else
    vsnprintf( msg_buffer, sizeof(msg_buffer),
               diag_rz_msg_table[ message_number ].ac_text,
               ap );
#endif
    va_end(ap);

    src_buffer[ 0 ] = 0;
    loc_buffer[ 0 ] = 0;
    ptr_buffer[ 0 ] = 0;

    if (az_src_rec != diag_k_no_source)
    {
        if ( !_src_null_access_key(az_src_rec->z_access_key) )
        {
            /*
            **	create the location line line
            */

#ifndef NO_MESSAGE_CATALOG
            sprintf( loc_buffer,
                     catgets(uil_catd, UIL_SET_MISC,
                             UIL_MISC_0, "\t\t line: %d  file: %s"),
                     az_src_rec->w_line_number,
                     src_get_file_name( az_src_rec ) );
#else
            sprintf( loc_buffer,
                     "\t\t line: %d  file: %s",
                     az_src_rec->w_line_number,
                     src_get_file_name( az_src_rec ) );
#endif

            /*
            **	retrieve the source line
            */

            src_buffer[ 0 ] = '\t';
            src_retrieve_source( az_src_rec, &src_buffer[ 1 ] );

            /*
            **	filter the standard unprintable characters.
            */

            lex_filter_unprintable_chars
            ( (unsigned char *)src_buffer, strlen( src_buffer ), 0 );

            /*
            **	create the column pointer if a source position was given
            */

            if (l_start_column != diag_k_no_column)
            {
                int	i;

                for (i=0;  i < l_start_column+1;  i++)
                {
                    if (src_buffer[ i ] == '\t')
                        ptr_buffer[ i ] = '\t';
                    else
                        ptr_buffer[ i ] = ' ';
                }

                ptr_buffer[ i++ ] = '*';
                ptr_buffer[ i ]   = 0;
            }
        }
        else	/* no access key */
        {
            /*
            **	create the location line line
            */

            if (l_start_column != diag_k_no_column)
#ifndef NO_MESSAGE_CATALOG
                sprintf(loc_buffer,
                        catgets(uil_catd, UIL_SET_MISC,
                                UIL_MISC_1,
                                "\t\t line: %d  position: %d  file: %s"),
                        az_src_rec->w_line_number,
                        l_start_column + 1,
                        src_get_file_name( az_src_rec ) );
#else
                sprintf(loc_buffer,
                        "\t\t line: %d  position: %d  file: %s",
                        az_src_rec->w_line_number,
                        l_start_column + 1,
                        src_get_file_name( az_src_rec ) );
#endif
            else
#ifndef NO_MESSAGE_CATALOG
                sprintf( loc_buffer, catgets(uil_catd, UIL_SET_MISC,
                                             UIL_MISC_0,
                                             "\t\t line: %d  file: %s"),
                         az_src_rec->w_line_number,
                         src_get_file_name( az_src_rec ) );
#else
                sprintf( loc_buffer,
                         "\t\t line: %d  file: %s",
                         az_src_rec->w_line_number,
                         src_get_file_name( az_src_rec ) );
#endif
        }
    }