aboutsummaryrefslogtreecommitdiffstats
path: root/c_parser
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-02-19 14:40:15 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-02-19 14:40:15 +0000
commit563fc043d2ed88cc72b825e3916287f8a67545c2 (patch)
tree66b9dc80272558a25906255bea46641da10fa4b8 /c_parser
parent1802437f63e14c1128918c4e3a00f60fb97182d9 (diff)
downloadCompiler-563fc043d2ed88cc72b825e3916287f8a67545c2.tar.gz
Compiler-563fc043d2ed88cc72b825e3916287f8a67545c2.zip
Finished declarations completetly apart from curlies
Diffstat (limited to 'c_parser')
-rw-r--r--c_parser/src/c_parser.y2
-rw-r--r--c_parser/test/in/10.c18
-rw-r--r--c_parser/test/in/11.c10
-rw-r--r--c_parser/test/in/12.c4
-rw-r--r--c_parser/test/out/01.pretty.xml9
-rw-r--r--c_parser/test/out/02.pretty.xml6
-rw-r--r--c_parser/test/out/03.pretty.xml7
-rw-r--r--c_parser/test/out/04.pretty.xml12
-rw-r--r--c_parser/test/out/05.pretty.xml10
-rw-r--r--c_parser/test/out/06.pretty.xml14
-rw-r--r--c_parser/test/out/07.pretty.xml11
-rw-r--r--c_parser/test/out/08.pretty.xml16
-rw-r--r--c_parser/test/out/09.pretty.xml20
-rw-r--r--c_parser/test/out/10.diff.txt0
-rw-r--r--c_parser/test/out/10.pretty.xml19
-rw-r--r--c_parser/test/out/10.stderr.txt0
-rw-r--r--c_parser/test/out/10.stdout.xml20
-rw-r--r--c_parser/test/out/11.diff.txt0
-rw-r--r--c_parser/test/out/11.pretty.xml11
-rw-r--r--c_parser/test/out/11.stderr.txt0
-rw-r--r--c_parser/test/out/11.stdout.xml11
-rw-r--r--c_parser/test/out/12.diff.txt0
-rw-r--r--c_parser/test/out/12.pretty.xml10
-rw-r--r--c_parser/test/out/12.stderr.txt0
-rw-r--r--c_parser/test/out/12.stdout.xml10
-rw-r--r--c_parser/test/ref/01.stdout.xml12
-rw-r--r--c_parser/test/ref/02.stdout.xml8
-rw-r--r--c_parser/test/ref/03.stdout.xml10
-rw-r--r--c_parser/test/ref/04.stdout.xml18
-rw-r--r--c_parser/test/ref/05.stdout.xml16
-rw-r--r--c_parser/test/ref/06.stdout.xml22
-rw-r--r--c_parser/test/ref/07.stdout.xml16
-rw-r--r--c_parser/test/ref/08.stdout.xml26
-rw-r--r--c_parser/test/ref/09.stdout.xml36
-rw-r--r--c_parser/test/ref/10.stdout.xml20
-rw-r--r--c_parser/test/ref/11.stdout.xml11
-rw-r--r--c_parser/test/ref/12.stdout.xml10
37 files changed, 342 insertions, 83 deletions
diff --git a/c_parser/src/c_parser.y b/c_parser/src/c_parser.y
index 6dabbe7..b9b2f31 100644
--- a/c_parser/src/c_parser.y
+++ b/c_parser/src/c_parser.y
@@ -109,7 +109,7 @@ DECLARATOR:
;
INITIALIZER:
- T_INT_CONST { ; }
+ ASSIGNMENT_EXPRESSION { ; }
;
// STATEMENT
diff --git a/c_parser/test/in/10.c b/c_parser/test/in/10.c
new file mode 100644
index 0000000..3d4bb3c
--- /dev/null
+++ b/c_parser/test/in/10.c
@@ -0,0 +1,18 @@
+int f()
+{}
+
+int g = 2;
+
+int x(int y) {
+ int z = 3;
+
+ if(y < z || g < z) {
+ int r;
+ ++y;
+ } else if(y == z) {
+ int f;
+ --y;
+ } else return y;
+
+ return g;
+}
diff --git a/c_parser/test/in/11.c b/c_parser/test/in/11.c
new file mode 100644
index 0000000..7b6c0b5
--- /dev/null
+++ b/c_parser/test/in/11.c
@@ -0,0 +1,10 @@
+int f() {
+ int x = 0;
+
+ while(x < 5) {
+ int y = 0;
+ x++;
+ }
+
+ return x;
+}
diff --git a/c_parser/test/in/12.c b/c_parser/test/in/12.c
new file mode 100644
index 0000000..bc51045
--- /dev/null
+++ b/c_parser/test/in/12.c
@@ -0,0 +1,4 @@
+int f(int b, int c) {
+ int a = b+c;
+ return a;
+}
diff --git a/c_parser/test/out/01.pretty.xml b/c_parser/test/out/01.pretty.xml
new file mode 100644
index 0000000..e0545e4
--- /dev/null
+++ b/c_parser/test/out/01.pretty.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<Program>
+ <Variable id="a" />
+ <Variable id="b" />
+ <Variable id="c" />
+ <Variable id="d" />
+ <Variable id="e" />
+ <Variable id="f" />
+</Program>
diff --git a/c_parser/test/out/02.pretty.xml b/c_parser/test/out/02.pretty.xml
new file mode 100644
index 0000000..1f73bca
--- /dev/null
+++ b/c_parser/test/out/02.pretty.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="f">
+ <Scope></Scope>
+ </Function>
+</Program>
diff --git a/c_parser/test/out/03.pretty.xml b/c_parser/test/out/03.pretty.xml
new file mode 100644
index 0000000..6ab6ab3
--- /dev/null
+++ b/c_parser/test/out/03.pretty.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="foo">
+ <Parameter id="bar" />
+ <Scope></Scope>
+ </Function>
+</Program>
diff --git a/c_parser/test/out/04.pretty.xml b/c_parser/test/out/04.pretty.xml
new file mode 100644
index 0000000..caae53b
--- /dev/null
+++ b/c_parser/test/out/04.pretty.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="foo">
+ <Parameter id="bar1" />
+ <Parameter id="bar2" />
+ <Scope>
+ <Variable id="x" />
+ <Variable id="y" />
+ <Variable id="z" />
+ </Scope>
+ </Function>
+</Program>
diff --git a/c_parser/test/out/05.pretty.xml b/c_parser/test/out/05.pretty.xml
new file mode 100644
index 0000000..944d950
--- /dev/null
+++ b/c_parser/test/out/05.pretty.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="foo">
+ <Parameter id="x" />
+ <Parameter id="y" />
+ <Scope>
+ <Scope></Scope>
+ </Scope>
+ </Function>
+</Program>
diff --git a/c_parser/test/out/06.pretty.xml b/c_parser/test/out/06.pretty.xml
new file mode 100644
index 0000000..6422001
--- /dev/null
+++ b/c_parser/test/out/06.pretty.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="f">
+ <Parameter id="a" />
+ <Parameter id="b" />
+ <Parameter id="c" />
+ <Scope>
+ <Variable id="d" />
+ <Scope>
+ <Variable id="e" />
+ </Scope>
+ </Scope>
+ </Function>
+</Program>
diff --git a/c_parser/test/out/07.pretty.xml b/c_parser/test/out/07.pretty.xml
new file mode 100644
index 0000000..11c3b77
--- /dev/null
+++ b/c_parser/test/out/07.pretty.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="foo">
+ <Parameter id="a" />
+ <Scope>
+ <Scope>
+ <Variable id="z" />
+ </Scope>
+ </Scope>
+ </Function>
+</Program>
diff --git a/c_parser/test/out/08.pretty.xml b/c_parser/test/out/08.pretty.xml
new file mode 100644
index 0000000..6cf0f8e
--- /dev/null
+++ b/c_parser/test/out/08.pretty.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="func">
+ <Parameter id="a" />
+ <Parameter id="b" />
+ <Scope>
+ <Variable id="c" />
+ <Scope>
+ <Variable id="d" />
+ </Scope>
+ <Scope>
+ <Variable id="e" />
+ </Scope>
+ </Scope>
+ </Function>
+</Program>
diff --git a/c_parser/test/out/09.pretty.xml b/c_parser/test/out/09.pretty.xml
new file mode 100644
index 0000000..6c137df
--- /dev/null
+++ b/c_parser/test/out/09.pretty.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="x">
+ <Scope></Scope>
+ </Function>
+ <Variable id="g" />
+ <Function id="zz">
+ <Parameter id="a" />
+ <Parameter id="b" />
+ <Parameter id="c" />
+ <Scope>
+ <Scope>
+ <Variable id="a" />
+ </Scope>
+ <Scope>
+ <Variable id="fsdfsdfs" />
+ </Scope>
+ </Scope>
+ </Function>
+</Program>
diff --git a/c_parser/test/out/10.diff.txt b/c_parser/test/out/10.diff.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/c_parser/test/out/10.diff.txt
diff --git a/c_parser/test/out/10.pretty.xml b/c_parser/test/out/10.pretty.xml
new file mode 100644
index 0000000..89a6292
--- /dev/null
+++ b/c_parser/test/out/10.pretty.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="f">
+ <Scope></Scope>
+ </Function>
+ <Variable id="g" />
+ <Function id="x">
+ <Parameter id="y" />
+ <Scope>
+ <Variable id="z" />
+ <Scope>
+ <Variable id="r" />
+ </Scope>
+ <Scope>
+ <Variable id="f" />
+ </Scope>
+ </Scope>
+ </Function>
+</Program>
diff --git a/c_parser/test/out/10.stderr.txt b/c_parser/test/out/10.stderr.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/c_parser/test/out/10.stderr.txt
diff --git a/c_parser/test/out/10.stdout.xml b/c_parser/test/out/10.stdout.xml
new file mode 100644
index 0000000..b07997e
--- /dev/null
+++ b/c_parser/test/out/10.stdout.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<Program>
+<Function id="f">
+<Scope>
+</Scope>
+</Function>
+<Variable id="g" />
+<Function id="x">
+<Parameter id="y" />
+<Scope>
+<Variable id="z" />
+<Scope>
+<Variable id="r" />
+</Scope>
+<Scope>
+<Variable id="f" />
+</Scope>
+</Scope>
+</Function>
+</Program>
diff --git a/c_parser/test/out/11.diff.txt b/c_parser/test/out/11.diff.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/c_parser/test/out/11.diff.txt
diff --git a/c_parser/test/out/11.pretty.xml b/c_parser/test/out/11.pretty.xml
new file mode 100644
index 0000000..b9779d7
--- /dev/null
+++ b/c_parser/test/out/11.pretty.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="f">
+ <Scope>
+ <Variable id="x" />
+ <Scope>
+ <Variable id="y" />
+ </Scope>
+ </Scope>
+ </Function>
+</Program>
diff --git a/c_parser/test/out/11.stderr.txt b/c_parser/test/out/11.stderr.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/c_parser/test/out/11.stderr.txt
diff --git a/c_parser/test/out/11.stdout.xml b/c_parser/test/out/11.stdout.xml
new file mode 100644
index 0000000..0822742
--- /dev/null
+++ b/c_parser/test/out/11.stdout.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<Program>
+<Function id="f">
+<Scope>
+<Variable id="x" />
+<Scope>
+<Variable id="y" />
+</Scope>
+</Scope>
+</Function>
+</Program>
diff --git a/c_parser/test/out/12.diff.txt b/c_parser/test/out/12.diff.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/c_parser/test/out/12.diff.txt
diff --git a/c_parser/test/out/12.pretty.xml b/c_parser/test/out/12.pretty.xml
new file mode 100644
index 0000000..9f49265
--- /dev/null
+++ b/c_parser/test/out/12.pretty.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="f">
+ <Parameter id="b" />
+ <Parameter id="c" />
+ <Scope>
+ <Variable id="a" />
+ </Scope>
+ </Function>
+</Program>
diff --git a/c_parser/test/out/12.stderr.txt b/c_parser/test/out/12.stderr.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/c_parser/test/out/12.stderr.txt
diff --git a/c_parser/test/out/12.stdout.xml b/c_parser/test/out/12.stdout.xml
new file mode 100644
index 0000000..471f225
--- /dev/null
+++ b/c_parser/test/out/12.stdout.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<Program>
+<Function id="f">
+<Parameter id="b" />
+<Parameter id="c" />
+<Scope>
+<Variable id="a" />
+</Scope>
+</Function>
+</Program>
diff --git a/c_parser/test/ref/01.stdout.xml b/c_parser/test/ref/01.stdout.xml
index bd7cd1f..e0545e4 100644
--- a/c_parser/test/ref/01.stdout.xml
+++ b/c_parser/test/ref/01.stdout.xml
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<Program>
-<Variable id="a" />
-<Variable id="b" />
-<Variable id="c" />
-<Variable id="d" />
-<Variable id="e" />
-<Variable id="f" />
+ <Variable id="a" />
+ <Variable id="b" />
+ <Variable id="c" />
+ <Variable id="d" />
+ <Variable id="e" />
+ <Variable id="f" />
</Program>
diff --git a/c_parser/test/ref/02.stdout.xml b/c_parser/test/ref/02.stdout.xml
index bc37d7a..6caf2fc 100644
--- a/c_parser/test/ref/02.stdout.xml
+++ b/c_parser/test/ref/02.stdout.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<Program>
-<Function id="f">
-<Scope>
-</Scope>
-</Function>
+ <Function id="f">
+ <Scope>
+ </Scope>
+ </Function>
</Program>
diff --git a/c_parser/test/ref/03.stdout.xml b/c_parser/test/ref/03.stdout.xml
index 6ca0ab2..2c29a50 100644
--- a/c_parser/test/ref/03.stdout.xml
+++ b/c_parser/test/ref/03.stdout.xml
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<Program>
-<Function id="foo">
-<Parameter id="bar" />
-<Scope>
-</Scope>
-</Function>
+ <Function id="foo">
+ <Parameter id="bar" />
+ <Scope>
+ </Scope>
+ </Function>
</Program>
diff --git a/c_parser/test/ref/04.stdout.xml b/c_parser/test/ref/04.stdout.xml
index 9257eac..caae53b 100644
--- a/c_parser/test/ref/04.stdout.xml
+++ b/c_parser/test/ref/04.stdout.xml
@@ -1,12 +1,12 @@
<?xml version="1.0"?>
<Program>
-<Function id="foo">
-<Parameter id="bar1" />
-<Parameter id="bar2" />
-<Scope>
-<Variable id="x" />
-<Variable id="y" />
-<Variable id="z" />
-</Scope>
-</Function>
+ <Function id="foo">
+ <Parameter id="bar1" />
+ <Parameter id="bar2" />
+ <Scope>
+ <Variable id="x" />
+ <Variable id="y" />
+ <Variable id="z" />
+ </Scope>
+ </Function>
</Program>
diff --git a/c_parser/test/ref/05.stdout.xml b/c_parser/test/ref/05.stdout.xml
index 7381e51..f4b306f 100644
--- a/c_parser/test/ref/05.stdout.xml
+++ b/c_parser/test/ref/05.stdout.xml
@@ -1,11 +1,11 @@
<?xml version="1.0"?>
<Program>
-<Function id="foo">
-<Parameter id="x" />
-<Parameter id="y" />
-<Scope>
-<Scope>
-</Scope>
-</Scope>
-</Function>
+ <Function id="foo">
+ <Parameter id="x" />
+ <Parameter id="y" />
+ <Scope>
+ <Scope>
+ </Scope>
+ </Scope>
+ </Function>
</Program>
diff --git a/c_parser/test/ref/06.stdout.xml b/c_parser/test/ref/06.stdout.xml
index fbcbebd..3526139 100644
--- a/c_parser/test/ref/06.stdout.xml
+++ b/c_parser/test/ref/06.stdout.xml
@@ -1,14 +1,14 @@
<?xml version="1.0"?>
<Program>
-<Function id="f">
-<Parameter id="a" />
-<Parameter id="b" />
-<Parameter id="c" />
-<Scope>
-<Variable id="d" />
-<Scope>
-<Variable id="e" />
-</Scope>
-</Scope>
-</Function>
+ <Function id="f">
+ <Parameter id="a" />
+ <Parameter id="b" />
+ <Parameter id="c" />
+ <Scope>
+ <Variable id="d" />
+ <Scope>
+ <Variable id="e" />
+ </Scope>
+ </Scope>
+ </Function>
</Program>
diff --git a/c_parser/test/ref/07.stdout.xml b/c_parser/test/ref/07.stdout.xml
index ff0efb2..17c7c1b 100644
--- a/c_parser/test/ref/07.stdout.xml
+++ b/c_parser/test/ref/07.stdout.xml
@@ -1,11 +1,11 @@
<?xml version="1.0"?>
<Program>
-<Function id="foo">
-<Parameter id="a" />
-<Scope>
-<Scope>
-<Variable id="z" />
-</Scope>
-</Scope>
-</Function>
+ <Function id="foo">
+ <Parameter id="a" />
+ <Scope>
+ <Scope>
+ <Variable id="z" />
+ </Scope>
+ </Scope>
+ </Function>
</Program>
diff --git a/c_parser/test/ref/08.stdout.xml b/c_parser/test/ref/08.stdout.xml
index 7929e75..0838fe5 100644
--- a/c_parser/test/ref/08.stdout.xml
+++ b/c_parser/test/ref/08.stdout.xml
@@ -1,16 +1,16 @@
<?xml version="1.0"?>
<Program>
-<Function id="func">
-<Parameter id="a" />
-<Parameter id="b" />
-<Scope>
-<Variable id="c" />
-<Scope>
-<Variable id="d" />
-</Scope>
-<Scope>
-<Variable id="e" />
-</Scope>
-</Scope>
-</Function>
+ <Function id="func">
+ <Parameter id="a" />
+ <Parameter id="b" />
+ <Scope>
+ <Variable id="c" />
+ <Scope>
+ <Variable id="d" />
+ </Scope>
+ <Scope>
+ <Variable id="e" />
+ </Scope>
+ </Scope>
+ </Function>
</Program>
diff --git a/c_parser/test/ref/09.stdout.xml b/c_parser/test/ref/09.stdout.xml
index 7a7a770..646cd98 100644
--- a/c_parser/test/ref/09.stdout.xml
+++ b/c_parser/test/ref/09.stdout.xml
@@ -1,21 +1,21 @@
<?xml version="1.0"?>
<Program>
-<Function id="x">
-<Scope>
-</Scope>
-</Function>
-<Variable id="g" />
-<Function id="zz">
-<Parameter id="a" />
-<Parameter id="b" />
-<Parameter id="c" />
-<Scope>
-<Scope>
-<Variable id="a" />
-</Scope>
-<Scope>
-<Variable id="fsdfsdfs" />
-</Scope>
-</Scope>
-</Function>
+ <Function id="x">
+ <Scope>
+ </Scope>
+ </Function>
+ <Variable id="g" />
+ <Function id="zz">
+ <Parameter id="a" />
+ <Parameter id="b" />
+ <Parameter id="c" />
+ <Scope>
+ <Scope>
+ <Variable id="a" />
+ </Scope>
+ <Scope>
+ <Variable id="fsdfsdfs" />
+ </Scope>
+ </Scope>
+ </Function>
</Program>
diff --git a/c_parser/test/ref/10.stdout.xml b/c_parser/test/ref/10.stdout.xml
new file mode 100644
index 0000000..21cadeb
--- /dev/null
+++ b/c_parser/test/ref/10.stdout.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="f">
+ <Scope>
+ </Scope>
+ </Function>
+ <Variable id="g" />
+ <Function id="x">
+ <Parameter id="y" />
+ <Scope>
+ <Variable id="z" />
+ <Scope>
+ <Variable id="r" />
+ </Scope>
+ <Scope>
+ <Variable id="f" />
+ </Scope>
+ </Scope>
+ </Function>
+</Program>
diff --git a/c_parser/test/ref/11.stdout.xml b/c_parser/test/ref/11.stdout.xml
new file mode 100644
index 0000000..ad96d6c
--- /dev/null
+++ b/c_parser/test/ref/11.stdout.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="f">
+ <Scope>
+ <Variable id="x" />
+ <Scope>
+ <Variable id="y" />
+ </Scope>
+ </Scope>
+ </Function>
+</Program>
diff --git a/c_parser/test/ref/12.stdout.xml b/c_parser/test/ref/12.stdout.xml
new file mode 100644
index 0000000..9f49265
--- /dev/null
+++ b/c_parser/test/ref/12.stdout.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<Program>
+ <Function id="f">
+ <Parameter id="b" />
+ <Parameter id="c" />
+ <Scope>
+ <Variable id="a" />
+ </Scope>
+ </Function>
+</Program>