OpenCores
URL https://opencores.org/ocsvn/raptor64/raptor64/trunk

Subversion Repositories raptor64

[/] [raptor64/] [trunk/] [software/] [c64/] [source/] [Cmain.c] - Blame information for rev 51

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 37 robfinch
#include        <stdio.h>
2
#include <string.h>
3
#include        "c.h"
4
#include        "expr.h"
5
#include        "gen.h"
6
#include        "cglbdec.h"
7
 
8
/*
9
 *      68000 C compiler
10
 *
11
 *      Copyright 1984, 1985, 1986 Matthew Brandt.
12
 *  all commercial rights reserved.
13
 *
14
 *      This compiler is intended as an instructive tool for personal use. Any
15
 *      use for profit without the written consent of the author is prohibited.
16
 *
17
 *      This compiler may be distributed freely for non-commercial use as long
18
 *      as this notice stays intact. Please forward any enhancements or questions
19
 *      to:
20
 *
21
 *              Matthew Brandt
22
 *              Box 920337
23
 *              Norcross, Ga 30092
24
 */
25
/*******************************************************
26
        Modified to support Raptor64 'C64' language
27
        by Robert Finch
28
        robfinch@opencores.org
29
*******************************************************/
30
 
31
void makename(char *s, char *e);
32
void summary();
33
int options(char *);
34
int openfiles(char *);
35
void closefiles();
36
 
37 51 robfinch
char            infile[32],
38
                listfile[32],
39
                outfile[32],
40
                                outfileG[32];
41
 
42 37 robfinch
extern TABLE    tagtable;
43
int             mainflag;
44
extern int      total_errors;
45
int uctran_off;
46
 
47
int main(int argc, char **argv)
48
{
49
        uctran_off = 0;
50
        while(--argc) {
51
        if( **++argv == '-')
52
            options(*argv);
53
        else if( openfiles(*argv)) {
54
            lineno = 0;
55
            initsym();
56
                        memset(gsyms,0,sizeof(gsyms));
57
            getch();
58
            NextToken();
59
            compile();
60
            summary();
61
            ReleaseGlobalMemory();
62
            closefiles();
63
        }
64
    }
65
        getchar();
66
        return 0;
67
}
68
 
69
int     options(char *s)
70
{
71
        optimize =1;
72
        exceptions=1;
73
        if (s[1]=='o')
74
                optimize = 0;
75
        return 0;
76
}
77
 
78
int     openfiles(char *s)
79
{
80 51 robfinch
        int     ofl,oflg;
81
        int i;
82 37 robfinch
        strcpy(infile,s);
83
        strcpy(listfile,s);
84
        strcpy(outfile,s);
85 51 robfinch
                strcpy(outfileG,s);
86
                _splitpath(s,NULL,NULL,nmspace[0],NULL);
87 37 robfinch
        makename(listfile,".lis");
88
        makename(outfile,".s");
89 51 robfinch
                makename(outfileG,".sg");
90 37 robfinch
        if( (input = fopen(infile,"r")) == 0) {
91
                printf(" cant open %s\n",infile);
92
                return 0;
93
                }
94
        ofl = _creat(outfile,-1);
95
        if( ofl < 0 )
96
                {
97
                printf(" cant create %s\n",outfile);
98
                fclose(input);
99
                return 0;
100
                }
101 51 robfinch
        oflg = _creat(outfileG,-1);
102
        if( oflg < 0 )
103
                {
104
                printf(" cant create %s\n",outfileG);
105
                fclose(input);
106
                return 0;
107
                }
108 37 robfinch
        if( (output = _fdopen(ofl,"w")) == 0) {
109
                printf(" cant open %s\n",outfile);
110
                fclose(input);
111
                return 0;
112
                }
113 51 robfinch
        if( (outputG = _fdopen(oflg,"w")) == 0) {
114
                printf(" cant open %s\n",outfileG);
115
                fclose(input);
116
                fclose(output);
117
                return 0;
118
                }
119 37 robfinch
        if( (list = fopen(listfile,"w")) == 0) {
120
                printf(" cant open %s\n",listfile);
121
                fclose(input);
122
                fclose(output);
123 51 robfinch
                fclose(outputG);
124 37 robfinch
                return 0;
125
                }
126
        return 1;
127
}
128
 
129
void makename(char *s, char *e)
130
{
131
        while(*s != 0 && *s != '.')
132
        ++s;
133
    while(*s++ = *e++);
134
}
135
 
136
void summary()
137
{
138
        printf("\n -- %d errors found.",total_errors);
139
    fprintf(list,"\f\n *** global scope typedef symbol table ***\n\n");
140
    ListTable(&gsyms,0);
141
    fprintf(list,"\n *** structures and unions ***\n\n");
142
    ListTable(&tagtable,0);
143
}
144
 
145
void closefiles()
146
{
147
        fclose(input);
148
    fclose(output);
149 51 robfinch
        fclose(outputG);
150 37 robfinch
    fclose(list);
151
}
152 51 robfinch
 
153
char *GetNamespace()
154
{
155
        return nmspace[incldepth];
156
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.