Browse Source

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.
master
Skia 2 months ago
parent
commit
b06785f4b7
2 changed files with 22 additions and 9 deletions
  1. BIN
      Parser/debug/ParserTest
  2. +22
    -9
      Parser/src/Parser.cpp

BIN
Parser/debug/ParserTest View File


+ 22
- 9
Parser/src/Parser.cpp View File

@@ -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…
Cancel
Save