Files
fsh-oop/include/ast/ast.hpp

44 lines
1.1 KiB
C++

/*
* 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_component.hpp"
#include "ast/ast_executable.hpp"
#include "ast/ast_token.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;
};
} // namespace fsh