able-script/src/parser.rs

18 lines
366 B
Rust
Raw Normal View History

2021-04-13 10:43:54 -05:00
use crate::tokens::Abool;
2021-04-11 15:11:23 -05:00
pub fn abool2num(abool: Abool) -> i32 {
2021-04-11 17:22:06 -05:00
match abool {
Abool::Never => -1,
Abool::Sometimes => 0,
Abool::Always => 1,
2021-04-11 17:22:06 -05:00
}
}
pub fn num2abool(number: i32) -> Abool {
2021-04-11 17:22:06 -05:00
match number {
-1 => Abool::Never,
0 => Abool::Sometimes,
1 => Abool::Always,
_ => Abool::Sometimes,
2021-04-11 15:11:23 -05:00
}
}