Dies ist eine gemeinschaftliche Sammlung von Testfaellen fuer die Uebungsbeispiele
der LVA "Uebersetzerbau (SS10)".
-Kurzes HOWTO:
+Kurzes HOWTO (fuer die g0):
$ git clone git://github.com/lewurm/testub10.git ~/test
Danach koennen die Testfaelle durch diesen Befehl aktualisiert werden:
erwartete Ausgabe fuer die Datei bar.0 nennen Sie bar.out.
Namenskonventionen fuer uns:
-Jeder Testfall wird hat als Praefix "<nick>_", sodass keine Namenskonflikte enstehen.
+Jeder Testfall hat als Praefix "<nick>_", sodass keine Namenskonflikte entstehen.
Wie kannst du beitragen?
--- /dev/null
+method f(a b c)
+ /* x nicht deklariert */
+ if a < x then
+ c := 0x1;
+ end;
+end;
--- /dev/null
+method f(a b c)
+ if a < b then
+ var x := 0;
+ c := 1;
+ end;
+ /* x ist nicht im scope */
+ x := x - 1;
+end;
--- /dev/null
+method f(a b c)
+ /* x ist (noch) nicht im scope */
+ var x := x - 1;
+end;
--- /dev/null
+struct a end;
+method f(c s)
+ /* lesender feldzugriff */
+ var b := c*(s.a - 1);
+end;
--- /dev/null
+struct a d end;
+method f(b c s)
+ var t := 0;
+ /* lesender feldzugriff */
+ b := c*(s.a - 1);
+ b := c*(s.d - 1);
+ b := c*(t.a - 1);
+ b := c*(t.d - 1);
+end;
--- /dev/null
+struct a c d end;
+method f(b c s)
+ var t := 0;
+ /* lesender feldzugriff */
+ b := c*(s.a - 1);
+ b := c*(s.d - 1);
+ b := c*(t.a - 1);
+ /* auch gueltig, da structs und vars unterschiedlichen scope haben */
+ b := c*(t.c - 1);
+end;
--- /dev/null
+method f(b)
+ var t := 0;
+ /* identifier doppelt vorhanden */
+ var b := 0;
+end;
--- /dev/null
+method f (a b)
+ a := b - 1;
+end;
+
+method g (a)
+ a := a - 1;
+end;
+
+method main ()
+ var x := 0;
+ /* vgl.:
+ * [Term ’.’] ident ’(’ { Expr ’,’ } [ Expr ] ’)’ /* Methodenaufruf */
+ f (x,x,);
+ g (x,);
+ g (x);
+end;
--- /dev/null
+struct x y end;
+method f()
+ /* erlaubt, da 'x' als 'this.x' zu lesen ist */
+ var n := x;
+ return n;
+end;
--- /dev/null
+struct
+ x y z
+end;
+
+method f(a b c)
+ /* sollte funktionieren (zugriff auf this.x) */
+ var n := x;
+ return n;
+end;
+
--- /dev/null
+struct mystruct
+ field1
+ field2
+ field3
+end;
+method doit()
+ var a := 10000;
+ var b := 0x42;
+
+ return a - (b * 100);
+end;
+
+method tester(arg)
+ doit();
+end;
--- /dev/null
+method with_args2(arg1 arg2)
+ var a := 0;
+ doit();
+ another_stmt();
+ a;
+ something();
+ something_other(arg1,);
+end;
--- /dev/null
+struct mystruct
+end
--- /dev/null
+/*
+ Hi,
+ this is a very long comment with some keywords which should be eaten
+ struct struct
+ struct
+*/
--- /dev/null
+method testit()
+ var b := 10 - d * 20; /* should raise an error, since '(' ')' are missing */
+end;
--- /dev/null
+struct person
+ first_name
+ last_name
+end;
+
+method doit(person)
+ person.print_names(person.first_name, person.last_name,);
+end;
+
+method print_names(arg1 arg2)
+ if arg1 = arg2 then
+ this.print(arg1);
+ return 1;
+ end;
+ this.print(arg1);
+ this.print(arg2);
+ var a := 0;
+ a := (1 - 0x3).to_f();
+
+ if 1 then
+ print(a);
+ else
+ print(0); /* never reached */
+ end;
+end;
--- /dev/null
+struct
+ dots per line should be allowed some other
+end;
+
+method doit(a b)
+ while a < b do
+ var something := 0x42;
+ var many := 0x42;
+ var and := 0x42;
+ while a = b do
+ the_end();
+ end;
+ if something then
+ doit();
+ else if not something then end;
+ end;
+
+ many.dots.per.line.should.be.allowed := and.some.other.dots;
+
+ end;
+end;
--- /dev/null
+method abc(arg1 arg2)
+ if arg1 = arg2 then
+ var a := 42;
+ end;
+
+ var b := a - -1;
+end;
--- /dev/null
+method test_nested_ifs(arg1 arg2)
+ if arg1 = arg2 then
+ var a := 1;
+ end;
+
+ if not (arg1 = arg2) then
+ var a := 2;
+ var b := a - -1;
+ end;
+end;
--- /dev/null
+method abc(arg1 arg2)
+ if arg1 = arg2 then
+ var a := 42;
+ end;
+
+ var a := 3;
+ var b := a - -1;
+end;
+
--- /dev/null
+struct a b c end;
+method test(arg1 arg2)
+ arg1.a := 10;
+end;
+
+struct c d e end;
--- /dev/null
+method abc(arg1 arg2)
+ var arg2 := 10; /* detect duplicates and fail */
+end;
+++ /dev/null
-method TForm1.FindString()
-var hFile;
-
-struct
- pIniData;
- pData;
-end;
-
- /* Initalize Data */
- hMapping := _INVALID_HANDLE_VALUE;
- pIniData := 0x13;
-
- result := 1;
-
-
- /* Search File in Workspace... */
- filename := abc;
- if FileExists(aSearchFile) then
- filename := aSearchFile;
- else
- return;
- end;
-
- /* CreateFileHandle... */
- this.hFile := 10 * pIniData;
-
-
-
- if hFile < INVALID_HANDLE_VALUE then
- return 0x2345;
-
- if hFile = INVALID_HANDLE_VALUE then
- return 23456;
-
-
- while not result or pIniData = 0x12 do
-
- pIniData := pIniData - 1;
- end;
-end;
\ No newline at end of file
--- /dev/null
+method TForm1.FindString()
+var hFile;
+
+struct
+ pIniData;
+ pData;
+end;
+
+ /* Initalize Data */
+ hMapping := _INVALID_HANDLE_VALUE;
+ pIniData := 0x13;
+
+ result := 1;
+
+
+ /* Search File in Workspace... */
+ filename := abc;
+ if FileExists(aSearchFile) then
+ filename := aSearchFile;
+ else
+ return;
+ end;
+
+ /* CreateFileHandle... */
+ this.hFile := 10 * pIniData;
+
+
+
+ if hFile < INVALID_HANDLE_VALUE then
+ return 0x2345;
+
+ if hFile = INVALID_HANDLE_VALUE then
+ return 23456;
+
+
+ while not result or pIniData = 0x12 do
+
+ pIniData := pIniData - 1;
+ end;
+end;
\ No newline at end of file
--- /dev/null
+/* oneliner :) */
+struct x end; method f (a b c d e) if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then d := c - 0x1 - x.u; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end;
--- /dev/null
+/* oneliner :) */
+struct x end; method f (a b c d e) if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then d := c - 0x1 - x.u; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end;
--- /dev/null
+/* oneliner :) */
+struct x end; method f (a b c d e) if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then if (a<b) then while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do while (a=c) do d := c - 0x1 - x.u; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end; end;
--- /dev/null
+method f (a b)
+ a := b - 1;
+end;
+
+method g (a)
+ a := a - 1;
+end;
+
+method main ()
+ var x := 0;
+ /* vgl.:
+ * [Term ’.’] ident ’(’ { Expr ’,’ } [ Expr ] ’)’ /* Methodenaufruf */
+ f (x,x,);
+ g (x,);
+ g (x);
+end;
--- /dev/null
+/* comment
+**
+//*
+/* /* end of comment
+***/
+
+/* another comment */ /* and another one */
+++ /dev/null
-method TForm1.FindString()
-var hFile;
-
-struct
- pIniData;
- pData;
-end;
-
- /* Initalize Data */
- hMapping := _INVALID_HANDLE_VALUE;
- pIniData := 0x13;
-
- result := 1;
-
-
- /* Search File in Workspace... */
- filename := abc;
- if FileExists(aSearchFile) then
- filename := aSearchFile;
- else
- return;
- end;
-
- /* CreateFileHandle... */
- this.hFile := 10 * pIniData;
-
-
-
- if hFile < INVALID_HANDLE_VALUE then
- return 0x2345;
-
- if hFile = INVALID_HANDLE_VALUE then
- return 23456;
-
-
- while not result or pIniData = 0x12 do
-
- pIniData := pIniData - 1;
- end;
-end;
\ No newline at end of file
+++ /dev/null
-method
-ident TForm1
-.
-ident FindString
-(
-)
-var
-ident hFile
-;
-struct
-ident pIniData
-;
-ident pData
-;
-end
-;
-ident hMapping
-:=
-ident _INVALID_HANDLE_VALUE
-;
-ident pIniData
-:=
-num 13
-;
-ident result
-:=
-num 1
-;
-ident filename
-:=
-ident abc
-;
-if
-ident FileExists
-(
-ident aSearchFile
-)
-then
-ident filename
-:=
-ident aSearchFile
-;
-else
-return
-;
-end
-;
-this
-.
-ident hFile
-:=
-num a
-*
-ident pIniData
-;
-if
-ident hFile
-<
-ident INVALID_HANDLE_VALUE
-then
-return
-num 2345
-;
-if
-ident hFile
-=
-ident INVALID_HANDLE_VALUE
-then
-return
-num 5ba0
-;
-while
-not
-ident result
-or
-ident pIniData
-=
-num 12
-do
-ident pIniData
-:=
-ident pIniData
--
-num 1
-;
-end
-;
-end
-;
\ No newline at end of file
--- /dev/null
+method TForm1.FindString()
+var hFile;
+
+struct
+ pIniData;
+ pData;
+end;
+
+ /* Initalize Data */
+ hMapping := _INVALID_HANDLE_VALUE;
+ pIniData := 0x13;
+
+ result := 1;
+
+
+ /* Search File in Workspace... */
+ filename := abc;
+ if FileExists(aSearchFile) then
+ filename := aSearchFile;
+ else
+ return;
+ end;
+
+ /* CreateFileHandle... */
+ this.hFile := 10 * pIniData;
+
+
+
+ if hFile < INVALID_HANDLE_VALUE then
+ return 0x2345;
+
+ if hFile = INVALID_HANDLE_VALUE then
+ return 23456;
+
+
+ while not result or pIniData = 0x12 do
+
+ pIniData := pIniData - 1;
+ end;
+end;
\ No newline at end of file
--- /dev/null
+method
+ident TForm1
+.
+ident FindString
+(
+)
+var
+ident hFile
+;
+struct
+ident pIniData
+;
+ident pData
+;
+end
+;
+ident hMapping
+:=
+ident _INVALID_HANDLE_VALUE
+;
+ident pIniData
+:=
+num 13
+;
+ident result
+:=
+num 1
+;
+ident filename
+:=
+ident abc
+;
+if
+ident FileExists
+(
+ident aSearchFile
+)
+then
+ident filename
+:=
+ident aSearchFile
+;
+else
+return
+;
+end
+;
+this
+.
+ident hFile
+:=
+num a
+*
+ident pIniData
+;
+if
+ident hFile
+<
+ident INVALID_HANDLE_VALUE
+then
+return
+num 2345
+;
+if
+ident hFile
+=
+ident INVALID_HANDLE_VALUE
+then
+return
+num 5ba0
+;
+while
+not
+ident result
+or
+ident pIniData
+=
+num 12
+do
+ident pIniData
+:=
+ident pIniData
+-
+num 1
+;
+end
+;
+end
+;
\ No newline at end of file
--- /dev/null
+method TForm1.FindString()
+var hFile;
+
+struct
+ pIniData;
+ pData;
+end;
+
+ /* Initalize Data */
+ hMapping := _INVALID_HANDLE_VALUE;
+ pIniData := 0x13;
+
+ result := 1;
+
+
+ /* Search File in Workspace... */
+ filename := abc;
+ if FileExists(aSearchFile) then
+ filename := aSearchFile;
+ else
+ return;
+ end;
+
+ /* CreateFileHandle... */
+ this.hFile := 10 % pIniData;
+
+
+
+ if hFile < INVALID_HANDLE_VALUE then
+ return 0x2345;
+
+ if hFile = INVALID_HANDLE_VALUE then
+ return 23456;
+
+
+ while not result or pIniData = 0x12 do
+
+ pIniData := pIniData + 1;
+ end;
+end;
\ No newline at end of file