Commit 7e8ad6fc authored by Sergio Costas's avatar Sergio Costas

Added an extra test to check if a WHILE stops fine when the condition is met

parent 436c88ba
......@@ -1053,13 +1053,13 @@ class crust(object):
if var_container["loop_level"] == 0:
self._add_error(var_container,self.MSG_CRITICAL,"Break not in a loop at line {:d}",node.line)
return [(None,None)]
while(tree[0].type != "ENDLOOP"):
while(tree[0].type != "END_LOOP"):
tree = tree[1:]
return [self._check_return_block(tree,var_container)]
return self._check_return_block(tree,var_container)
if node.type == "END_LOOP":
var_container["loop_level"] -= 1
return [self._check_return_block(tree[1:],var_container)]
return self._check_return_block(tree[1:],var_container)
if node.type == "WHILE":
var_container["loop_level"] += 1
......@@ -1096,26 +1096,36 @@ class crust(object):
def _new_start_block(self):
node = self.AST_node()
node.type = "START_BLOCK"
node.line = -1
node.name = ""
return node
def _new_end_block(self):
node = self.AST_node()
node.type = "END_BLOCK"
node.line = -1
node.name = ""
return node
def _new_end_loop(self):
node = self.AST_node()
node.type = "END_LOOP"
node.line = -1
node.name = ""
return node
def _new_eval_false(self,condition):
node = self.AST_node()
node.type = "EVAL_FALSE"
node.condition = condition.copy()
node.line = -1
node.name = ""
return node
def _new_eval_true(self,condition):
node = self.AST_node()
node.type = "EVAL_TRUE"
node.condition = condition.copy()
node.line = -1
node.name = ""
return node
......@@ -91,7 +91,6 @@ class tokens(object):
344:'START_BLOCK',
345:'END_BLOCK',
346:'TYPENAME_IDENTIFIER',
347:'ENDLOOP',
'IDENTIFIER':258,
'CONSTANT':259,
'STRING_LITERAL':260,
......@@ -181,7 +180,6 @@ class tokens(object):
'START_BLOCK':344,
'END_BLOCK':345,
'TYPENAME_IDENTIFIER':346,
'ENDLOOP':347,
}
@staticmethod
......
......@@ -401,6 +401,8 @@ class Test(unittest.TestCase):
def testOrOpWrong(self):
self._generic_test("unitest/test101.c",[ (crust.crust.MSG_ERROR,"Assignment to '{:s}' at line {:d}, which was already assigned at line {:d}","param2",11,7) ])
def testWhileCrustVarFine(self):
self._all_fine_test("unitest/test102.c")
if __name__ == '__main__':
unittest.main()
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
void main(crust_t param) {
while(param == NULL) {
param = (crust_t) 1;
}
main(param);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment