From ea5348c9d601be86438f8172cd848f870321f7fa Mon Sep 17 00:00:00 2001 From: thorstenhater <24411438+thorstenhater@users.noreply.github.com> Date: Fri, 15 May 2020 23:48:11 +0200 Subject: [PATCH] Make if/else statements case insensitive. (#1041) --- modcc/token.cpp | 2 ++ test/unit-modcc/test_parser.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/modcc/token.cpp b/modcc/token.cpp index 3cdcfa4e..8348a6e8 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 4730560b..11e6e51b 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" -- GitLab