From: Bernhard Urban Date: Wed, 31 Mar 2010 14:19:16 +0000 (+0200) Subject: Merge branch 'master' of git://github.com/skinner33/testub10 X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=testub10.git;a=commitdiff_plain;h=3bae9d34785b9d2eba710933e1dc7e1f7fa27211;hp=f2c982e1eb37561bc4c1e597cdc8d07b17cd7086 Merge branch 'master' of git://github.com/skinner33/testub10 --- diff --git a/README b/README index 7a61a50..b892894 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ 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: @@ -22,7 +22,7 @@ auf .0 enden) auch noch eine Ausgabe, die ueberprueft werden muss; die erwartete Ausgabe fuer die Datei bar.0 nennen Sie bar.out. Namenskonventionen fuer uns: -Jeder Testfall wird hat als Praefix "_", sodass keine Namenskonflikte enstehen. +Jeder Testfall hat als Praefix "_", sodass keine Namenskonflikte entstehen. Wie kannst du beitragen? diff --git a/ag/lewurm_00.3 b/ag/lewurm_00.3 new file mode 100644 index 0000000..25e8e2f --- /dev/null +++ b/ag/lewurm_00.3 @@ -0,0 +1,6 @@ +method f(a b c) + /* x nicht deklariert */ + if a < x then + c := 0x1; + end; +end; diff --git a/ag/lewurm_01.3 b/ag/lewurm_01.3 new file mode 100644 index 0000000..eda05e0 --- /dev/null +++ b/ag/lewurm_01.3 @@ -0,0 +1,8 @@ +method f(a b c) + if a < b then + var x := 0; + c := 1; + end; + /* x ist nicht im scope */ + x := x - 1; +end; diff --git a/ag/lewurm_02.3 b/ag/lewurm_02.3 new file mode 100644 index 0000000..c5fc09a --- /dev/null +++ b/ag/lewurm_02.3 @@ -0,0 +1,4 @@ +method f(a b c) + /* x ist (noch) nicht im scope */ + var x := x - 1; +end; diff --git a/ag/lewurm_03.0 b/ag/lewurm_03.0 new file mode 100644 index 0000000..ae12764 --- /dev/null +++ b/ag/lewurm_03.0 @@ -0,0 +1,5 @@ +struct a end; +method f(c s) + /* lesender feldzugriff */ + var b := c*(s.a - 1); +end; diff --git a/ag/lewurm_04.0 b/ag/lewurm_04.0 new file mode 100644 index 0000000..7bb46a6 --- /dev/null +++ b/ag/lewurm_04.0 @@ -0,0 +1,9 @@ +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; diff --git a/ag/lewurm_05.0 b/ag/lewurm_05.0 new file mode 100644 index 0000000..709f525 --- /dev/null +++ b/ag/lewurm_05.0 @@ -0,0 +1,10 @@ +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; diff --git a/ag/lewurm_06.3 b/ag/lewurm_06.3 new file mode 100644 index 0000000..2b44db2 --- /dev/null +++ b/ag/lewurm_06.3 @@ -0,0 +1,5 @@ +method f(b) + var t := 0; + /* identifier doppelt vorhanden */ + var b := 0; +end; diff --git a/ag/lewurm_07.0 b/ag/lewurm_07.0 new file mode 100644 index 0000000..b6c4511 --- /dev/null +++ b/ag/lewurm_07.0 @@ -0,0 +1,16 @@ +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; diff --git a/ag/lewurm_08.0 b/ag/lewurm_08.0 new file mode 100644 index 0000000..fc4bc42 --- /dev/null +++ b/ag/lewurm_08.0 @@ -0,0 +1,6 @@ +struct x y end; +method f() + /* erlaubt, da 'x' als 'this.x' zu lesen ist */ + var n := x; + return n; +end; diff --git a/ag/nax_00.0 b/ag/nax_00.0 new file mode 100644 index 0000000..62d4d11 --- /dev/null +++ b/ag/nax_00.0 @@ -0,0 +1,10 @@ +struct + x y z +end; + +method f(a b c) + /* sollte funktionieren (zugriff auf this.x) */ + var n := x; + return n; +end; + diff --git a/ag/nax_01.0 b/ag/nax_01.0 new file mode 100644 index 0000000..f579a41 --- /dev/null +++ b/ag/nax_01.0 @@ -0,0 +1,15 @@ +struct mystruct + field1 + field2 + field3 +end; +method doit() + var a := 10000; + var b := 0x42; + + return a - (b * 100); +end; + +method tester(arg) + doit(); +end; diff --git a/ag/nax_02.0 b/ag/nax_02.0 new file mode 100644 index 0000000..a335fe6 --- /dev/null +++ b/ag/nax_02.0 @@ -0,0 +1,8 @@ +method with_args2(arg1 arg2) + var a := 0; + doit(); + another_stmt(); + a; + something(); + something_other(arg1,); +end; diff --git a/ag/nax_03.2 b/ag/nax_03.2 new file mode 100644 index 0000000..9a78b21 --- /dev/null +++ b/ag/nax_03.2 @@ -0,0 +1,2 @@ +struct mystruct +end diff --git a/ag/nax_04.0 b/ag/nax_04.0 new file mode 100644 index 0000000..67a0c34 --- /dev/null +++ b/ag/nax_04.0 @@ -0,0 +1,6 @@ +/* + Hi, + this is a very long comment with some keywords which should be eaten + struct struct + struct +*/ diff --git a/ag/nax_05.2 b/ag/nax_05.2 new file mode 100644 index 0000000..fc6fb9e --- /dev/null +++ b/ag/nax_05.2 @@ -0,0 +1,3 @@ +method testit() + var b := 10 - d * 20; /* should raise an error, since '(' ')' are missing */ +end; diff --git a/ag/nax_06.0 b/ag/nax_06.0 new file mode 100644 index 0000000..146d79a --- /dev/null +++ b/ag/nax_06.0 @@ -0,0 +1,25 @@ +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; diff --git a/ag/nax_07.0 b/ag/nax_07.0 new file mode 100644 index 0000000..257a7a3 --- /dev/null +++ b/ag/nax_07.0 @@ -0,0 +1,21 @@ +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; diff --git a/ag/nax_08.0 b/ag/nax_08.0 new file mode 100644 index 0000000..e69de29 diff --git a/ag/nax_09.3 b/ag/nax_09.3 new file mode 100644 index 0000000..f78e9ec --- /dev/null +++ b/ag/nax_09.3 @@ -0,0 +1,7 @@ +method abc(arg1 arg2) + if arg1 = arg2 then + var a := 42; + end; + + var b := a - -1; +end; diff --git a/ag/nax_10.0 b/ag/nax_10.0 new file mode 100644 index 0000000..f187306 --- /dev/null +++ b/ag/nax_10.0 @@ -0,0 +1,10 @@ +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; diff --git a/ag/nax_11.0 b/ag/nax_11.0 new file mode 100644 index 0000000..96058a2 --- /dev/null +++ b/ag/nax_11.0 @@ -0,0 +1,9 @@ +method abc(arg1 arg2) + if arg1 = arg2 then + var a := 42; + end; + + var a := 3; + var b := a - -1; +end; + diff --git a/ag/nax_12.3 b/ag/nax_12.3 new file mode 100644 index 0000000..4ee7a1b --- /dev/null +++ b/ag/nax_12.3 @@ -0,0 +1,6 @@ +struct a b c end; +method test(arg1 arg2) + arg1.a := 10; +end; + +struct c d e end; diff --git a/ag/nax_14.3 b/ag/nax_14.3 new file mode 100644 index 0000000..7174855 --- /dev/null +++ b/ag/nax_14.3 @@ -0,0 +1,3 @@ +method abc(arg1 arg2) + var arg2 := 10; /* detect duplicates and fail */ +end; diff --git a/parser/kersm00.2 b/parser/kersm00.2 deleted file mode 100644 index ae832e6..0000000 --- a/parser/kersm00.2 +++ /dev/null @@ -1,40 +0,0 @@ -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 diff --git a/parser/kersm_00.2 b/parser/kersm_00.2 new file mode 100644 index 0000000..ae832e6 --- /dev/null +++ b/parser/kersm_00.2 @@ -0,0 +1,40 @@ +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 diff --git a/parser/lewurm_04.0 b/parser/lewurm_04.0 new file mode 100644 index 0000000..e69de29 diff --git a/parser/lewurm_05.0 b/parser/lewurm_05.0 new file mode 100644 index 0000000..8ce5264 --- /dev/null +++ b/parser/lewurm_05.0 @@ -0,0 +1,2 @@ +/* oneliner :) */ +struct x end; method f (a b c d e) if (a