Created
August 24, 2016 20:02
-
-
Save kierdavis/575c14947d8f408b58c4a2f1bbf780b6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
GateKind = enum | |
gateNot | |
gateAnd | |
gateOr | |
gateNand | |
gateNor | |
gateXor | |
proc raiseValue[T](e: ref Exception): T = | |
raise e | |
# leave result set to the zero value for T | |
let kind = | |
case kindStr | |
of "NOT": gateNot | |
of "AND": gateAnd | |
of "OR": gateOr | |
of "NAND": gateNand | |
of "NOR": gateNor | |
of "XOR": gateXor | |
else: | |
raiseValue[GateKind] newException(ParseError, "bad kindStr") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment