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