Skip to content

Instantly share code, notes, and snippets.

@0xF6
Created January 23, 2021 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xF6/1861b394baab731ab80cff1e87ba7450 to your computer and use it in GitHub Desktop.
Save 0xF6/1861b394baab731ab80cff1e87ba7450 to your computer and use it in GitHub Desktop.
rex for method declaration
(?x)
(?<return-type>
(?<type-name>
(?:
(?:ref\s+(?:readonly\s+)?)?
(?:
(?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\s*\:\:\s*)?
(?<name-and-type-args>
\g<identifier>\s*
(?<type-args>\s*<(?:[^<>]|\g<type-args>)+>\s*)?
)
(?:\s*\.\s*\g<name-and-type-args>)* |
(?<tuple>\s*\((?:[^\(\)]|\g<tuple>)+\))
)
(?:\s*\?\s*)?
(?:\s*\[(?:\s*,\s*)*\]\s*)*
)
)\s+
)
(?<interface-name>\g<type-name>\s*\.\s*)?
(\g<identifier>)\s*
(<([^<>]+)>)?\s*
(?=\()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment