Adding implementation comments to Language
This commit is contained in:
parent
b8f2380c60
commit
aecad978ec
1 changed files with 5 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ SimpleParser::SimpleParser() {
|
|||
// Define Context-Free grammar
|
||||
ContextFreeGrammar contextFreeGrammar;
|
||||
{
|
||||
// use existing CF grammar interface
|
||||
auto term = contextFreeGrammar.createTerminal();
|
||||
|
||||
auto nonTerm = contextFreeGrammar.createNonTerminal();
|
||||
|
|
@ -23,6 +24,7 @@ SimpleParser::SimpleParser() {
|
|||
// Define Regular grammar
|
||||
RegularGrammar regularGrammar;
|
||||
{
|
||||
// this is basically ast from existing tokenizer
|
||||
regularGrammar.addRule(regularGrammar.alternate(regularGrammar.repeat(regularGrammar.symbols("asd")), regularGrammar.symbol("a")));
|
||||
regularGrammar.addRule(regularGrammar.alternate(regularGrammar.repeat(regularGrammar.symbols("asd")), regularGrammar.symbol("a")));
|
||||
}
|
||||
|
|
@ -37,12 +39,14 @@ void SimpleParser::compileTables(const Sentence& grammar) {
|
|||
// compile each ast into RegularGrammar and ContextFree Grammar api instructions
|
||||
ContextFreeGrammar userContextFreeGrammar;
|
||||
RegularGrammar userRegularGrammar;
|
||||
|
||||
// ...
|
||||
// split ast into RE and CF part
|
||||
// generate and execute grammar api commands
|
||||
// use existing tokenizer code to create RE transition matrix
|
||||
// ...
|
||||
|
||||
// compile tables from user grammar
|
||||
|
||||
mUserParser.compileTables(userContextFreeGrammar, userRegularGrammar);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue