source: mainline/uspace/app/sbi/src/main.c@ fa36f29

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since fa36f29 was fa36f29, checked in by Jiri Svoboda <jiri@…>, 16 years ago

Update SBI to rev. 75.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 * Copyright (c) 2010 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
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.
16 *
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.
27 */
28
29/** @file Main module. */
30
31#include <stdio.h>
32#include <stdlib.h>
33#include "ancr.h"
34#include "builtin.h"
35#include "mytypes.h"
36#include "strtab.h"
37#include "stree.h"
38#include "input.h"
39#include "lex.h"
40#include "parse.h"
41#include "run.h"
42
43void syntax_print(void);
44
45int main(int argc, char *argv[])
46{
47 input_t *input;
48 lex_t lex;
49 parse_t parse;
50 stree_program_t *program;
51 run_t run;
52 int rc;
53
54 if (argc != 2) {
55 syntax_print();
56 exit(1);
57 }
58
59 rc = input_new(&input, argv[1]);
60 if (rc != EOK) {
61 printf("Failed opening source file '%s'.\n", argv[1]);
62 exit(1);
63 }
64
65 strtab_init();
66 program = stree_program_new();
67 program->module = stree_module_new();
68
69 /* Declare builtin symbols. */
70 builtin_declare(program);
71
72 /* Parse input file. */
73 lex_init(&lex, input);
74 parse_init(&parse, program, &lex);
75 parse_module(&parse);
76
77 /* Resolve ancestry. */
78 ancr_module_process(program, parse.cur_mod);
79
80 /* Run program. */
81 run_init(&run);
82 run_program(&run, program);
83
84 return 0;
85}
86
87void syntax_print(void)
88{
89 printf("Missing or invalid arguments.\n");
90 printf("Syntax: sbi <source_file.sy>\n");
91}
Note: See TracBrowser for help on using the repository browser.