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

Subversion Repositories c16

[/] [c16/] [trunk/] [compiler/] [cc80.cc] - Blame information for rev 29

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 29 jsauermann
#include <assert.h>
2 2 jsauermann
#include <stdio.h>
3
#include <stdlib.h>
4 29 jsauermann
#include <string.h>
5
 
6 2 jsauermann
#include "List.hh"
7
#include "Backend.hh"
8
 
9
extern FILE * yyin;
10
extern FILE * out;
11
extern int yyparse();
12
 
13
static int usage(const char * prog, int ret);
14
 
15
FILE * out = 0;
16
 
17
extern bool is_loader;
18
extern int  memtop;
19
 
20
bool is_loader = false;
21
int  memtop = 0;
22
 
23
//-----------------------------------------------------------------------------
24
int main(int argc, char * argv[])
25
{
26
int ret = 0;
27
 
28
const char * prog = *argv;
29
   argv++;
30
   argc--;
31
 
32
   if (argc < 1)   return usage(prog, 1);
33
 
34
   if (!strcmp(*argv, "-l"))
35
      {
36
        argv++;
37
        argc--;
38
        is_loader = true;
39
      }
40
 
41
   if (argc < 1)   return usage(prog, 2);
42
 
43
   memtop = strtol(*argv, 0, 0);
44
   if (!memtop)   return usage(prog, 3);
45
   fprintf(stderr, "Top of memory is 0x%X\n", memtop);
46
   argv++;
47
   argc--;
48
 
49
   if (argc < 1)   return usage(prog, 4);
50
   yyin = fopen(*argv,  "r");
51
   if (yyin == 0)
52
      {
53
        fprintf(stderr, "Can't open input file %s\n", *argv);
54
        return 5;
55
      }
56
   argv++;
57
   argc--;
58
 
59
   out = stdout;
60
   if (argc)
61
      {
62
        out = fopen(*argv, "w");
63
        if (out == 0)
64
           {
65
             fprintf(stderr, "Can't open output file %s\n", *argv);
66
             return 6;
67
           }
68
      }
69
 
70
   Backend::file_header();
71
 
72
   if (yyparse())
73
      {
74
        fprintf(stderr, "PARSE ERROR\n");
75
        ret = 7;
76
      }
77
   else
78
      {
79
        fprintf(stderr, "PARSED OK\n");
80
        if (Node::GetSemanticErrors())
81
           {
82
             fprintf(stderr, "BUT: %d errors\n", Node::GetSemanticErrors());
83
             ret = Node::GetSemanticErrors();
84
           }
85
      }
86
 
87
   Backend::file_footer();
88
 
89
   fclose(yyin);
90
   fclose(out);
91
   yyin = 0;
92
   return ret;
93
}
94
//-----------------------------------------------------------------------------
95
int usage(const char * prog, int ret)
96
{
97
   fprintf(stderr, "\n%s: Error %d\n", prog, ret);
98
   fprintf(stderr, "\nUsage:\n   %s [-l] memtop file.c [file.asm]\n", prog);
99
   return ret;
100
}
101
//-----------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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