2 * Copyright (c) 2010 Jiri Svoboda
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 /** @file Main module.
31 * Main entry point for SBI, the Sysel Bootstrap Interpreter.
32 * When run without parameters, the interpreter will enter interactive
52 static void syntax_print(void);
56 * @return Zero on success, non-zero on error.
58 int main(int argc
, char *argv
[])
60 stree_program_t
*program
;
65 /* Store executable file path under which we have been invoked. */
66 os_store_ef_path(*argv
);
72 /* Enter interactive mode */
78 if (os_str_cmp(*argv
, "-h") == 0) {
84 program
= stree_program_new();
85 program
->module
= stree_module_new();
87 /* Declare builtin symbols. */
88 builtin_declare(program
);
90 /* Process source files in the library. */
91 if (program_lib_process(program
) != EOK
)
94 /* Resolve ancestry. */
95 ancr_module_process(program
, program
->module
);
97 /* Bind internal interpreter references to symbols. */
98 builtin_bind(program
->builtin
);
100 /* Process all source files specified in command-line arguments. */
102 rc
= program_file_process(program
, *argv
);
110 /* Resolve ancestry. */
111 ancr_module_process(program
, program
->module
);
114 stype
.program
= program
;
115 stype
.error
= b_false
;
116 stype_module(&stype
, program
->module
);
118 /* Check for typing errors. */
124 run_program(&run
, program
);
126 /* Check for run-time errors. */
127 if (run
.thread_ar
->error
)
133 /** Print command-line syntax help. */
134 static void syntax_print(void)
136 printf("Syntax: sbi <source_file.sy>\n");