Changeset 074444f in mainline for uspace/app/sbi/src/main.c


Ignore:
Timestamp:
2010-04-10T11:15:33Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1ef0fc3, 38aaacc2
Parents:
23de644
Message:

Update SBI to rev. 184.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sbi/src/main.c

    r23de644 r074444f  
    3737#include <stdlib.h>
    3838#include "ancr.h"
     39#include "os/os.h"
    3940#include "builtin.h"
    4041#include "imode.h"
    4142#include "mytypes.h"
     43#include "program.h"
    4244#include "strtab.h"
    4345#include "stree.h"
     
    4850#include "run.h"
    4951
    50 void syntax_print(void);
     52static void syntax_print(void);
    5153
    5254/** Main entry point.
     
    5658int main(int argc, char *argv[])
    5759{
    58         input_t *input;
    59         lex_t lex;
    60         parse_t parse;
    6160        stree_program_t *program;
    6261        stype_t stype;
     
    6463        int rc;
    6564
    66         if (argc == 1) {
     65        /* Store executable file path under which we have been invoked. */
     66        os_store_ef_path(*argv);
     67
     68        argv += 1;
     69        argc -= 1;
     70
     71        if (argc == 0) {
    6772                /* Enter interactive mode */
    6873                strtab_init();
     
    7176        }
    7277
    73         if (argc != 2) {
     78        if (os_str_cmp(*argv, "-h") == 0) {
    7479                syntax_print();
    75                 exit(1);
    76         }
    77 
    78         rc = input_new_file(&input, argv[1]);
    79         if (rc != EOK) {
    80                 printf("Failed opening source file '%s'.\n", argv[1]);
    81                 exit(1);
     80                return 0;
    8281        }
    8382
     
    8988        builtin_declare(program);
    9089
    91         /* Parse input file. */
    92         lex_init(&lex, input);
    93         parse_init(&parse, program, &lex);
    94         parse_module(&parse);
    95 
    96         /* Check for parse errors. */
    97         if (parse.error)
     90        /* Process source files in the library. */
     91        if (program_lib_process(program) != EOK)
    9892                return 1;
    9993
     94        /* Process all source files specified in command-line arguments. */
     95        while (argc > 0) {
     96                rc = program_file_process(program, *argv);
     97                if (rc != EOK)
     98                        return 1;
     99
     100                argv += 1;
     101                argc -= 1;
     102        }
     103
    100104        /* Resolve ancestry. */
    101         ancr_module_process(program, parse.cur_mod);
     105        ancr_module_process(program, program->module);
    102106
    103107        /* Type program. */
     
    122126
    123127/** Print command-line syntax help. */
    124 void syntax_print(void)
     128static void syntax_print(void)
    125129{
    126         printf("Missing or invalid arguments.\n");
    127130        printf("Syntax: sbi <source_file.sy>\n");
    128131}
Note: See TracChangeset for help on using the changeset viewer.