Language Initial
This commit is contained in:
parent
73897f11df
commit
b8f2380c60
47 changed files with 831 additions and 14 deletions
8
Language/public/AST.hpp
Normal file
8
Language/public/AST.hpp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "LanguageCommon.hpp"
|
||||
|
||||
namespace tp {
|
||||
class AST {};
|
||||
}
|
||||
9
Language/public/Grammar.hpp
Normal file
9
Language/public/Grammar.hpp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "LanguageCommon.hpp"
|
||||
|
||||
namespace tp {
|
||||
class ContextFreeGrammar {};
|
||||
class RegularGrammar {};
|
||||
}
|
||||
6
Language/public/GrammarCompiler.hpp
Normal file
6
Language/public/GrammarCompiler.hpp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Grammar.hpp"
|
||||
|
||||
namespace tp {}
|
||||
7
Language/public/LanguageCommon.hpp
Normal file
7
Language/public/LanguageCommon.hpp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Module.hpp"
|
||||
|
||||
namespace tp {
|
||||
extern ModuleManifest gModuleLanguage;
|
||||
}
|
||||
20
Language/public/Parser.hpp
Normal file
20
Language/public/Parser.hpp
Normal 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
|
||||
};
|
||||
}
|
||||
13
Language/public/Sentence.hpp
Normal file
13
Language/public/Sentence.hpp
Normal 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; }
|
||||
};
|
||||
}
|
||||
20
Language/public/SimpleParser.hpp
Normal file
20
Language/public/SimpleParser.hpp
Normal 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;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue