X-Git-Url: https://jxself.org/git/?p=zilutils.git;a=blobdiff_plain;f=zilasm%2Fmain.cpp;fp=zilasm%2Fmain.cpp;h=68846b03da7fb491cf82c6861d67baf59a8bdc8b;hp=22b7e7145c09d8642fe8df92455ebae9b11d26ec;hb=633e24778bccbc5f035bdb8516e8cc75c85123d9;hpb=82b0f84ab797141758929d16894d42e12ef79af7 diff --git a/zilasm/main.cpp b/zilasm/main.cpp index 22b7e71..68846b0 100644 --- a/zilasm/main.cpp +++ b/zilasm/main.cpp @@ -2,7 +2,7 @@ * main.c * * Copyright (C) 2015 Alexander Andrejevic - * Copyright (C) 2015, 2019 Jason Self + * Copyright (C) 2015, 2019, 2020 Jason Self * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -24,6 +24,12 @@ #include #include #include +#include +#include +#include +using namespace std; + + extern "C" { #include @@ -39,9 +45,7 @@ extern "C" } #include "parser.h" -#include -#include -using namespace std; + const int DEFAULT_ZVERSION = 6; @@ -143,7 +147,7 @@ CMain::assembly () ++m_code_size; // write instructions' codes - for (int i = 0; i < g_numberOfInstructions; ++i) + for (int i = 0; i < g_number_of_instructions; ++i) { for (int j = 0; j < g_codes[i]->used_size; ++j) { @@ -424,9 +428,33 @@ main (int argc, char *argv[], char *envp[]) init_parser (); - for (int i = optind; i < argc; i++) - parse_file (argv[i]); - main.assembly (); + //for (int i = optind; i < argc; i++) + // parse_file(argv[i]); + + string file_name = argv[optind]; + Parsing_Context pc; + +#ifdef WIN32 + char delimeter = '\\'; +#else + char delimeter = '/'; +#endif + + if (file_name.rfind(delimeter) == string::npos) + { + pc.current_directory = ""; + pc.current_file_name = file_name; + } + else + { + pc.current_directory = file_name.substr(0, file_name.rfind(delimeter)+1); + pc.current_file_name = file_name.substr(file_name.rfind(delimeter)+1); + } + g_parsing_contexts.push(pc); + + parse_file();// argv[optind]); + if ( !g_haveErrors ) + main.assembly (); /* TODO! List global symbols */ /* TODO! Find abbreviations */