Initial commit
This commit is contained in:
46
include/ast/ast.hpp
Normal file
46
include/ast/ast.hpp
Normal 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;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user