Created
November 22, 2016 12:26
-
-
Save willmurphyscode/da2268ce07343d58e8820dd42e38060f to your computer and use it in GitHub Desktop.
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
//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