Skip to content

Instantly share code, notes, and snippets.

@joseoliv
Created June 13, 2019 14:27
Show Gist options
  • Save joseoliv/c2b40c871d9423a809d47731275694bb to your computer and use it in GitHub Desktop.
Save joseoliv/c2b40c871d9423a809d47731275694bb to your computer and use it in GitHub Desktop.
grammarMethod
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