Skip to content

Instantly share code, notes, and snippets.

@willmurphyscode
Created November 22, 2016 12:26
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 willmurphyscode/da2268ce07343d58e8820dd42e38060f to your computer and use it in GitHub Desktop.
Save willmurphyscode/da2268ce07343d58e8820dd42e38060f to your computer and use it in GitHub Desktop.
//from scientific_names.lalrpop
// parse the final noun of a scientific name.
// match it to one of the legal final nouns.
pub FinalNoun : FinalNoun = {
"kablooie" => FinalNoun::Kablooie,
"swoosh" => FinalNoun::Swoosh,
"frobber" => FinalNoun::Frobber,
"atomizer" => FinalNoun::Atomizer,
"event" => FinalNoun::Event,
"device" => FinalNoun::Device,
};
// this is a simple enumerated type
// it's basically a list of legal values
// it derives from std traits that allow it to be
// copied around and compared.
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum FinalNoun {
Kablooie,
Swoosh,
Frobber,
Atomizer,
Event,
Device
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment