Skip to content

Fixes annotation parser #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/providers/swift/parsing/parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3088,19 +3088,23 @@ and balancedTokens _ =
(*| balanced-token -> Any identifier, keyword, literal, or operator |*)
(*| balanced-token -> Any punctuation except "(" , ")" , "[" , "]" , "{" , or "}" |*)
and balancedToken _ =
wchar '(' *> fix balancedTokens <* wchar '*'
wchar '(' *> fix balancedTokens <* wchar ')'
<|>
wchar '[' *> fix balancedTokens <* wchar ']'
<|>
wchar '{' *> fix balancedTokens <* wchar '}'
<|>
identifier () (*| this includes keywords |*)
<|>
literal ()
<|>
operator ()
<|> (
pos >>= fun pos ->
many1(fun () -> satisfy(function
| '(' | ')'
| '[' | ']'
| '{' | '}'
-> false
| _ -> true
| '.' | ',' | ':' | ';' | '=' | '@' | '#' | '&' | '`' | '?' | '!'
-> true
| _ -> false
)) >>| fun chars ->
NodeHolder(pos, string_of_chars chars)
)
Expand Down
7 changes: 7 additions & 0 deletions tests/swift_parser/valid/annotation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: %neal-swift

final class Foo {
@available(*, unavailable, message: "Unavailable, use baz()")
func bar() {
}
}