This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathmain.c
More file actions
199 lines (170 loc) · 5.04 KB
/
main.c
File metadata and controls
199 lines (170 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/* Copyright (C) 2016 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode 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 LiveCode. If not see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <position.h>
#include "literal.h"
#include "report.h"
#include "outputfile.h"
extern void ROOT(void);
extern void yyExtend(void);
extern void InitializeCustomInvokeLists(void);
int IsDependencyCompile(void)
{
return 0;
}
/* Print some sort of helpful message if the user doesn't pass sane arguments */
static void
usage(int status)
{
fprintf(stderr,
"Usage: lc-compile-ffi-java [OPTION ...] --check OUTFILE --output OUTFILE [--] SOURCEFILES\n"
"\n"
"Parse a Java FFI DSL source file.\n"
"\n"
"Options:\n"
" --check OUTFILE Filename for reconstructed output.\n"
" --output OUTFILE Filename for generated LCB output.\n"
" --modulename NAME Name for output LCB module.\n"
" -Werror Turn all warnings into errors.\n"
" -v, --verbose Output extra debugging information.\n"
" -h, --help Print this message.\n"
" -- Treat all remaining arguments as filenames.\n"
"\n"
"Report bugs to <http://quality.livecode.com/>\n"
);
exit (status);
}
static void full_main(int argc, char *argv[])
{
/* Process options. */
int have_input_file = 0;
int end_of_args = 0;
int argi;
/* FIXME maybe we should use getopt? */
for (argi = 0; argi < argc; ++argi)
{
const char *opt = argv[argi];
const char *optarg = (argi + 1 < argc) && 0 != strncmp(argv[argi+1], "--", 2) ? argv[argi+1] : NULL;
if (!end_of_args)
{
if (0 == strcmp(opt, "--check") && optarg)
{
SetOutputFile(argv[++argi]);
continue;
}
if (0 == strcmp(opt, "--output") && optarg)
{
SetOutputLCBFile(argv[++argi]);
continue;
}
if (0 == strcmp(opt, "--modulename") && optarg)
{
SetOutputLCBModuleName(argv[++argi]);
continue;
}
/* FIXME This should be expanded to support "-W error",
* "--warn error", "--warn=error", etc. Also options for
* enabling/disabling/errorifying particular warning
* types. */
if (0 == strcmp(opt, "-Werror"))
{
s_is_werror_enabled = 1;
continue;
}
if (0 == strcmp(opt, "-v") || 0 == strcmp(opt, "--verbose"))
{
++s_verbose_level;
continue;
}
if (0 == strcmp(opt, "-h") || 0 == strcmp(opt, "--help"))
{
usage(0);
continue;
}
if (0 == strcmp(opt, "--"))
{
end_of_args = 1;
continue;
}
/* Detect unrecognized arguments */
if ('-' == opt[0])
{
fprintf(stderr, "ERROR: Invalid option '%s'.\n\n",
argv[argi]);
usage(1);
}
}
AddFile(opt);
have_input_file = 1;
}
// If there is no filename, error.
if (!have_input_file)
{
fprintf(stderr, "ERROR: You must specify an input filename.\n\n");
usage(1);
}
if (MoveToNextFile())
{
yyExtend();
InitializeCustomInvokeLists();
ROOT();
}
}
// No built-in modules for the compiler
void* g_builtin_modules[1] = {NULL};
unsigned int g_builtin_module_count = 0;
extern int yydebug;
int main(int argc, char *argv[])
{
//extern int yydebug;
int t_return_code;
// Skip command arg.
argc -= 1;
argv += 1;
// Check for debug mode.
if (argc > 1 && strcmp(argv[0], "--debug") == 0)
{
argc -= 1;
argv += 1;
#ifdef YYDEBUG
yydebug = 1;
#endif
}
InitializeFiles();
InitializePosition();
InitializeLiterals();
InitializeReports();
InitializeScopes();
// Check for bootstrap mode.
full_main(argc, argv);
if (ErrorsDidOccur())
t_return_code = 1;
else
t_return_code = 0;
FinalizeScopes();
FinalizeReports();
FinalizeLiterals();
FinalizePosition();
FinalizeFiles();
return t_return_code;
/*extern FILE *yyin;
yyin = fopen(argv[0], "r");
if (yyin == NULL)
{
fprintf(stderr, "Could not open file '%s'\n", argv[0]);
return 1;
}
Run();
return 0;*/
}