disallow datatype redefining
This commit is contained in:
parent
393db5da62
commit
0b3d5b2e54
|
@ -28,6 +28,7 @@ pub enum Error {
|
|||
BadWrite(std::io::Error),
|
||||
NotDefined,
|
||||
ExpectedID,
|
||||
RedefData,
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
|
@ -37,6 +38,7 @@ impl fmt::Display for Error {
|
|||
Self::BadWrite(e) => write!(f, "{}", e),
|
||||
Self::NotDefined => write!(f, "undefined data type"),
|
||||
Self::ExpectedID => write!(f, "expected identifier"),
|
||||
Self::RedefData => write!(f, "redefining existing datatype"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +191,9 @@ impl Writer {
|
|||
if s == "data" {
|
||||
let lhs = lhs.clone();
|
||||
let data = self.parse_data_type(rhs);
|
||||
self.data.insert(lhs, data);
|
||||
self.data
|
||||
.insert(lhs, data)
|
||||
.map_or(Ok(()), |_| Err(Error::RedefData))?;
|
||||
} else {
|
||||
self.parse_id(rhs)?;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue