Skip to content
Snippets Groups Projects
Commit 2f89a2d2 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Remove a bunch of unnecessary language namespace embedding

parent d5546c4d
No related branches found
No related tags found
1 merge request!37Feature/language
......@@ -260,11 +260,11 @@ using selector =
ASTBuilder::simplify_stream_statement::on<ostream_statement>>;
template <typename InputT>
std::unique_ptr<language::ASTNode>
std::unique_ptr<ASTNode>
ASTBuilder::build(InputT& input)
{
return parse_tree::parse<language::grammar, language::ASTNode, selector, nothing, language::errors>(input);
return parse_tree::parse<language::grammar, ASTNode, selector, nothing, language::errors>(input);
}
template std::unique_ptr<language::ASTNode> ASTBuilder::build(read_input<>& input);
template std::unique_ptr<language::ASTNode> ASTBuilder::build(string_input<>& input);
template std::unique_ptr<ASTNode> ASTBuilder::build(read_input<>& input);
template std::unique_ptr<ASTNode> ASTBuilder::build(string_input<>& input);
......@@ -18,7 +18,7 @@ struct ASTBuilder
public:
template <typename InputT>
static std::unique_ptr<language::ASTNode> build(InputT& input);
static std::unique_ptr<ASTNode> build(InputT& input);
};
#endif // AST_BUILDER_HPP
......@@ -10,8 +10,6 @@
using namespace TAO_PEGTL_NAMESPACE;
namespace language
{
struct ExecUntilBreakOrContinue
{
enum class JumpType
......@@ -52,7 +50,6 @@ struct ExecUntilBreakOrContinue
}
};
class SymbolTable;
class INodeProcessor
{
public:
......@@ -65,8 +62,13 @@ class INodeProcessor
virtual ~INodeProcessor() {}
};
class SymbolTable;
struct ASTNode : public parse_tree::basic_node<ASTNode>
{
using DataType = language::DataType;
using DataVariant = language::DataVariant;
std::shared_ptr<SymbolTable> m_symbol_table;
std::unique_ptr<INodeProcessor> m_node_processor;
......@@ -83,6 +85,5 @@ struct ASTNode : public parse_tree::basic_node<ASTNode>
DataType m_data_type{DataType::undefined_t};
DataVariant m_value;
};
} // namespace language
#endif // AST_NODE_HPP
......@@ -85,8 +85,7 @@ operator<<(std::ostream& os, const ASTPrinter& ast_printer)
return os;
}
ASTPrinter::ASTPrinter(const language::ASTNode& node, Format format, std::initializer_list<Info> initializer_list)
: m_node{node}
ASTPrinter::ASTPrinter(const ASTNode& node, Format format, std::initializer_list<Info> initializer_list) : m_node{node}
{
if (format == Format::pretty) {
T_junction = " \u251c\u2500\u2500";
......
......@@ -3,8 +3,6 @@
#include <PEGGrammar.hpp>
namespace language
{
void
ASTSymbolTableBuilder::buildSymbolTable(ASTNode& n, std::shared_ptr<SymbolTable>& symbol_table)
{
......@@ -53,4 +51,3 @@ ASTSymbolTableBuilder::ASTSymbolTableBuilder(ASTNode& node)
this->buildSymbolTable(node, symbol_table);
std::cout << " - checked symbols declaration\n";
}
} // namespace language
......@@ -2,10 +2,7 @@
#define AST_SYMBOL_TABLE_BUILDER_HPP
#include <ASTNode.hpp>
namespace language
{
class SymbolTable;
#include <SymbolTable.hpp>
class ASTSymbolTableBuilder
{
......@@ -19,6 +16,5 @@ class ASTSymbolTableBuilder
~ASTSymbolTableBuilder() = default;
};
} // namespace language
#endif // AST_SYMBOL_TABLE_BUILDER_HPP
......@@ -408,13 +408,13 @@ parser(const std::string& filename)
std::cout << rang::style::bold << "Parsing file " << rang::style::reset << rang::style::underline << filename
<< rang::style::reset << " ...\n";
std::unique_ptr<language::ASTNode> root_node;
std::unique_ptr<ASTNode> root_node;
read_input input(filename);
try {
root_node = ASTBuilder::build(input);
std::cout << " - AST is built ...... [done]\n";
language::ASTSymbolTableBuilder{*root_node};
ASTSymbolTableBuilder{*root_node};
language::check_symbol_initialization(*root_node);
{
......@@ -438,7 +438,7 @@ parser(const std::string& filename)
std::cout << language::ASTPrinter{*root_node} << '\n';
language::ExecUntilBreakOrContinue exec_all;
ExecUntilBreakOrContinue exec_all;
root_node->execute(exec_all);
std::cout << *(root_node->m_symbol_table) << '\n';
}
......
#ifndef SYMBOL_TABLE_HPP
#define SYMBOL_TABLE_HPP
namespace language
{
#include <ASTNodeDataType.hpp>
class SymbolTable
{
public:
class Attributes
{
private:
using DataType = language::DataType;
using DataVariant = language::DataVariant;
bool m_is_initialized{false};
DataType m_data_type{DataType::undefined_t};
DataVariant m_value;
......@@ -121,6 +126,5 @@ class SymbolTable
;
}
};
} // namespace language
#endif // SYMBOL_TABLE_HPP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment