Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Scala: allow ellipsis in for loop headers #539

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lang_scala/parsing/AST_scala.ml
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ and for_header = enumerators bracket
and enumerators = enumerator list
and enumerator =
| G of generator
| GIf of guard list
| GEllipsis of tok
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have added a (* semgrep-ext: *) comment, to indicate this is actually not part of Scala but
an AST extension useful for semgrep only.

(* less: GAssign *)

and generator = {
Expand Down
6 changes: 3 additions & 3 deletions lang_scala/parsing/Parser_scala_recursive_descent.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2255,9 +2255,9 @@ and guard_loop in_ : guard list =
and enumerator ~isFirst ?(allowNestedIf=true) in_ : enumerator =
in_ |> with_logging "enumerator" (fun () ->
match in_.token with
| Kif _ when not isFirst ->
let xs = guard_loop in_ in
GIf xs
| Ellipsis tok ->
nextToken in_;
GEllipsis tok
| _ ->
let g = generator ~eqOK:(not isFirst) ~allowNestedIf in_ in
G g
Expand Down