Created
June 13, 2019 14:27
-
-
Save joseoliv/c2b40c871d9423a809d47731275694bb to your computer and use it in GitHub Desktop.
grammarMethod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package metaobjectTest | |
@doc{* | |
Annotation 'grammarMethod' takes an attached DSL that is a regular | |
expression with the regular operators (+, *, ?, |) and message | |
keywords like 'name:', 'at:', and 'with:'. This is huge metaobject. | |
Read more about in the text "The Cyan Language Metaobject Protocol". | |
*} | |
object GrammarMethod | |
func run { | |
GrammarMethod name: "Kandinsky" | |
at: "Garden" | |
with: "Matisse" | |
name: "Frida" | |
with: "Picasso" | |
with: "Mondrian" | |
name: "Leonardo"; | |
} | |
@grammarMethod{* | |
(name: String (at: String)? (with: String)* )+ | |
*} | |
func meet: Array<Tuple<String, | |
Union<some, String, none, Any>, Array<String>>> p { | |
for t in p { | |
Out print: "name is " ++ t f1; | |
type t f2 | |
case String some { | |
Out print: " place is " ++ some | |
} | |
case Any none { | |
} | |
for name in t f3 { | |
Out print: " with " ++ name | |
} | |
"" println; | |
} | |
} | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment