Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.