summaryrefslogtreecommitdiff
path: root/Homework/cs5300/p4-formatter/data
diff options
context:
space:
mode:
authorElizabeth Alexander Hunt <me@liz.coffee>2026-07-02 11:55:17 -0700
committerElizabeth Alexander Hunt <me@liz.coffee>2026-07-02 11:55:17 -0700
commit6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6 (patch)
treeed97e39ec77c5231ffd2c394493e68d00ddac5a4 /Homework/cs5300/p4-formatter/data
downloadmisc-undergrad-main.tar.gz
misc-undergrad-main.zip
Diffstat (limited to 'Homework/cs5300/p4-formatter/data')
-rw-r--r--Homework/cs5300/p4-formatter/data/test0.c29
-rw-r--r--Homework/cs5300/p4-formatter/data/test0.out40
-rw-r--r--Homework/cs5300/p4-formatter/data/test1.c65
-rw-r--r--Homework/cs5300/p4-formatter/data/test1.out82
4 files changed, 216 insertions, 0 deletions
diff --git a/Homework/cs5300/p4-formatter/data/test0.c b/Homework/cs5300/p4-formatter/data/test0.c
new file mode 100644
index 0000000..1198b0e
--- /dev/null
+++ b/Homework/cs5300/p4-formatter/data/test0.c
@@ -0,0 +1,29 @@
+int
+
+
+ a
+ , b;
+int c[ 3
+
+];
+
+int fie () {
+
+print(a);
+ }
+
+int foo(int a) {
+ print(a);
+}
+
+int add(int a[], int b) {
+ int c, z;
+ c -= 3;
+ if (c || b<3 || !!!(false) || b >12 +z < 14+3-2*1) {
+ c -= 3 + 8;
+ b--;
+ {}
+ z = (a[0] + c[2] - (b+a*3));
+ }
+}
+
diff --git a/Homework/cs5300/p4-formatter/data/test0.out b/Homework/cs5300/p4-formatter/data/test0.out
new file mode 100644
index 0000000..12b25f6
--- /dev/null
+++ b/Homework/cs5300/p4-formatter/data/test0.out
@@ -0,0 +1,40 @@
+Parsing data/test0.c
+
+
+
+Building abstract syntax tree
+
+Undefined symbol on line 12: print
+Undefined symbol on line 16: print
+
+Formatted code:
+
+int a, b;
+int c[3];
+
+int fie()
+{
+ print(a);
+}
+
+int foo(int a)
+{
+ print(a);
+}
+
+int add(int a[], int b)
+{
+ int c, z;
+ c -= 3;
+ if (c || b < 3 || !!!(false) || b > 12 + z < 14 + 3 - 2 * 1)
+ {
+ c -= 3 + 8;
+ b--;
+ {
+ }
+ z = (a[0] + c[2] - (b + a * 3));
+ }
+}
+
+
+Process finished with exit code 0
diff --git a/Homework/cs5300/p4-formatter/data/test1.c b/Homework/cs5300/p4-formatter/data/test1.c
new file mode 100644
index 0000000..bad6240
--- /dev/null
+++ b/Homework/cs5300/p4-formatter/data/test1.c
@@ -0,0 +1,65 @@
+int a, b;
+int c[3];
+
+int add(int a[], int b) {
+ int c, z;
+ c -= 3;
+ if (c || b<3) {
+ c -= 3;
+ } else
+ c *= 3;
+ while (b > 0) {
+ int d;
+ b = a;
+ }
+ b = a;
+ z = a;
+ return b;
+}
+
+void nothing(char c) {
+ // do nothing
+ add(1, 3);
+}
+
+int ant(int bat, int cat[], bool dog, bool elk, int fox)
+{
+ int gnu, hog[100];
+ gnu = hog[2] = 3**cat;
+ if (dog && elk || bat > cat[3]) dog = !dog;
+ else fox++;
+ if (bat <= fox) {
+ while (dog) {
+ int hog; // hog in new scope
+ hog = fox;
+ // undefined symbol error
+ dog = fred(fox++, cat)>666;
+ if (hog>bat) break;
+ else if (fox!=0) fox += 7;
+ }
+ }
+ return (fox+bat*cat[bat])/-fox;
+}
+
+int main() {
+ int a;
+ a = 0;
+ while (a
+ < 3
+) a++;
+
+
+ b = 3;
+ c *= (18 / (3-1)-3) ;
+ c ++;
+ // Should give an undefined symbol error
+ z++;
+ break ;
+
+ // Should give an underfined symbol error
+ fie();
+ return
+
+ 0;
+
+}
diff --git a/Homework/cs5300/p4-formatter/data/test1.out b/Homework/cs5300/p4-formatter/data/test1.out
new file mode 100644
index 0000000..1daaaea
--- /dev/null
+++ b/Homework/cs5300/p4-formatter/data/test1.out
@@ -0,0 +1,82 @@
+
+Parsing data/test1.c
+
+
+
+Building abstract syntax tree
+
+Undefined symbol on line 36: fred
+Undefined symbol on line 56: z
+Undefined symbol on line 60: fie
+
+Formatted code:
+
+int a, b;
+int c[3];
+
+int add(int a[], int b)
+{
+ int c, z;
+ c -= 3;
+ if (c || b < 3)
+ {
+ c -= 3;
+ }
+ else
+ c *= 3;
+ while (b > 0)
+ {
+ int d;
+ b = a;
+ }
+ b = a;
+ z = a;
+ return b;
+}
+
+void nothing(char c)
+{
+ add(1, 3);
+}
+
+int ant(int bat, int cat[], bool dog, bool elk, int fox)
+{
+ int gnu, hog[100];
+ gnu = hog[2] = 3 * *cat;
+ if (dog && elk || bat > cat[3])
+ dog = !dog;
+ else
+ fox++;
+ if (bat <= fox)
+ {
+ while (dog)
+ {
+ int hog;
+ hog = fox;
+ dog = fred(fox++, cat) > 666;
+ if (hog > bat)
+ break;
+ else
+ if (fox != 0)
+ fox += 7;
+ }
+ }
+ return (fox + bat * cat[bat]) / -fox;
+}
+
+int main()
+{
+ int a;
+ a = 0;
+ while (a < 3)
+ a++;
+ b = 3;
+ c *= (18 / (3 - 1) - 3);
+ c++;
+ z++;
+ break;
+ fie();
+ return 0;
+}
+
+