Added comments

This commit is contained in:
2024-12-06 22:05:41 +01:00
parent d2cbdc2910
commit b3f75ae3d8
15 changed files with 128 additions and 12 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -80,4 +80,4 @@ namespace fsh {
bool append = false;
};
} // namespace fsh
}

View File

@ -66,4 +66,4 @@ namespace fsh {
std::shared_ptr<ExecutableNode> pipe;
};
} // namespace fsh
}

View File

@ -6,6 +6,7 @@
namespace fsh {
// Genericni node namenjen kao wrapper za tokene
template <Lexer::TokenType T>
class TokenNode : public AstNode {
public: