diff --git a/source/ParserRules.cpp b/source/ParserRules.cpp index b375c51..f979380 100644 --- a/source/ParserRules.cpp +++ b/source/ParserRules.cpp @@ -219,6 +219,11 @@ void Parser::statement() { case KW_while: next_token(); expression(); + if (tk.name == KW_do) { + next_token(); + } else { + panic("", { First::block, Follow::block }); + } do_statement(); break; case KW_if: diff --git a/tests/test1.png b/tests/test1.png new file mode 100644 index 0000000..4adc942 Binary files /dev/null and b/tests/test1.png differ diff --git a/tests/test1.txt b/tests/test1.txt deleted file mode 100644 index 23767e9..0000000 --- a/tests/test1.txt +++ /dev/null @@ -1,27 +0,0 @@ --- funcao bem util -function array_sum(array, id) - local total = 0; - for elem in array do - total = total + elem; - end; -end; - --- fatorial -function factorial(n) - local value = 1; - for i = 2, i <= n do - value = value * i; - end; - return value; -end; - --- fibonacci -function fibonacci(n) - local fib0, fib1 = 0, 1; - for i = 0, i < n do - local tmp = fib1; - fib1 = fib0 + fib1; - fib0 = fib1; - end; - return fib0; -end; diff --git a/tests/test2.png b/tests/test2.png new file mode 100644 index 0000000..bcd85e0 Binary files /dev/null and b/tests/test2.png differ diff --git a/tests/test3.png b/tests/test3.png new file mode 100644 index 0000000..d2d905a Binary files /dev/null and b/tests/test3.png differ