Parser::Parser(const vector<Production>& productions, const string& parserTablePath) : BasicParser(productions), parserTablePath(parserTablePath) { #ifdef _DEBUG stream.open("ParserResult.txt", fstream::out | fstream::binary); #endif // String Begin Rule quotationMarks = Rule('\"', &context); Rule ruleString = quotationMarks + *!quotationMarks + quotationMarks; ruleString.buildDFA(); ruleString.setShowName("\"{String}\""); Production::Item itemString(ruleString); // String End // Digit Start Rule _0('0', &context); Rule _9('9', &context); Rule _0_9 = _0 - _9; Rule ruleDigit = +_0_9; ruleDigit.buildDFA(); ruleDigit.setShowName("\"{Digit}\""); Production::Item itemDigit(ruleDigit); // Digit End // Real Start Rule _point('.', &context); Rule ruleReal = *_0_9 + _point + +_0_9; ruleReal.buildDFA(); ruleReal.setShowName("\"{Real}\""); Production::Item itemReal(ruleReal); // Real End // Letter Start Rule _('_', &context); Rule _a('a', &context); Rule _z('z', &context); Rule _A('A', &context); Rule _Z('Z', &context); Rule _a_z = _a - _z; Rule _A_Z = _A - _Z; Rule ruleLetter = ((+_ + ruleDigit) | (+(_ | _a_z | _A_Z))) + *(_ | ruleDigit | _a_z | _A_Z); ruleLetter.buildDFA(); ruleLetter.setShowName("\"{Letter}\""); Production::Item itemLetter(ruleLetter); // Letter End vts.push_back(pair<string, Production::Item>("{String}", itemString)); vts.push_back(pair<string, Production::Item>("{Digit}", itemDigit)); vts.push_back(pair<string, Production::Item>("{Real}", itemReal)); vts.push_back(pair<string, Production::Item>("{Letter}", itemLetter)); }
int main() { int _19 = 0; struct _31* _1 = NULL; struct _31* _32 = NULL; while(1){ char _3[80]; fgets(_3, 80, stdin); if (feof(stdin)) { break; } struct _31 *_2 = malloc(sizeof(struct _31)); _2->_34 = 0; _2->_36 = NULL; _19++; _2->_33 = strdup(_3); if (_1 != NULL) { _1->_36 = _2; _1 = _2; } else { _1 = _2; _32 = _2; } } int** _14 = (int**)malloc(_19 * sizeof(int*)); int _18; for (_18 = 0; _18 < _19; _18++) { _14[_18] = (int*)malloc(_19 * sizeof(int)); } struct _31 **_8 = (struct _31**)malloc(_19 * sizeof(struct _31)); struct _31 *_5 = NULL; int _12; int _15 = 0; for (_12 = 0; _12 < _19; _12+=2) { struct _31* _3 = _32; _32 = _32->_36; struct _31* _4 = _32; _32 = _32 ->_36; struct _31* _7 = _9(_5, _3->_33); if (_7 == NULL) { _7 = _3; _7 -> index = _15; _8[_15] = _7; _15++; _7 -> _36 = _5; _5 = _7; } struct _31* _6 = _9(_5, _4->_33); if (_6 == NULL) { _6 = _4; _6 -> index = _15; _8[_15] = _6; _15++; _6 -> _36 = _5; _5 = _6; } _14[_6->index][_7->index] = 1; _7->_34 = _7->_34+1; } _11(_8, _15, _14); return 0; }