Skip to content

Commit

Permalink
can i even do this
Browse files Browse the repository at this point in the history
  • Loading branch information
wilyJ80 committed Dec 12, 2024
1 parent caf56fd commit fbc4fbf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
18 changes: 12 additions & 6 deletions parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ enum SYNTAX_ERROR arrayFator(struct Parser *parser) {
return NO_ERROR;
}

enum SYNTAX_ERROR expr(struct Parser *parser) {
// TODO:
return NO_ERROR;
}

/**
* prog accepts repetitions of declarations of variables (decl_list_var), or
* procedures (decl_list_proc).
Expand Down Expand Up @@ -465,12 +460,23 @@ enum SYNTAX_ERROR cmdDo(struct Parser *parser) {
parser->token.category == REALCON || parser->token.category == CHARCON ||
(parser->token.category == SIGN && parser->token.signCode == OPEN_PAR) ||
(parser->token.category == SIGN && parser->token.signCode == NEGATION)) {
enum SYNTAX_ERROR error = fator(parser);
// goes from expr down to fator
enum SYNTAX_ERROR error = expr(parser);
if (error != NO_ERROR) {
return error;
}
}

parser->token = lexerGetNextChar(parser->fd, parser->lineCount);
if (!(parser->token.category == SIGN && parser->token.signCode == CLOSE_PAR)) {
return INVALID_FUNCTION_CALL_PAREN_CLOSE;
}

return NO_ERROR;
}

enum SYNTAX_ERROR expr(struct Parser *parser) {
// TODO:
return NO_ERROR;
}

Expand Down
7 changes: 7 additions & 0 deletions test/parser_integration_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,17 @@ void atribAssignedToABadExprAStringcon() {
assert(error == NO_FACTOR_VALID_START_SYMBOL);
}

void doButNoClosingParen() {
enum SYNTAX_ERROR error = setupError("def nitrogenio(int i) do nitrogenio(8(");
assert(error == INVALID_FUNCTION_CALL_PAREN_CLOSE);
}


// TODO:
//
// atrib with bad unclosed paren
/*void atribBadClosedParen() {*/
/* enum SYNTAX_ERROR error = setupError("def oxigenio(int i) id[8[");*/
/* assert(error == NO_ATRIB_BRACKET_CLOSE);*/
/*}*/

2 changes: 2 additions & 0 deletions test/parser_integration_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ void putstrError();

void doButNotIdproc();
void doButNoParenOpen();
void doButNoClosingParen();
// test expression list too

void atribNoValidAfterId();
void atribAssignedToABadExprAStringcon();
Expand Down
2 changes: 1 addition & 1 deletion test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int main(void) {

doButNotIdproc();
doButNoParenOpen();
// doIdprocExprExprSimpTermoFatorNoValidTokenAfterId();
doButNoClosingParen();

atribNoValidAfterId();
atribAssignedToABadExprAStringcon();
Expand Down

0 comments on commit fbc4fbf

Please sign in to comment.