diff --git a/modcc/token.cpp b/modcc/token.cpp index 3cdcfa4eeb966f277d39acf9a4ff984187c1b1ae..8348a6e8a219ba3c9b5f16850cfdfb81b7586610 100644 --- a/modcc/token.cpp +++ b/modcc/token.cpp @@ -55,7 +55,9 @@ static Keyword keywords[] = { {"METHOD", tok::method}, {"STEADYSTATE", tok::steadystate}, {"if", tok::if_stmt}, + {"IF", tok::if_stmt}, {"else", tok::else_stmt}, + {"ELSE", tok::else_stmt}, {"cnexp", tok::cnexp}, {"sparse", tok::sparse}, {"min", tok::min}, diff --git a/test/unit-modcc/test_parser.cpp b/test/unit-modcc/test_parser.cpp index 4730560b39996471220239263a2a147f6cb675fd..11e6e51b8a90eae3c306dd3460194837718e80ac 100644 --- a/test/unit-modcc/test_parser.cpp +++ b/test/unit-modcc/test_parser.cpp @@ -280,6 +280,19 @@ TEST(Parser, parse_if) { EXPECT_NE(s->false_branch(), nullptr); } + EXPECT_TRUE(check_parse(s, &Parser::parse_if, + " IF(a<b) { \n" + " a = 2+b \n" + " } ELSE { \n" + " a = 2+b \n" + " } " + )); + if (s) { + EXPECT_NE(s->condition()->is_binary(), nullptr); + EXPECT_NE(s->true_branch()->is_block(), nullptr); + EXPECT_NE(s->false_branch(), nullptr); + } + EXPECT_TRUE(check_parse(s, &Parser::parse_if, " if(fabs(a-b)) { \n" " a = 2+b \n"