diff --git a/src/lfortran/parser/fixedform_tokenizer.cpp b/src/lfortran/parser/fixedform_tokenizer.cpp index a45d549aec..6bbd9defea 100644 --- a/src/lfortran/parser/fixedform_tokenizer.cpp +++ b/src/lfortran/parser/fixedform_tokenizer.cpp @@ -994,6 +994,12 @@ struct FixedFormRecursiveDescent { return true; } + if (next_is(cur, "exit")) { + push_token_advance(cur, "exit"); + tokenize_line(cur); + return true; + } + if (next_is(cur, "goto")) { push_token_advance(cur, "goto"); tokenize_line(cur); diff --git a/tests/fixed_form_with_exit.f b/tests/fixed_form_with_exit.f new file mode 100644 index 0000000000..276881ce30 --- /dev/null +++ b/tests/fixed_form_with_exit.f @@ -0,0 +1,6 @@ + SUBROUTINE EXAMPLE + INTEGER I + DO I = 2, 8 + IF (I == 2) EXIT + END DO + END \ No newline at end of file diff --git a/tests/reference/ast-fixed_form_with_exit-0c669e6.json b/tests/reference/ast-fixed_form_with_exit-0c669e6.json new file mode 100644 index 0000000000..15dc8c1b39 --- /dev/null +++ b/tests/reference/ast-fixed_form_with_exit-0c669e6.json @@ -0,0 +1,13 @@ +{ + "basename": "ast-fixed_form_with_exit-0c669e6", + "cmd": "lfortran --fixed-form --show-ast --no-color {infile} -o {outfile}", + "infile": "tests/fixed_form_with_exit.f", + "infile_hash": "96d9aae99e4783183d44514eb3229ae1d1879847d4722d605ae687f6", + "outfile": null, + "outfile_hash": null, + "stdout": "ast-fixed_form_with_exit-0c669e6.stdout", + "stdout_hash": "438fb8012f29766becc2f526e72e71043772617a0ae5c81a28566eb8", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/ast-fixed_form_with_exit-0c669e6.stdout b/tests/reference/ast-fixed_form_with_exit-0c669e6.stdout new file mode 100644 index 0000000000..d81042b46a --- /dev/null +++ b/tests/reference/ast-fixed_form_with_exit-0c669e6.stdout @@ -0,0 +1,57 @@ +(TranslationUnit + [(Subroutine + example + [] + [] + () + () + [] + [] + [] + [(Declaration + (AttrType + TypeInteger + [] + () + () + None + ) + [] + [(i + [] + [] + () + () + None + ())] + () + )] + [(DoLoop + 0 + () + 0 + i + 2 + 8 + () + [(If + 0 + () + (== i 2) + [(Exit + 0 + () + () + )] + [] + () + () + () + )] + () + () + )] + [] + [] + )] +) diff --git a/tests/tests.toml b/tests/tests.toml index 9a00785e45..7797d57ecd 100644 --- a/tests/tests.toml +++ b/tests/tests.toml @@ -2628,6 +2628,10 @@ ast = true filename = "fixed_form_without_newline.f" ast = true +[[test]] +filename = "fixed_form_with_exit.f" +ast = true + [[test]] filename = "fixedform_doloop.f" ast = true