forked from MightyPork/crsn
Introduce the 'true' and 'false' conditions
This commit is contained in:
@@ -106,6 +106,10 @@ pub enum Cond {
|
||||
Eof,
|
||||
/// Not empty
|
||||
NotEof,
|
||||
// Always true, for eg. (else? ...)
|
||||
True,
|
||||
/// Always false
|
||||
False,
|
||||
}
|
||||
|
||||
pub fn parse_cond(text: &str, pos: &SourcePosition) -> Result<Cond, CrsnError> {
|
||||
@@ -134,6 +138,8 @@ pub fn parse_cond(text: &str, pos: &SourcePosition) -> Result<Cond, CrsnError> {
|
||||
"neof" => Cond::NotEof,
|
||||
"ov" => Cond::Overflow,
|
||||
"nov" => Cond::NotOverflow,
|
||||
"true" | "always" | "else" => Cond::True,
|
||||
"false" | "never" => Cond::False,
|
||||
_ => {
|
||||
return Err(CrsnError::Parse(format!("Unknown cond: {}", text).into(), pos.clone()));
|
||||
}
|
||||
@@ -174,6 +180,8 @@ impl Display for Cond {
|
||||
Cond::Valid => "valid",
|
||||
Cond::Eof => "eof",
|
||||
Cond::NotEof => "neof",
|
||||
Cond::True => "true",
|
||||
Cond::False => "false",
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -214,6 +222,9 @@ impl Not for Cond {
|
||||
|
||||
Cond::NotEof => Cond::Eof,
|
||||
Cond::Eof => Cond::NotEof,
|
||||
|
||||
Cond::True => Cond::False,
|
||||
Cond::False => Cond::True,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,8 @@ impl StatusFlags {
|
||||
Cond::NotEmpty => !self.empty,
|
||||
Cond::Eof => self.eof,
|
||||
Cond::NotEof => !self.eof,
|
||||
Cond::True => true,
|
||||
Cond::False => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user