diff --git a/.vscode/settings.json b/.vscode/settings.json index 9c2d689..3d47c94 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -70,6 +70,8 @@ "numeric": "cpp", "stack": "cpp", "list": "cpp", - "variant": "cpp" + "variant": "cpp", + "__functional_base_03": "cpp", + "charconv": "cpp" } } \ No newline at end of file diff --git a/ml.cpp b/ml.cpp index 377ca9f..aaff3aa 100644 --- a/ml.cpp +++ b/ml.cpp @@ -2163,7 +2163,7 @@ int main(int argc, char *argv[]) { // help if (cmdOptionExists(argv, argv + argc, "-h")) { std::cout - << "Usage:\n\t-h print this help\n\t-b skip stdlib loading\n\t-c code - runs code passed on command line\n\t-f source_file - executes code in file\n\t-i runs repl\n\t-p prints profile info at the end\n\t-v prints version string\n\n"; + << "Usage:\n\t-h print this help\n\t-b skip stdlib loading\n\t-c code - runs code passed on command line\n\t-f source_file - executes code in file\n\t-i runs repl\n\t-run used for shebang\n\t-p prints profile info at the end\n\t-v prints version string\n\n"; return 0; } // version @@ -2176,19 +2176,18 @@ int main(int argc, char *argv[]) { std::vector codes = getCmdOption(argv, argc, "-c"); for (size_t i = 0; i < codes.size(); i++) run(codes[i], env); - // run files + // run files } else if (cmdOptionExists(argv, argv + argc, "-f")) { std::vector files = getCmdOption(argv, argc, "-f"); for (size_t i = 0; i < files.size(); i++) run(read_file_contents(files[i]), env); - // just one parameter - filename - } else if (argc == 2 && !cmdOptionExists(argv, argv + argc, "-b")) { - std::string file_content = read_file_contents(argv[1]); + // sheebang + } else if (argc == 3 && cmdOptionExists(argv, argv + argc, "-run")) { + std::string file_content = read_file_contents(argv[2]); if (file_content.find("#!") == 0) // shebang ? - file_content.erase(0, file_content.find("\n") + - 1); // TODO mac osx newline?? + file_content.erase(0, file_content.find("\n") + 1); // TODO mac osx newline?? run(file_content, env); - // repl + // repl } else { repl(env); } diff --git a/usql/main.cpp b/usql/main.cpp index f128100..3fea64f 100644 --- a/usql/main.cpp +++ b/usql/main.cpp @@ -148,7 +148,7 @@ void debug() { "insert into a (i, s, b) values(1, upper('zero'), 'Y')", "insert into a (i, s, b, f) values(1 + 10000, upper('one'), 'N', 3.1415)", "insert into a (i, s, f) values(2 + 10000, upper('two'), 9.1415)", - "select * from a order by i", + "select pp(f * 100, \"%.2f\"), i from a order by i", // "select min(i), max(f), count(*) from a where b is not null", // "select * from a where b is null", // "select * from a where b is not null", diff --git a/usql/parser.cpp b/usql/parser.cpp index 4889147..1109241 100644 --- a/usql/parser.cpp +++ b/usql/parser.cpp @@ -424,7 +424,7 @@ namespace usql { m_lexer.skipToken(TokenType::open_paren); while (m_lexer.tokenType() != TokenType::close_paren && m_lexer.tokenType() != TokenType::eof) { - pars.push_back(parse_value()); + pars.push_back(parse_expression()); m_lexer.skipTokenOptional(TokenType::comma); } m_lexer.skipToken(TokenType::close_paren); diff --git a/usql/usql.cpp b/usql/usql.cpp index 7ac76d3..238824d 100644 --- a/usql/usql.cpp +++ b/usql/usql.cpp @@ -309,6 +309,8 @@ std::unique_ptr USql::pp_function(const std::vector= 1000000000000) std::snprintf(buf, 20, "%7.2fT", value/1000000000000); else if (value >= 1000000000)