Skip to content

Commit b486f88

Browse files
Manuel AstudilloManuel Astudillo
Manuel Astudillo
authored and
Manuel Astudillo
committed
Removed several warnings.
1 parent 3688ef7 commit b486f88

File tree

1 file changed

+4
-157
lines changed

1 file changed

+4
-157
lines changed

src/LALR.cpp

Lines changed: 4 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,8 @@
9494
Symbol *LALR::nextReduction (bool trimReductions, bool reportOnlyOneError) {
9595
Action *actObj;
9696
Token *tok;
97-
NonTerminal *newNonTerminal;
98-
Terminal *newTerminal;
99-
100-
integer index;
101-
102-
integer i;
103-
104-
int action, target;
97+
98+
int action;
10599

106100
m_trimReductions = trimReductions;
107101

@@ -156,154 +150,7 @@
156150
return rdc;
157151
}
158152

159-
/*
160-
action = actObj->action;
161-
target = actObj->target;
162-
163-
if (DEBUG) wprintf (L"Action: %d\n", action);
164-
165-
switch (action) {
166-
// Pushes current token into the stack
167-
case ACTION_SHIFT:
168-
if (DEBUG) {
169-
wprintf (L"Shifting: ");
170-
wprintf (tokens[tokenIndex]->symbol.c_str());
171-
wprintf ( L"\nGo to state:%d\n\n", target);
172-
}
173-
174-
// Push current token on the stack
175-
currentState = target;
176-
177-
currentLine = tokens[tokenIndex]->line;
178-
currentCol = tokens[tokenIndex]->col;
179-
180-
tokens[tokenIndex]->state = currentState;
181-
182-
// Create a terminal symbol and push it on the stack
183-
newTerminal = new Terminal();
184-
tok = tokens[tokenIndex];
185-
newTerminal->symbol = tok->symbol;
186-
newTerminal->image = tok->image;
187-
newTerminal->symbolIndex = tok->symbolIndex;
188-
newTerminal->state = tok->state;
189-
newTerminal->line = tok->line;
190-
newTerminal->col = tok->col;
191-
192-
currentLine = tok->line;
193-
currentCol = tok->col;
194-
195-
symbolStack.push (newTerminal);
196-
197-
// Update Burke-Fisher Queue and Stack
198-
updateBurkeFisher (newTerminal);
199-
break;
200-
201-
202-
// Creates a new reduction. Pops all the terminals and non terminals
203-
// for this rule and pushes the most left non terminal.
204-
205-
case ACTION_REDUCE:
206-
if (DEBUG) {
207-
wprintf (L"Reducing...\n");
208-
}
209-
210-
// Create a new Non Terminal (to represent this reduction)
211-
newNonTerminal = new NonTerminal();
212-
index = ruleTable->rules[target].symbolIndex;
213-
214-
newNonTerminal->symbolIndex = index;
215-
newNonTerminal->symbol = symbolTable->symbols [index].name;
216-
217-
newNonTerminal->ruleIndex = ruleTable->rules[target].ruleIndex;
218-
newNonTerminal->line = currentLine;
219-
newNonTerminal->col = currentCol;
220-
221-
// If the rule has only a nonterminal then we dont create a reduction
222-
// node for this rule in the tree since its not usefull.
223-
// User can decide to simplify this by enabling the trimming
224-
if ((ruleTable->rules[target].symbols.size() == 1) &&
225-
(symbolTable->symbols[ruleTable->rules[target].symbols[0]].kind ==
226-
NON_TERMINAL) && trimReductions) {
227-
trim = true;
228-
newNonTerminal->trimmed = true;
229-
} else {
230-
newNonTerminal->trimmed = false;
231-
trim = false;
232-
}
233-
234-
if (DEBUG) {
235-
wprintf (symbolTable->symbols[ruleTable->rules[target].ruleIndex].name.c_str());
236-
wprintf (L" = ");
237-
}
238-
239-
// pop from the stack the tokens for the reduced rule
240-
// and store them in the reduction
241-
for (i=0; i < ruleTable->rules[target].symbols.size(); i++) {
242-
Symbol *s = symbolStack.top ();
243-
// If the symbol is trimmed we just pick up its children
244-
if (s->trimmed) {
245-
assert (s->type == NON_TERMINAL);
246-
NonTerminal *trimmedNT = (NonTerminal*) s;
247-
248-
assert (trimmedNT->children.size() == 1);
249-
newNonTerminal->children.push_front (trimmedNT->children[0]);
250-
} else {
251-
newNonTerminal->children.push_front (s);
252-
}
253-
symbolStack.pop();
254-
}
255-
256-
if (DEBUG) {
257-
for (i=0; i < ruleTable->rules[target].symbols.size(); i++) {
258-
int symIndex;
259-
if (!trim) {
260-
symIndex = newNonTerminal->children[i]->symbolIndex;
261-
}
262-
wprintf (symbolTable->symbols[symIndex].name.c_str());
263-
wprintf (L" ");
264-
}
265-
wprintf (L"\n");
266-
}
267-
268-
// Perform GOTO
269-
if (DEBUG) {
270-
wprintf (L"state: %d index: %d\n", symbolStack.top()->state,
271-
newNonTerminal->symbolIndex);
272-
}
273-
actObj = getNextAction (newNonTerminal->symbolIndex, symbolStack.top()->state);
274-
275-
if ((actObj != NULL) && (actObj->action == ACTION_GOTO)) {
276-
if (DEBUG) wprintf (L"Go to state: %d\n\n", actObj->target);
277-
currentState = actObj->target;
278-
newNonTerminal->state = currentState;
279-
280-
// Push the reduced nonterminal in the stack
281-
symbolStack.push (newNonTerminal);
282-
updateBurkeFisher (newNonTerminal);
283-
284-
} else {
285-
wprintf (L"Internal Error!!\n");
286-
reductionResult = REDUCTION_ERROR;
287-
return NULL;
288-
}
289-
290-
return newNonTerminal;
291-
break;
292-
293-
// This Action should never happen...
294-
case ACTION_GOTO:
295-
wprintf (L"Goto: %d", target);
296-
currentState = target;
297-
break;
298-
299-
case ACTION_ACCEPT:
300-
reductionResult = REDUCTION_TEXT_ACCEPTED;
301-
if (DEBUG) wprintf (L"text parsed succesfully\n");
302-
return NULL;
303-
break;
304-
}
305-
*/
306-
}
153+
}
307154
}
308155
reductionResult = REDUCTION_ERROR;
309156
return NULL;
@@ -414,7 +261,7 @@
414261

415262
Symbol *LALR::parseToken (Action *actObj, SymbolStack &theStack, int tokenIndex,
416263
integer &currentState) {
417-
Token *tok;
264+
418265
NonTerminal *newNonTerminal;
419266
Terminal *newTerminal;
420267

0 commit comments

Comments
 (0)