Skip to content

Commit

Permalink
Merge pull request lfortran#4485 from gxyd/exit_fixed_form
Browse files Browse the repository at this point in the history
fix: tokenize "exit" in fixed form parser
  • Loading branch information
certik authored Jul 11, 2024
2 parents 07a2f4a + 9d02c46 commit 3c76586
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lfortran/parser/fixedform_tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions tests/fixed_form_with_exit.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SUBROUTINE EXAMPLE
INTEGER I
DO I = 2, 8
IF (I == 2) EXIT
END DO
END
13 changes: 13 additions & 0 deletions tests/reference/ast-fixed_form_with_exit-0c669e6.json
Original file line number Diff line number Diff line change
@@ -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
}
57 changes: 57 additions & 0 deletions tests/reference/ast-fixed_form_with_exit-0c669e6.stdout
Original file line number Diff line number Diff line change
@@ -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
()
()
)]
[]
()
()
()
)]
()
()
)]
[]
[]
)]
)
4 changes: 4 additions & 0 deletions tests/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3c76586

Please sign in to comment.