-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cc
36 lines (30 loc) · 875 Bytes
/
main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<bits/stdc++.h>
#include "gpeg_parser.h"
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
void code(Grammar *g) {
vector<Nonterminal*> vec = g->getNonterminals();
cout << "the nubmer of Nonterminals = " << vec.size() << endl;
rep(i,(int)vec.size()) {
Node* tmp = new Node;
tmp->setType(0);
tmp->values[0] = vec[i];
cout << "[+[" << i+1 << "]+] " << tmp->toString() << endl;
}
}
int main() {
//string gpeg = " nari <-.* \n yoshi <- 'aaa'\n";
string gpeg="";
string buf;
while( getline(cin,buf) ) gpeg += (buf + "\n");
gpeg_parser::GPEGParser tmp(gpeg);
//tmp.debug();
//std::cout << "vvv------v------vvv" << std::endl;
Grammar* g = tmp.parse();
//puts("---encoding finished---");
//code(g);
//std::cout << "^^^------^------^^^" << std::endl;
//puts("");
tmp.encode();
}