Added comments
This commit is contained in:
@ -29,7 +29,7 @@ namespace fsh {
|
||||
|
||||
class AstFactory {
|
||||
public:
|
||||
// Generates an abstract syntax tree
|
||||
// Generise abstraktno sintaksno drvo po ebnf formuli gore
|
||||
static std::shared_ptr<ExecutableNode> generate_ast(std::list<Token>& list) {
|
||||
auto it = list.begin();
|
||||
return CommandLineNode::build(it);
|
||||
@ -41,4 +41,4 @@ namespace fsh {
|
||||
AstFactory(const AstFactory&) = default;
|
||||
};
|
||||
|
||||
} // namespace fsh
|
||||
}
|
||||
@ -33,6 +33,7 @@ namespace fsh {
|
||||
using TokenType = Lexer::TokenType;
|
||||
AstNode(NodeType type, std::string name) : type(type), name(name) {}
|
||||
|
||||
// Pokusa da napravi od narednih tokena zadati Node ako ne uspe vrati null
|
||||
template <class T>
|
||||
static std::shared_ptr<T> Optional(std::list<Token>::iterator& it, std::shared_ptr<T>& node_ptr);
|
||||
|
||||
@ -42,6 +43,7 @@ namespace fsh {
|
||||
return Optional<T>(it, node_ptr);
|
||||
}
|
||||
|
||||
// Pravi od narednih tokena zadati Node ako ne uspe izbaci AstBuildError
|
||||
template <class T>
|
||||
static std::shared_ptr<T> Mandatory(std::list<Token>::iterator& it) {
|
||||
return T::build(it);
|
||||
@ -70,4 +72,4 @@ namespace fsh {
|
||||
AstBuildError(std::string err) : std::runtime_error(err) {}
|
||||
};
|
||||
|
||||
} // namespace fsh
|
||||
}
|
||||
@ -80,4 +80,4 @@ namespace fsh {
|
||||
bool append = false;
|
||||
};
|
||||
|
||||
} // namespace fsh
|
||||
}
|
||||
@ -66,4 +66,4 @@ namespace fsh {
|
||||
std::shared_ptr<ExecutableNode> pipe;
|
||||
};
|
||||
|
||||
} // namespace fsh
|
||||
}
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
namespace fsh {
|
||||
|
||||
// Genericni node namenjen kao wrapper za tokene
|
||||
template <Lexer::TokenType T>
|
||||
class TokenNode : public AstNode {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user