Beispiel #1
0
int FscRead::ReadFont()
	{
	iInputFile.seekg(0,ios::end);
	iFileBufLen=iInputFile.tellg();
	iInputFile.seekg(0);
	iFileBufPos=0;
	iFileBuf=new char[iFileBufLen];
	iInputFile.read(iFileBuf,iFileBufLen);
	int ret=Pass1();
	if(ret) return(ret);
	return(Pass2());
	}
Beispiel #2
0
static void PreprocessLine (void)
/* Translate one line. */
{
    /* Trim whitespace and remove comments. The function returns the number of
     * identifiers found. If there were any, we will have to check for macros.
     */
    SB_Clear (MLine);
    if (Pass1 (Line, MLine) > 0) {
        MLine = InitLine (MLine);
        SB_Reset (Line);
        SB_Clear (MLine);
        MacroReplacement (Line, MLine);
    }

    /* Read from the new line */
    SB_Reset (MLine);
    MLine = InitLine (MLine);
}
Beispiel #3
0
int main( int argc, char * argv[] )
#endif
/***************************************/
{
    bool    noerror;

#ifndef DLL_COMPILE
    RcMemInit();
    Layer0InitStatics();
#if !defined(__UNIX__) && !defined(__OSI__) /* _grow_handles doesn't work yet */
    _grow_handles(100);
#endif
#endif
    if( !InitRcMsgs( argv[0] ) ) return( 1 );

    noerror = ScanParams( argc, argv );
    if (!CmdLineParms.Quiet) {
        RcIoPrintBanner();
    }
    if (CmdLineParms.PrintHelp) {
        RcIoPrintHelp( argv[0] );
    }

    if (noerror && !CmdLineParms.Pass2Only) {
        noerror = Pass1();
    }
    if (noerror && !CmdLineParms.Pass1Only && !CmdLineParms.PreprocessOnly ) {
        noerror = Pass2();
    }

    FiniTable();
#ifndef DLL_COMPILE
    ScanParamShutdown();
    FiniRcMsgs();
    RcMemShutdown();
#endif

    if (noerror) {
        return( 0 );
    } else {
        return( 1 );
    }
} /* main */
Beispiel #4
0
static void DoPragma (void)
/* Handle a #pragma line by converting the #pragma preprocessor directive into
 * the _Pragma() compiler operator.
 */
{
    /* Skip blanks following the #pragma directive */
    SkipWhitespace (0);

    /* Copy the remainder of the line into MLine removing comments and ws */
    SB_Clear (MLine);
    Pass1 (Line, MLine);

    /* Convert the directive into the operator */
    SB_CopyStr (Line, "_Pragma (");
    SB_Reset (MLine);
    Stringize (MLine, Line);
    SB_AppendChar (Line, ')');

    /* Initialize reading from line */
    SB_Reset (Line);
    InitLine (Line);
}
Beispiel #5
0
int main()
{

	int Pass1(MNT mnt[50], MDT mdt[50], int mntc, int mdtc, Pass1table table1[50]);
	int Pass2(MNT mnt[50], MDT mdt[50], int mntc, Pass1table table1[50], int tp, Pass2table table2[50]);
	int putinbuffer(FILE *fin, char buffer[20]);
	int displayPass1tables(MNT mnt[50], int mntc, MDT mdt[50], int mdtc, FPPL fppl[5], int fptr);
	int print_IC(Pass1table table1[50], int tp);
	
	int o=0;

	MNT mnt[50];
	MDT mdt[50];
	Pass1table table1[50];
	
	int mdtc=0, tp=0, tp2=0, mntc=0;

	printf("\nPrinting the IC File");
	tp=Pass1(mnt,mdt,mntc,mdtc,table1);
	

	return 0;
}
Beispiel #6
0
int
main(int argc, char *argv[]) {
	progname = argv[0];		/* save program name */
	argv++, argc--;			/* and skip it */

	/* Set the default output and debug streams */
	OutputFile = stdout;
	DebugFile = stdout;

	/* Get command line options */
	{	int nop = do_options(progname, optlist, argc, argv);
		argc -= nop, argv += nop;	/* skip them */
	}

	/* Treat the value options */
	if (minrunstring) {
		MinRunSize = strtoul(minrunstring, NULL, 10);
		if (MinRunSize == 0) fatal("bad or zero run size; form is: -r N");
	}
	if (pagewidthstring) {
		PageWidth = atoi(pagewidthstring);
		if (PageWidth == 0) fatal("bad or zero page width; form is: -w N");
	}
	if (outputname) {
		OutputFile = fopen(outputname, "w");
		if (OutputFile == 0) {
			char msg[500];

			sprintf(msg, "cannot open output file %s", outputname);
			fatal(msg);
			/*NOTREACHED*/
		}
	}

	if (option_set('-')) {
		/* it is the lexical scan only */
		while (argv[0]) {
			print_stream(argv[0]);
			argv++;
		}
		return 0;
	}

	/* Start processing */
	InitLanguage();

	/* Read the input files */
	Pass1(argc, argv);

	/* Set up the forward reference table */
	MakeForwardReferences();

	/* Compare the input files to find runs */
	Compare();

	/* Delete forward reference table */
	FreeForwardReferences();

	/* Find positions of the runs found */
	Pass2();

	/* Print the similarities */
	Pass3();

	return 0;
}
Beispiel #7
0
static void DefineMacro (void)
/* Handle a macro definition. */
{
    ident       Ident;
    Macro*      M;
    Macro*      Existing;
    int         C89;

    /* Read the macro name */
    SkipWhitespace (0);
    if (!MacName (Ident)) {
        return;
    }

    /* Remember if we're in C89 mode */
    C89 = (IS_Get (&Standard) == STD_C89);

    /* Get an existing macro definition with this name */
    Existing = FindMacro (Ident);

    /* Create a new macro definition */
    M = NewMacro (Ident);

    /* Check if this is a function like macro */
    if (CurC == '(') {

        /* Skip the left paren */
        NextChar ();

        /* Set the marker that this is a function like macro */
        M->ArgCount = 0;

        /* Read the formal parameter list */
        while (1) {

            /* Skip white space and check for end of parameter list */
            SkipWhitespace (0);
            if (CurC == ')') {
                break;
            }

            /* The next token must be either an identifier, or - if not in
             * C89 mode - the ellipsis.
             */
            if (!C89 && CurC == '.') {
                /* Ellipsis */
                NextChar ();
                if (CurC != '.' || NextC != '.') {
                    PPError ("`...' expected");
                    ClearLine ();
                    return;
                }
                NextChar ();
                NextChar ();

                /* Remember that the macro is variadic and use __VA_ARGS__ as
                 * the argument name.
                 */
                AddMacroArg (M, "__VA_ARGS__");
                M->Variadic = 1;

            } else {
                /* Must be macro argument name */
                if (MacName (Ident) == 0) {
                    return;
                }

                /* __VA_ARGS__ is only allowed in C89 mode */
                if (!C89 && strcmp (Ident, "__VA_ARGS__") == 0) {
                    PPWarning ("`__VA_ARGS__' can only appear in the expansion "
                               "of a C99 variadic macro");
                }

                /* Add the macro argument */
                AddMacroArg (M, Ident);
            }

            /* If we had an ellipsis, or the next char is not a comma, we've
             * reached the end of the macro argument list.
             */
            SkipWhitespace (0);
            if (M->Variadic || CurC != ',') {
                break;
            }
            NextChar ();
        }

        /* Check for a right paren and eat it if we find one */
        if (CurC != ')') {
            PPError ("`)' expected");
            ClearLine ();
            return;
        }
        NextChar ();
    }

    /* Skip whitespace before the macro replacement */
    SkipWhitespace (0);

    /* Insert the macro into the macro table and allocate the ActualArgs array */
    InsertMacro (M);

    /* Remove whitespace and comments from the line, store the preprocessed
     * line into the macro replacement buffer.
     */
    Pass1 (Line, &M->Replacement);

    /* Remove whitespace from the end of the line */
    while (IsSpace (SB_LookAtLast (&M->Replacement))) {
        SB_Drop (&M->Replacement, 1);
    }
#if 0
    printf ("%s: <%.*s>\n", M->Name, SB_GetLen (&M->Replacement), SB_GetConstBuf (&M->Replacement));
#endif

    /* If we have an existing macro, check if the redefinition is identical.
     * Print a diagnostic if not.
     */
    if (Existing && MacroCmp (M, Existing) != 0) {
        PPError ("Macro redefinition is not identical");
    }
}
Beispiel #8
0
/******************************************************************************
 Description : 
  Parameters : 
     Returns : 
    Comments : 
 ******************************************************************************/
int
main(int argc, char *argv[])
{
    char optch;
    char *outputext = "ptp";
    int  exitvalue = EXIT_SUCCESS;

/******
 * Set up globals.
 ******/

    if (argv[0] != NULL)
        ProgName = argv[0];

/******
 * Check parameters.
 ******/

    opterr = 0;

    while ((optch = getopt(argc, argv, "l:")) != -1)
    {
        switch (optch)
        {
            case 'l':
                ListFileName = optarg;
                break;
            default:
                usage();
        }
    }

    if (optind + 1 != argc)
        usage();

    InFileName = argv[optind];
    InFile = fopen(InFileName, "r");
    if (InFile == NULL)
        Error("Can't open '%s' for first pass read: %s", InFileName, strerror(errno));

    if (strlen(InFileName) > 3 &&
        STREQ(InFileName + strlen(InFileName) - 4, ".asm"))
    {
        char *newname = CopyStr(InFileName);
        char *chptr = newname + strlen(newname) - 4;

        *chptr = '\0';
        sprintf(OutFileName, "%s.%s", newname, outputext);

        free(newname);
    }
    else
        sprintf(OutFileName, "%s.%s", InFileName, outputext);

    OutFile = fopen(OutFileName, "w");
    if (OutFile == NULL)
        Error("Can't open '%s' for output: %s", OutFileName, strerror(errno));

    if (ListFileName != NULL)
    {
        ListFile = fopen(ListFileName, "w");
        if (ListFile == NULL)
            Error("Can't open '%s' for list output: %s", ListFileName, strerror(errno));
    }

/******
 * Assemble the input file.
 ******/

    if (Pass1())
    {
        fclose(InFile);
        InFile = fopen(InFileName, "r");
        if (InFile == NULL)
            Error("Can't open '%s' for second pass read: %s", InFileName, strerror(errno));

        if (!Pass2())
            exitvalue = PASS2_FAIL;
    }
    else
        exitvalue = PASS1_FAIL;

/******
 * Close the files.
 ******/

    if (InFile != NULL)
        fclose(InFile);
    if (OutFile != NULL)
        fclose(OutFile);

    exit(exitvalue);
}