Initial commit

This commit is contained in:
2024-12-02 06:30:40 +00:00
commit fd62fb822d
33 changed files with 1972 additions and 0 deletions

46
include/ast/ast.hpp Normal file
View File

@ -0,0 +1,46 @@
/*
* Fsh Grammar
*
* Command_Line ::= Command EOF
* | Command Pipeline_Command
*
* Pipeline_Command ::= "|" Command EOF
* | "|" Command "|" Pipeline_Command
*
* Command ::= Command_Name [Flag_Opt] {Command_Argument} [Redirect]
*
* Redirects ::= [LRedirect Word] RRedirect Word | [RRedirect Word] LRedirect Word
*
* Command_Argument ::= Word | String_Literal
*
* Command_Name ::= Word
*/
#pragma once
#include "lexer.hpp"
#include "util/text.hpp"
#include "ast/ast_base.hpp"
#include "ast/ast_token.hpp"
#include "ast/ast_component.hpp"
#include "ast/ast_executable.hpp"
namespace fsh {
class AstFactory {
public:
// Generates an abstract syntax tree
static std::shared_ptr<ExecutableNode> generate_ast(std::list<Token>& list) {
auto it = list.begin();
return CommandLineNode::build(it);
}
private:
static AstFactory& get_factory();
AstFactory() {}
AstFactory(const AstFactory&) = default;
};
}