Last stuff found in my worktree
The git hook seems to tell me it's building, but I don't know what works and what doesn't.
This commit is contained in:
parent
5931642177
commit
b06785f4b7
Binary file not shown.
|
@ -73,16 +73,29 @@ bool Parser::decls()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Parser::decl(List *l) //XXX: memleak because we don't free what we rem/pop
|
||||
// TODO: Improve that a lot to really return what could be a possible unexpected token:
|
||||
// always check the size of the list, and the tokens one by one, not every thing in one test!
|
||||
// Handle array and declaration in general
|
||||
bool Parser::decl(List *l)
|
||||
{
|
||||
std::cout << "Size: " << l->getSize() << std::endl;
|
||||
if (l->rem()->getTokenType() == T_INT && l->pop()->getTokenType() == T_IDENTIFIER) {
|
||||
// TODO: Improve that a lot to really return what could be a possible unexpected token:
|
||||
// always check the size of the list, and the tokens one by one, not every thing in one test!
|
||||
if (l->head() != NULL)
|
||||
array(l);
|
||||
// Handle array and declaration in general
|
||||
return true;
|
||||
Token *first = l->rem(),
|
||||
*last = l->pop();
|
||||
// std::cout << "Size: " << l->getSize() << std::endl;
|
||||
if (first->getTokenType() == T_INT) {
|
||||
if (last->getTokenType() == T_IDENTIFIER) {
|
||||
if (l->head() != NULL)
|
||||
array(l);
|
||||
// TODO: add the var to the dcl tree
|
||||
delete first;
|
||||
delete last;
|
||||
return true;
|
||||
} else {
|
||||
delete first;
|
||||
error(last);
|
||||
}
|
||||
} else {
|
||||
delete last;
|
||||
error(first);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue