mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-14 22:38:46 +00:00
Update skeleton
This commit is contained in:
11
examples/array5.c
Normal file
11
examples/array5.c
Normal file
@@ -0,0 +1,11 @@
|
||||
int main() {
|
||||
int init = 1;
|
||||
int a[5] = {init, 2, 3, 4, -5};
|
||||
int sum = 0;
|
||||
|
||||
for(int i = 0; i < 5; i++) {
|
||||
sum += a[i];
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
@@ -88,11 +88,20 @@ impl IsEquiv for Initializer {
|
||||
fn is_equiv(&self, other: &Self) -> bool {
|
||||
match (self, other) {
|
||||
(Self::Expression(expr), Self::Expression(other_expr)) => expr.is_equiv(other_expr),
|
||||
(Self::List(items), Self::List(other_items)) => items.is_equiv(other_items),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IsEquiv for InitializerListItem {
|
||||
fn is_equiv(&self, other: &Self) -> bool {
|
||||
self.designation.is_empty()
|
||||
&& other.designation.is_empty()
|
||||
&& self.initializer.is_equiv(&other.initializer)
|
||||
}
|
||||
}
|
||||
|
||||
impl IsEquiv for Declarator {
|
||||
fn is_equiv(&self, other: &Self) -> bool {
|
||||
self.kind.is_equiv(&other.kind) && self.derived.is_equiv(&other.derived)
|
||||
|
||||
@@ -208,11 +208,18 @@ impl AssertSupported for Initializer {
|
||||
fn assert_supported(&self) {
|
||||
match self {
|
||||
Self::Expression(expr) => expr.assert_supported(),
|
||||
Self::List(_) => panic!("Initializer::List"),
|
||||
Self::List(items) => items.assert_supported(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AssertSupported for InitializerListItem {
|
||||
fn assert_supported(&self) {
|
||||
assert!(self.designation.is_empty());
|
||||
self.initializer.assert_supported();
|
||||
}
|
||||
}
|
||||
|
||||
impl AssertSupported for Declarator {
|
||||
fn assert_supported(&self) {
|
||||
self.kind.assert_supported();
|
||||
|
||||
@@ -611,10 +611,9 @@ impl TryFrom<&ast::Initializer> for Constant {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(initializer: &ast::Initializer) -> Result<Self, Self::Error> {
|
||||
if let ast::Initializer::Expression(expr) = &initializer {
|
||||
Self::try_from(&expr.node)
|
||||
} else {
|
||||
Err(())
|
||||
match initializer {
|
||||
ast::Initializer::Expression(expr) => Self::try_from(&expr.node),
|
||||
ast::Initializer::List(_) => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,9 @@ REPLACE_DICT = {
|
||||
# "typedef struct[^\n]*\n{[^}]*}[^;]*;": "",
|
||||
# "typedef struct[^{]{[^}]*}": "typedef int",
|
||||
# "struct _IO_FILE": "int",
|
||||
# "FILE *": "void *",
|
||||
# "typedef __fpos_t fpos_t;": "",
|
||||
# "fpos_t *": "void *",
|
||||
}
|
||||
CSMITH_DIR = "csmith-2.3.0"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user