Ignore:
File:
1 edited

Legend:

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

    r074444f r23de644  
    3737#include <stdlib.h>
    3838#include "ancr.h"
    39 #include "os/os.h"
    4039#include "builtin.h"
    4140#include "imode.h"
    4241#include "mytypes.h"
    43 #include "program.h"
    4442#include "strtab.h"
    4543#include "stree.h"
     
    5048#include "run.h"
    5149
    52 static void syntax_print(void);
     50void syntax_print(void);
    5351
    5452/** Main entry point.
     
    5856int main(int argc, char *argv[])
    5957{
     58        input_t *input;
     59        lex_t lex;
     60        parse_t parse;
    6061        stree_program_t *program;
    6162        stype_t stype;
     
    6364        int rc;
    6465
    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) {
     66        if (argc == 1) {
    7267                /* Enter interactive mode */
    7368                strtab_init();
     
    7671        }
    7772
    78         if (os_str_cmp(*argv, "-h") == 0) {
     73        if (argc != 2) {
    7974                syntax_print();
    80                 return 0;
     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);
    8182        }
    8283
     
    8889        builtin_declare(program);
    8990
    90         /* Process source files in the library. */
    91         if (program_lib_process(program) != EOK)
     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)
    9298                return 1;
    9399
    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 
    104100        /* Resolve ancestry. */
    105         ancr_module_process(program, program->module);
     101        ancr_module_process(program, parse.cur_mod);
    106102
    107103        /* Type program. */
     
    126122
    127123/** Print command-line syntax help. */
    128 static void syntax_print(void)
     124void syntax_print(void)
    129125{
     126        printf("Missing or invalid arguments.\n");
    130127        printf("Syntax: sbi <source_file.sy>\n");
    131128}
Note: See TracChangeset for help on using the changeset viewer.