Skip to content

Instantly share code, notes, and snippets.

@huonw
Last active December 20, 2015 14:19
Show Gist options
  • Save huonw/6145412 to your computer and use it in GitHub Desktop.
Save huonw/6145412 to your computer and use it in GitHub Desktop.
match 'foo {
'foo => {
if some_thing {
match 'bar;
} else if other_thing {
match 'baz;
}
}
'bar => { blah(); match 'baz; }
'baz => { blahblah(); match 'foo; }
}
match 'foo {
'foo => {
match if some_thing {
'bar
} else if other_thing {
'baz
} else {
'end
}
}
'bar => { blah(); match 'baz; }
'baz => { blahblah(); match 'foo; }
'end => {}
}
enum Matcher { Foo, Bar(int), Baz(float) }
match xyz {
Foo => {
if some_thing {
match Bar(10);
} else if other_thing {
match Baz(10000.0);
}
}
Bar(n) => { blah(n); match Baz(1.2); }
Baz(f) => { blahblah(f); match Foo; }
}
@huonw
Copy link
Author

huonw commented Aug 6, 2013

A basic sketch of what this might look like when used for a yield state machine compiler. (Probably unworkable... it somehow has to handle the loop properly.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment