static struct Closure * init(struct Closure *_ptrInput, const struct Grammar * const __ptrGrammar, int __state){ struct internals *_ptrInternals = (struct internals *)_ptrInput->internals; _ptrInternals->Grammar = __ptrGrammar; _ptrInput->Items = (struct LinkedList*)Create_Object(LINKEDLIST); _ptrInput->Items = _ptrInput->Items->init(_ptrInput->Items, sizeof(struct ItemInClosure)); _ptrInput->Links = (struct LinkedList*)Create_Object(LINKEDLIST); _ptrInput->Links = _ptrInput->Links->init(_ptrInput->Links, sizeof(struct Link)); _ptrInput->State = __state; return _ptrInput; }
void WeaponSysLoad(List *list, AEGfxVertexList *pmesh, AEGfxTexture *pTex) { //***********************************************************************************// // Creating Player Bullet Object // //***********************************************************************************// pTex = AEGfxTextureLoad("Assets/Player_Bullet.png"); Create_Object(list, pmesh, pTex, Player_Bullet, Texture); //***********************************************************************************// // Creating Enemy Bullet Object // //***********************************************************************************// pTex = AEGfxTextureLoad("Assets/Enemy_Bullet.png"); Create_Object(list, pmesh, pTex, Enemy_Bullet, Texture); }
static struct SLRParser * init(struct SLRParser *__ptrInput, int **__Grammar, int *__Rows, int __countRows, int __countNonterminals, int __countTerminals){ struct internals *_ptrInternals = (struct internals *)__ptrInput->internals; _ptrInternals->ParseTable = (struct ParseTable *)Create_Object(PARSETABLE); _ptrInternals->ParseTable = _ptrInternals->ParseTable->init(_ptrInternals->ParseTable, __Grammar, __Rows, __countRows, __countNonterminals, __countTerminals); return __ptrInput; }
//allocates memory for the FIRST array static void InitFirstArray(struct First *__ptrInput, struct Grammar *__ptrGrammar){ struct internals *_ptrInternals = (struct internals *)__ptrInput->internals; int i; __ptrInput->arrFirst = (struct LinkedList **)malloc(sizeof(struct LinkedList *)*_ptrInternals->countRows); for ( i =0;i < _ptrInternals->countRows;i++){ __ptrInput->arrFirst[i] = (struct LinkedList *)Create_Object(LINKEDLIST); __ptrInput->arrFirst[i] = __ptrInput->arrFirst[i]->init(__ptrInput->arrFirst[i], sizeof(int)); } }
struct LinkedList * ItemsDotEnd(struct Closure *__ptrInput){ struct LinkedList *_ptrOutput = (struct LinkedList *)Create_Object(LINKEDLIST); struct internals *_ptrInternals = (struct internals *)__ptrInput->internals; struct ItemInClosure *_ptrValue; int _itemAfterDot; _ptrOutput = _ptrOutput->init(_ptrOutput, sizeof(struct ItemInClosure)); while (__ptrInput->Items->Head->Next!=NULL){ _ptrValue= (struct ItemInClosure *)__ptrInput->Items->Head->Value; _itemAfterDot = _ptrInternals->Grammar->GetItemAfterDot(_ptrInternals->Grammar, _ptrValue->intProduction, _ptrValue->intDot); if (_itemAfterDot ==-1){ _ptrOutput->Add(_ptrValue, _ptrOutput); } } return _ptrOutput; }
struct LinkedList *NT_First(int __nonTerminal, struct First *__ptrFirst){ struct LinkedList *_ptrOutput; struct LinkedList *_ptrRows; struct internals *_ptrInternals; struct Grammar *_ptrGrammar; struct LinkedListNode *_ptrRowsHead; int _production; _ptrOutput = (struct LinkedList *)Create_Object(LINKEDLIST); _ptrOutput = _ptrOutput->init(_ptrOutput, sizeof(int)); _ptrInternals = (struct internals *)__ptrFirst->internals; _ptrGrammar = _ptrInternals->Grammar; _ptrRows = _ptrGrammar->GetRows(_ptrGrammar, __nonTerminal); _ptrRowsHead = _ptrRows->Head; while (_ptrRowsHead->Next!=NULL){ _production = *(int *)_ptrRowsHead->Value; Add_NTs_First(_ptrOutput, _production, __ptrFirst); _ptrRowsHead = _ptrRowsHead->Next; } return _ptrOutput; }
struct ParseTree * Parse(struct SLRParser *__ptrParser, int *__tokens){ struct Stack *_ptrStack = (struct Stack *)Create_Object(STACK); struct ParseTree *_ptrOutput = (struct ParseTree*)Create_Object( PARSETREE); struct ParseTreeNode *_ptrHead; struct internals *_ptrInternals = (struct internals *)__ptrParser->internals; int _state; int _nextState; int _popCount; int _tokenIndex =0; int _reduceNTer; int i; enum EnumActions _nextAction; int df; _ptrOutput = _ptrOutput->init(_ptrOutput, sizeof(int)); _ptrStack = _ptrStack->init(_ptrStack, sizeof(int)); _state =0; _ptrStack->Push(_ptrStack, &_state); _ptrHead= _ptrOutput->Head; while (1){ _state = *(int *)_ptrStack->Read(_ptrStack); if (_tokenIndex ==7){ _tokenIndex=7; } _ptrInternals->ParseTable->NextAction(_ptrInternals->ParseTable,__tokens[_tokenIndex], _state, &_nextState, &_nextAction, &_reduceNTer, &_popCount); if (_nextAction == SHIFT){ if (__tokens[_tokenIndex]==6){ df=1; } _ptrStack->Push(_ptrStack, &_nextState); _ptrHead=_ptrOutput->Add_Next(_ptrOutput, _ptrHead, &__tokens[_tokenIndex]); _tokenIndex++; } else if (_nextAction == REDUCE){ if (_popCount >0){ _ptrStack->Pop(_ptrStack); } for ( i =0;i <_popCount-1;i++){ _ptrStack->Pop(_ptrStack); _ptrHead=_ptrOutput->GetPrevious(_ptrHead); } _ptrHead=_ptrOutput->Add_PSh(_ptrOutput, _ptrHead, &_reduceNTer); if (Par_Red(_ptrOutput,_ptrHead, __ptrParser, _ptrStack, _state, _reduceNTer, _popCount) ==-1){ return NULL; } } else if (_nextAction == ACCEPT){ return _ptrOutput; } else{ return NULL; } } return NULL; }