misc fixes

This commit is contained in:
VaclavT 2021-09-23 23:03:54 +02:00
parent 48f46289d6
commit 7f793bde61
5 changed files with 14 additions and 11 deletions

View File

@ -70,6 +70,8 @@
"numeric": "cpp",
"stack": "cpp",
"list": "cpp",
"variant": "cpp"
"variant": "cpp",
"__functional_base_03": "cpp",
"charconv": "cpp"
}
}

15
ml.cpp
View File

@ -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<std::string> 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<std::string> 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);
}

View File

@ -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",

View File

@ -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);

View File

@ -309,6 +309,8 @@ std::unique_ptr<ValueNode> USql::pp_function(const std::vector<std::unique_ptr<V
if (format == "100%")
std::snprintf(buf, 20, "%.2f%%", value);
else if (format == "%.2f")
std::snprintf(buf, 20, "%.2f", value);
else if (value >= 1000000000000)
std::snprintf(buf, 20, "%7.2fT", value/1000000000000);
else if (value >= 1000000000)