Language Initial

This commit is contained in:
IlyaShurupov 2024-02-03 12:18:10 +03:00 committed by Ilya Shurupov
parent 73897f11df
commit b8f2380c60
47 changed files with 831 additions and 14 deletions

8
Language/public/AST.hpp Normal file
View file

@ -0,0 +1,8 @@
#pragma once
#include "LanguageCommon.hpp"
namespace tp {
class AST {};
}

View file

@ -0,0 +1,9 @@
#pragma once
#include "LanguageCommon.hpp"
namespace tp {
class ContextFreeGrammar {};
class RegularGrammar {};
}

View file

@ -0,0 +1,6 @@
#pragma once
#include "Grammar.hpp"
namespace tp {}

View file

@ -0,0 +1,7 @@
#pragma once
#include "Module.hpp"
namespace tp {
extern ModuleManifest gModuleLanguage;
}

View file

@ -0,0 +1,20 @@
#pragma once
#include "AST.hpp"
#include "GrammarCompiler.hpp"
#include "Sentence.hpp"
namespace tp {
class Parser {
public:
Parser() = default;
public:
void compileTables(const ContextFreeGrammar& cfGrammar, const RegularGrammar& reGrammar);
void parse(const Sentence& sentence, AST& out);
public:
// save load compiled tables
};
}

View file

@ -0,0 +1,13 @@
#pragma once
#include "LanguageCommon.hpp"
namespace tp {
struct Sentence {
const int1* buffer = nullptr;
alni symbolSize = 1;
explicit Sentence(const char* buff) { buffer = buff; }
};
}

View file

@ -0,0 +1,20 @@
#pragma once
#include "Parser.hpp"
namespace tp {
// Gives ability to express grammar in the Unified Format as sentence
class SimpleParser {
public:
SimpleParser();
public:
void compileTables(const Sentence& grammar);
void parse(const Sentence& sentence, AST& out);
private:
Parser mUnifiedGrammarParser;
Parser mUserParser;
};
}