diff --git a/.clangd b/.clangd index 64ba9d0..f1845bf 100644 --- a/.clangd +++ b/.clangd @@ -1,4 +1,4 @@ CompileFlags: CompileCommandsDir: . Add: - - "-std=c++2b" \ No newline at end of file + - "-std=c++23" \ No newline at end of file diff --git a/source/cli/include/cli.hh b/source/cli/include/cli.hh index 36657ea..d5afbd4 100644 --- a/source/cli/include/cli.hh +++ b/source/cli/include/cli.hh @@ -1,6 +1,148 @@ +/** + * @author Ojas Talgaonkar + * @copyright Copyright (c) 2024 (CC BY 4.0) + * + * @note This code is part of the Helix Language Project and is licensed under the Attribution 4.0 + * International license (CC BY 4.0). You are allowed to use, modify, redistribute, and create + * derivative works, even for commercial purposes, provided that you give appropriate credit, + * provide a link to the license, and indicate if changes were made. For more information, please + * visit: https://creativecommons.org/licenses/by/4.0/ SPDX-License-Identifier: CC-BY-4.0 + * + * @note This code is provided by the creators of Helix. Visit our website at: + * https://helix-lang.com/ for more information. + */ #include #include #include +#include #include -#include "cli/include/args.hh" \ No newline at end of file +#include "cli/include/args.hh" +#include "core/types/hx_ints" + +/* +Helios - package manager / build system + +Usage: + helios create Create a new Helix project. + helios build Build the current project. + helios run [-r] -- Run the current project with optional arguments. + helios test Run tests for the current project. + helios clean Clean build artifacts. + helios install Install a package. + helios uninstall Uninstall a package. + helios update Update all installed packages. + helios search Search for a package. + helios list List all installed packages. + helios info Show information about a specific package. + helios help Show help information. + helios version Show the version of Helios. + helios license Show the license of Helios. + helios doc-gen Generate documentation. +*/ + +/* +helix - command line interface + +Usage: + helix [options] [options-2] + helix (-h | --help) + helix --version + helix --license + +options: + -O1 --optimize1 Optimization level 1. + -O2 --optimize2 Optimization level 2. + -O3 --optimize3 Optimization level 3. + -O4 --optimize4 Optimization level 4. + -O5 --optimize5 Optimization level 5. + + -h --help Show this screen. + -v --version Show version. + -l --license Show license information. + + --verbose Show verbose output. + --quiet Show no output. + + --emit-tokens Show tokens. + --emit-llvm Show LLVM IR. + --emit-asm Show assembly. + --emit-ast Show AST in json format + --emit-ir Show intermediate representation. (C++) + --emit-doc Only extract doc-comments along with signatures in json format. + + --toolchain Set the toolchain to use + + --config Specify configuration file. + -r --release Build in release mode. + -d --debug Build in debug mode with symbols. + +options-2: + --lib [abi-options] Compile as library. + -o Output file. + -I Include directory. + -L Library directory. + -l Link library. + -m Helix Modules directory. + +options-3: + --target Target triple. + --arch Target architecture. + --os Target operating system. + --sdk Optional Path to a sdk. + +abi-options: + -py --python Python stub files gen and pylib compile + -rs --rust Rust source files gen and a rust compiler lib + -cxx --cxx C++ header files gen and linkable object file + -hlx --helix Helix ABI compatable libary +*/ + +namespace command_line { +class CLIArgs { + public: + enum class OPTIMIZATION : u8 { O1 = 1, O2 = 2, O3 = 3, O4 = 4, O5 = 5 }; + enum class MODE : char { RELEASE = 'r', DEBUG_= 'd' }; + enum class ABI : char { PYTHON = 'p', RUST = 'r', CXX = 'c', HELIX = 'h' }; + + std::string file; + std::optional output_file; + + // Options + OPTIMIZATION optimize; + + bool help = false; + + bool verbose = false; + bool quiet = false; + + bool emit_tokens = false; + bool emit_llvm = false; + bool emit_asm = false; + bool emit_ast = false; + bool emit_ir = false; + bool emit_doc = false; + + struct tool_chain { + std::string target; + std::string arch; + std::string os; + std::string sdk; + }; + + tool_chain toolchain; + + std::string config_file; + + MODE build_mode; + + ABI build_lib; // if --lib is passed without [-py, -rs, -cx, -hlx] then asumme -hlx + + std::vector include_dirs; + std::vector library_dirs; + std::vector link_libraries; + std::vector module_dirs; + + explicit CLIArgs(int argc, char **argv); +}; +} // end namespace command_line diff --git a/source/cli/source/cli.cc b/source/cli/source/cli.cc index d5a0621..7c72f1f 100644 --- a/source/cli/source/cli.cc +++ b/source/cli/source/cli.cc @@ -1,3 +1,16 @@ +/** + * @author Ojas Talgaonkar + * @copyright Copyright (c) 2024 (CC BY 4.0) + * + * @note This code is part of the Helix Language Project and is licensed under the Attribution 4.0 + * International license (CC BY 4.0). You are allowed to use, modify, redistribute, and create + * derivative works, even for commercial purposes, provided that you give appropriate credit, + * provide a link to the license, and indicate if changes were made. For more information, please + * visit: https://creativecommons.org/licenses/by/4.0/ SPDX-License-Identifier: CC-BY-4.0 + * + * @note This code is provided by the creators of Helix. Visit our website at: + * https://helix-lang.com/ for more information. + */ /* Helios - package manager / build system @@ -61,12 +74,13 @@ options-2: -I Include directory. -L Library directory. -l Link library. + -m Helix Modules directory. options-3: --target Target triple. --arch Target architecture. --os Target operating system. - + --sdk Optional Path to a sdk. abi-options: -py --python Python stub files gen and pylib compile @@ -75,98 +89,36 @@ abi-options: -hlx --helix Helix ABI compatable libary */ +#include "cli/include/cli.hh" + #include #include #include +#include #include #include "cli/include/args.hh" +#include "core/types/hx_ints" namespace command_line { -class CLIArgs { - template - explicit CLIArgs(int argc, char **argv) { - args::ArgumentParser parser( - "This is a test program with a really long description that is probably going to have " - "to be wrapped across multiple different lines. This is a test to see how the line " - "wrapping works", - "This goes after the options. This epilog is also long enough that it will have to be " - "properly wrapped to display correctly on the screen"); - - args::HelpFlag help(parser, "HELP", "Show this help menu.", {'h', "help"}); - - args::ValueFlag foo(parser, "FOO", "The foo flag.", - {'a', 'b', 'c', "a", "b", "c", "the-foo-flag"}); - - args::ValueFlag bar( - parser, "BAR", - "The bar flag. This one has a lot of options, and will need wrapping in the " - "description, along with its long flag list.", - {'d', 'e', 'f', "d", "e", "f"}); - - args::ValueFlag baz( - parser, "FOO", - "The baz flag. This one has a lot of options, and will need wrapping in the " - "description, even with its short flag list.", - {"baz"}); - - args::Positional pos1(parser, "POS1", "The pos1 argument."); - args::PositionalList poslist1(parser, "POSLIST1", "The poslist1 argument."); - - try { - parser.ParseCLI(argc, argv); - } catch (args::Help) { - std::cout << parser; - return; - } catch (args::ParseError e) { - std::cerr << e.what() << std::endl; - std::cerr << parser; - return; - } catch (args::ValidationError e) { - std::cerr << e.what() << std::endl; - std::cerr << parser; - return; +CLIArgs::CLIArgs(int argc, char **argv) { + // Parse command line arguments + args::ArgumentParser parser("helix parser"); + args::Group commands(parser, "commands"); + args::Command version(commands, {"-v", "--version"}, "displays version"); + args::Command lisence(commands, "--lisence", "displays lisence"); + + try { + parser.ParseCLI(argc, argv); + if (version) { + std::cout << "current_version"; + } else if (lisence) { + std::cout << "lisence"; } + + } catch (args::Help) { std::cout << parser; } catch (args::Error &e) { + std::cerr << e.what() << std::endl << parser; + return; } -}; - -struct HelixArguments { - // File and optional output file - std::string file; - std::optional output_file; - - // Options - bool optimize1 = false; - bool optimize2 = false; - bool optimize3 = false; - bool optimize4 = false; - - bool help = false; - bool version = false; - bool license = false; - - bool verbose = false; - bool quiet = false; - - bool show_ast = false; - bool show_tokens = false; - bool emit_llvm = false; - bool emit_asm = false; - bool emit_ir = false; - bool emit_doc = false; - - std::optional target_triple; - std::optional target_arch; - std::optional target_os; - - std::optional config_file; - bool release = false; - bool debug = false; - - // Options-2 - bool compile_as_library = false; - std::vector include_dirs; - std::vector library_dirs; - std::vector link_libraries; -}; +} } // end namespace command_line diff --git a/source/main.cc b/source/main.cc index 69b1199..63335dd 100644 --- a/source/main.cc +++ b/source/main.cc @@ -19,10 +19,10 @@ #include "cli/include/cli.hh" #include "controllers/include/file_system.hh" #include "core/utils/hx_print" +#include "lexer/include/lexer.hh" #include "parser/cst/include/cst.hh" #include "parser/cst/include/nodes.hh" #include "parser/preprocessor/include/preprocessor.hh" -#include "lexer/include/lexer.hh" int main(int argc, char **argv) { using namespace token; @@ -34,6 +34,8 @@ int main(int argc, char **argv) { // "D:\projects\helix-lang\tests\main.hlx" // std::string file_name = "/Volumes/Container/Projects/Helix/helix-lang/tests/main.hlx"; // // relative to current working dir in POSIX shell (cmd/bash) + command_line::CLIArgs(argc, argv); + std::string file_name = "tests/main.hlx"; // relative to current working dir in Windows shell (cmd/powershell) // read the file and tokenize its contents : stage 0 diff --git a/xmake.lua b/xmake.lua index 2028add..a5d0e3a 100644 --- a/xmake.lua +++ b/xmake.lua @@ -9,7 +9,7 @@ target("helix") add_headerfiles("source/**.hh") -- add all headers in the source directory add_includedirs("source") - set_languages("c++2b") -- set the standard C++ version to C++23 + set_languages("c++23") -- set the standard C++ version to C++23 if is_mode("debug") then set_symbols("debug") -- Generate debug symbols @@ -36,7 +36,7 @@ target("tests") add_includedirs("source") add_includedirs("tests/lib") - set_languages("c++latest") -- set the standard C++ version to C++23 + set_languages("c++23") -- set the standard C++ version to C++23 set_symbols("debug") -- Generate debug symbols set_optimize("none") -- Disable optimization