diff --git a/src/test/lama/.gitignore b/src/test/lama/.gitignore new file mode 100644 index 0000000..bf30d1b --- /dev/null +++ b/src/test/lama/.gitignore @@ -0,0 +1,5 @@ +*.html +*.sm +/*.log +*.i +*.s diff --git a/src/test/lama/dune b/src/test/lama/dune new file mode 100644 index 0000000..2ddf89f --- /dev/null +++ b/src/test/lama/dune @@ -0,0 +1,162 @@ +; This file was autogenerated + +(cram (deps ../src/Driver.exe ../runtime/Std.i)) + +(cram (applies_to test001) + (deps test001.lama test001.input)) +(cram (applies_to test002) + (deps test002.lama test002.input)) +(cram (applies_to test003) + (deps test003.lama test003.input)) +(cram (applies_to test004) + (deps test004.lama test004.input)) +(cram (applies_to test005) + (deps test005.lama test005.input)) +(cram (applies_to test006) + (deps test006.lama test006.input)) +(cram (applies_to test007) + (deps test007.lama test007.input)) +(cram (applies_to test008) + (deps test008.lama test008.input)) +(cram (applies_to test009) + (deps test009.lama test009.input)) +(cram (applies_to test010) + (deps test010.lama test010.input)) +(cram (applies_to test011) + (deps test011.lama test011.input)) +(cram (applies_to test012) + (deps test012.lama test012.input)) +(cram (applies_to test013) + (deps test013.lama test013.input)) +(cram (applies_to test014) + (deps test014.lama test014.input)) +(cram (applies_to test015) + (deps test015.lama test015.input)) +(cram (applies_to test016) + (deps test016.lama test016.input)) +(cram (applies_to test017) + (deps test017.lama test017.input)) +(cram (applies_to test018) + (deps test018.lama test018.input)) +(cram (applies_to test019) + (deps test019.lama test019.input)) +(cram (applies_to test020) + (deps test020.lama test020.input)) +(cram (applies_to test021) + (deps test021.lama test021.input)) +(cram (applies_to test022) + (deps test022.lama test022.input)) +(cram (applies_to test023) + (deps test023.lama test023.input)) +(cram (applies_to test024) + (deps test024.lama test024.input)) +(cram (applies_to test025) + (deps test025.lama test025.input)) +(cram (applies_to test026) + (deps test026.lama test026.input)) +(cram (applies_to test027) + (deps test027.lama test027.input)) +(cram (applies_to test028) + (deps test028.lama test028.input)) +(cram (applies_to test029) + (deps test029.lama test029.input)) +(cram (applies_to test034) + (deps test034.lama test034.input)) +(cram (applies_to test036) + (deps test036.lama test036.input)) +(cram (applies_to test040) + (deps test040.lama test040.input)) +(cram (applies_to test041) + (deps test041.lama test041.input)) +(cram (applies_to test042) + (deps test042.lama test042.input)) +(cram (applies_to test045) + (deps test045.lama test045.input)) +(cram (applies_to test046) + (deps test046.lama test046.input)) +(cram (applies_to test050) + (deps test050.lama test050.input)) +(cram (applies_to test054) + (deps test054.lama test054.input)) +(cram (applies_to test059) + (deps test059.lama test059.input)) +(cram (applies_to test063) + (deps test063.lama test063.input)) +(cram (applies_to test072) + (deps test072.lama test072.input)) +(cram (applies_to test073) + (deps test073.lama test073.input)) +(cram (applies_to test074) + (deps test074.lama test074.input)) +(cram (applies_to test077) + (deps test077.lama test077.input)) +(cram (applies_to test078) + (deps test078.lama test078.input)) +(cram (applies_to test079) + (deps test079.lama test079.input)) +(cram (applies_to test080) + (deps test080.lama test080.input)) +(cram (applies_to test081) + (deps test081.lama test081.input)) +(cram (applies_to test082) + (deps test082.lama test082.input)) +(cram (applies_to test083) + (deps test083.lama test083.input)) +(cram (applies_to test084) + (deps test084.lama test084.input)) +(cram (applies_to test085) + (deps test085.lama test085.input)) +(cram (applies_to test086) + (deps test086.lama test086.input)) +(cram (applies_to test088) + (deps test088.lama test088.input)) +(cram (applies_to test089) + (deps test089.lama test089.input)) +(cram (applies_to test090) + (deps test090.lama test090.input)) +(cram (applies_to test091) + (deps test091.lama test091.input)) +(cram (applies_to test092) + (deps test092.lama test092.input)) +(cram (applies_to test093) + (deps test093.lama test093.input)) +(cram (applies_to test094) + (deps test094.lama test094.input)) +(cram (applies_to test095) + (deps test095.lama test095.input)) +(cram (applies_to test096) + (deps test096.lama test096.input)) +(cram (applies_to test097) + (deps test097.lama test097.input)) +(cram (applies_to test098) + (deps test098.lama test098.input)) +(cram (applies_to test099) + (deps test099.lama test099.input)) +(cram (applies_to test100) + (deps test100.lama test100.input)) +(cram (applies_to test101) + (deps test101.lama test101.input)) +(cram (applies_to test102) + (deps test102.lama test102.input)) +(cram (applies_to test103) + (deps test103.lama test103.input)) +(cram (applies_to test104) + (deps test104.lama test104.input)) +(cram (applies_to test105) + (deps test105.lama test105.input)) +(cram (applies_to test106) + (deps test106.lama test106.input)) +(cram (applies_to test107) + (deps test107.lama test107.input)) +(cram (applies_to test110) + (deps test110.lama test110.input)) +(cram (applies_to test111) + (deps test111.lama test111.input)) +(cram (applies_to test112) + (deps test112.lama test112.input)) +(cram (applies_to test801) + (deps test801.lama test801.input)) +(cram (applies_to test802) + (deps test802.lama test802.input)) +(cram (applies_to test803) + (deps test803.lama test803.input)) diff --git a/src/test/lama/gen.ml b/src/test/lama/gen.ml new file mode 100644 index 0000000..7463052 --- /dev/null +++ b/src/test/lama/gen.ml @@ -0,0 +1,35 @@ +(* Run as `ocaml gen.ml` *) + +let count = 1000 + +let () = + Out_channel.with_open_text "dune" (fun dunech -> + let dprintfn fmt = Format.kasprintf (Printf.fprintf dunech "%s\n") fmt in + dprintfn "; This file was autogenerated\n"; + dprintfn "(cram (deps ../src/Driver.exe ../runtime/Std.i))\n"; + + for i = 0 to count - 1 do + let cram_buf = Buffer.create 100 in + let cram_printfn fmt = + Format.kasprintf (Printf.bprintf cram_buf "%s\n") fmt + in + let cram_file = ref (Printf.sprintf "test%03d.t" i) in + let lama_file = ref (Printf.sprintf "test%03d.lama" i) in + let input_file = ref (Printf.sprintf "test%03d.input" i) in + + + let found = + if Sys.file_exists !lama_file then ( + cram_printfn + " $ ../src/Driver.exe -i test%03d.lama < \ + test%03d.input" + i i; + true) + else false + in + if found then ( + dprintfn "(cram (applies_to test%03d)" i; + dprintfn " (deps %s %s))" !lama_file !input_file; + Out_channel.with_open_text !cram_file (fun ch -> + output_string ch (Buffer.contents cram_buf))) + done) diff --git a/src/test/lama/test001.input b/src/test/lama/test001.input new file mode 100644 index 0000000..6613b56 --- /dev/null +++ b/src/test/lama/test001.input @@ -0,0 +1,2 @@ +5 +6 diff --git a/src/test/lama/test001.lama b/src/test/lama/test001.lama new file mode 100644 index 0000000..7003d2a --- /dev/null +++ b/src/test/lama/test001.lama @@ -0,0 +1,3 @@ +var x = read (), y = read (), z = x * y * 3; + +write (z) diff --git a/src/test/lama/test001.t b/src/test/lama/test001.t new file mode 100644 index 0000000..518e6ad --- /dev/null +++ b/src/test/lama/test001.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test001.lama < test001.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test002.input b/src/test/lama/test002.input new file mode 100644 index 0000000..6613b56 --- /dev/null +++ b/src/test/lama/test002.input @@ -0,0 +1,2 @@ +5 +6 diff --git a/src/test/lama/test002.lama b/src/test/lama/test002.lama new file mode 100644 index 0000000..5f67688 --- /dev/null +++ b/src/test/lama/test002.lama @@ -0,0 +1,6 @@ +var x, y, z; + +x := read (); +y := read (); +z := y*y; +write (x+z) diff --git a/src/test/lama/test002.t b/src/test/lama/test002.t new file mode 100644 index 0000000..1660aed --- /dev/null +++ b/src/test/lama/test002.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test002.lama < test002.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test003.input b/src/test/lama/test003.input new file mode 100644 index 0000000..3d08c7d --- /dev/null +++ b/src/test/lama/test003.input @@ -0,0 +1,2 @@ +10 +3 \ No newline at end of file diff --git a/src/test/lama/test003.lama b/src/test/lama/test003.lama new file mode 100644 index 0000000..3725a12 --- /dev/null +++ b/src/test/lama/test003.lama @@ -0,0 +1,7 @@ +var x, y; + +x := read (); +y := read (); +write (x-y); +write (x/y); +write (x%y) \ No newline at end of file diff --git a/src/test/lama/test003.t b/src/test/lama/test003.t new file mode 100644 index 0000000..b84e725 --- /dev/null +++ b/src/test/lama/test003.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test003.lama < test003.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test004.input b/src/test/lama/test004.input new file mode 100644 index 0000000..d3c6d1c --- /dev/null +++ b/src/test/lama/test004.input @@ -0,0 +1,2 @@ +10 +5 \ No newline at end of file diff --git a/src/test/lama/test004.lama b/src/test/lama/test004.lama new file mode 100644 index 0000000..3dfe78b --- /dev/null +++ b/src/test/lama/test004.lama @@ -0,0 +1,6 @@ +var x, y, z; + +x := read (); +y := read (); +z := ((x + y) + (x - y)) + ((x - y) - (x + y)); +write (z) \ No newline at end of file diff --git a/src/test/lama/test004.t b/src/test/lama/test004.t new file mode 100644 index 0000000..58b3bcb --- /dev/null +++ b/src/test/lama/test004.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test004.lama < test004.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test005.input b/src/test/lama/test005.input new file mode 100644 index 0000000..588bb35 --- /dev/null +++ b/src/test/lama/test005.input @@ -0,0 +1,2 @@ +6 +7 \ No newline at end of file diff --git a/src/test/lama/test005.lama b/src/test/lama/test005.lama new file mode 100644 index 0000000..f2af8fc --- /dev/null +++ b/src/test/lama/test005.lama @@ -0,0 +1,6 @@ +var x, y, z; + +x := read (); +y := read (); +z := ((x + y) + (x - y)) + ((x - y) - (x / y)); +write (z) \ No newline at end of file diff --git a/src/test/lama/test005.t b/src/test/lama/test005.t new file mode 100644 index 0000000..53a6c57 --- /dev/null +++ b/src/test/lama/test005.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test005.lama < test005.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test006.input b/src/test/lama/test006.input new file mode 100644 index 0000000..62881d2 --- /dev/null +++ b/src/test/lama/test006.input @@ -0,0 +1,2 @@ +-6 +7 \ No newline at end of file diff --git a/src/test/lama/test006.lama b/src/test/lama/test006.lama new file mode 100644 index 0000000..94cb35b --- /dev/null +++ b/src/test/lama/test006.lama @@ -0,0 +1,16 @@ +var x, y, z; + +x := read (); +y := read (); +z := x < y; +write (z); +z := x <= y; +write (z); +z := x == y; +write (z); +z := x != y; +write (z); +z := x >= y; +write (z); +z := x > y; +write (z) diff --git a/src/test/lama/test006.t b/src/test/lama/test006.t new file mode 100644 index 0000000..074663a --- /dev/null +++ b/src/test/lama/test006.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test006.lama < test006.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test007.input b/src/test/lama/test007.input new file mode 100644 index 0000000..e69de29 diff --git a/src/test/lama/test007.lama b/src/test/lama/test007.lama new file mode 100644 index 0000000..a080723 --- /dev/null +++ b/src/test/lama/test007.lama @@ -0,0 +1,6 @@ +var x, y, z; + +x := 1; +y := 2; +z := x - y - 3; +write (z) diff --git a/src/test/lama/test007.t b/src/test/lama/test007.t new file mode 100644 index 0000000..86fc9f4 --- /dev/null +++ b/src/test/lama/test007.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test007.lama < test007.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test008.input b/src/test/lama/test008.input new file mode 100644 index 0000000..e69de29 diff --git a/src/test/lama/test008.lama b/src/test/lama/test008.lama new file mode 100644 index 0000000..18b908d --- /dev/null +++ b/src/test/lama/test008.lama @@ -0,0 +1,4 @@ +var z; + +z := 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9; +write (z) diff --git a/src/test/lama/test008.t b/src/test/lama/test008.t new file mode 100644 index 0000000..ba4c09b --- /dev/null +++ b/src/test/lama/test008.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test008.lama < test008.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test009.input b/src/test/lama/test009.input new file mode 100644 index 0000000..e69de29 diff --git a/src/test/lama/test009.lama b/src/test/lama/test009.lama new file mode 100644 index 0000000..624497d --- /dev/null +++ b/src/test/lama/test009.lama @@ -0,0 +1,8 @@ +var n = 2, k = 10; + +(var res = 1; +while k > 0 do + res := res * n; + k := k - 1 +od; +write(res)) diff --git a/src/test/lama/test009.t b/src/test/lama/test009.t new file mode 100644 index 0000000..f450edd --- /dev/null +++ b/src/test/lama/test009.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test009.lama < test009.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test010.input b/src/test/lama/test010.input new file mode 100644 index 0000000..e69de29 diff --git a/src/test/lama/test010.lama b/src/test/lama/test010.lama new file mode 100644 index 0000000..2ca13d0 --- /dev/null +++ b/src/test/lama/test010.lama @@ -0,0 +1,20 @@ +var i, s; + +i := 0; +s := 0; + +while i < 100 +do + var j = 0; + + while j < 100 + do + s := s + j; + j := j + 1 + od; + + s := s + i; + i := i + 1 +od; + +write (s) diff --git a/src/test/lama/test010.t b/src/test/lama/test010.t new file mode 100644 index 0000000..0d4224f --- /dev/null +++ b/src/test/lama/test010.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test010.lama < test010.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test011.input b/src/test/lama/test011.input new file mode 100644 index 0000000..e69de29 diff --git a/src/test/lama/test011.lama b/src/test/lama/test011.lama new file mode 100644 index 0000000..f22e3ef --- /dev/null +++ b/src/test/lama/test011.lama @@ -0,0 +1,7 @@ +var x; + +x:=0; +if x +then write(1) +else write(2) +fi diff --git a/src/test/lama/test011.t b/src/test/lama/test011.t new file mode 100644 index 0000000..1d9f700 --- /dev/null +++ b/src/test/lama/test011.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test011.lama < test011.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test012.input b/src/test/lama/test012.input new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/src/test/lama/test012.input @@ -0,0 +1 @@ +3 \ No newline at end of file diff --git a/src/test/lama/test012.lama b/src/test/lama/test012.lama new file mode 100644 index 0000000..ec34543 --- /dev/null +++ b/src/test/lama/test012.lama @@ -0,0 +1,14 @@ +var n; + +n := read (); +while n >= 0 do + if n > 1 + then + write (0); + if n == 3 then write (0) else write (1) fi + else + write (1); + if n > 0 then write (0) else write (1) fi + fi; + n := n - 1 +od \ No newline at end of file diff --git a/src/test/lama/test012.t b/src/test/lama/test012.t new file mode 100644 index 0000000..a3abd09 --- /dev/null +++ b/src/test/lama/test012.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test012.lama < test012.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test013.input b/src/test/lama/test013.input new file mode 100644 index 0000000..1e8b314 --- /dev/null +++ b/src/test/lama/test013.input @@ -0,0 +1 @@ +6 diff --git a/src/test/lama/test013.lama b/src/test/lama/test013.lama new file mode 100644 index 0000000..cb35828 --- /dev/null +++ b/src/test/lama/test013.lama @@ -0,0 +1,16 @@ +var n = read (); + +do + + if n == 1 then write (0) +elif n == 2 then write (1) +elif n == 3 then write (2) +elif n == 4 then write (3) + else write (10) + fi; + + if n >= 5 then write (11) fi; + + n := n - 1 + +while n != 0 od \ No newline at end of file diff --git a/src/test/lama/test013.t b/src/test/lama/test013.t new file mode 100644 index 0000000..c6a66b2 --- /dev/null +++ b/src/test/lama/test013.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test013.lama < test013.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test014.input b/src/test/lama/test014.input new file mode 100644 index 0000000..29d6383 --- /dev/null +++ b/src/test/lama/test014.input @@ -0,0 +1 @@ +100 diff --git a/src/test/lama/test014.lama b/src/test/lama/test014.lama new file mode 100644 index 0000000..a9be510 --- /dev/null +++ b/src/test/lama/test014.lama @@ -0,0 +1,29 @@ +var n; + +n := read (); + +while n > 0 do + + if n < 1000 + then + if n < 500 + then + if n < 250 + then + if n < 125 + then + if n < 63 + then + if n < 32 + then + write (1) + fi + fi + fi + fi + fi + fi; + + n := n - 1 + +od \ No newline at end of file diff --git a/src/test/lama/test014.t b/src/test/lama/test014.t new file mode 100644 index 0000000..707cd59 --- /dev/null +++ b/src/test/lama/test014.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test014.lama < test014.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test015.input b/src/test/lama/test015.input new file mode 100644 index 0000000..83b33d2 --- /dev/null +++ b/src/test/lama/test015.input @@ -0,0 +1 @@ +1000 diff --git a/src/test/lama/test015.lama b/src/test/lama/test015.lama new file mode 100644 index 0000000..5fc01b3 --- /dev/null +++ b/src/test/lama/test015.lama @@ -0,0 +1,22 @@ +var s, n, p; + +s := 0; +n := read (); +p := 2; + +while n > 0 do ( + var c = 2, f = 1; + + while c*c <= p && f do + f := (p % c) != 0; + c := c + 1 + od; + + if f != 0 then + if n == 1 then write (p) else skip fi; + n := n - 1 + else skip fi; + + p := p + 1 +) +od diff --git a/src/test/lama/test015.t b/src/test/lama/test015.t new file mode 100644 index 0000000..ccd7a6a --- /dev/null +++ b/src/test/lama/test015.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test015.lama < test015.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test016.input b/src/test/lama/test016.input new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/src/test/lama/test016.input @@ -0,0 +1 @@ +10 diff --git a/src/test/lama/test016.lama b/src/test/lama/test016.lama new file mode 100644 index 0000000..5585e1f --- /dev/null +++ b/src/test/lama/test016.lama @@ -0,0 +1,14 @@ +var s, n; + +n := read (); + +s := 1; + +do + + s := s * n; + n := n - 1 + +while n != 0 od; + +write (s) \ No newline at end of file diff --git a/src/test/lama/test016.t b/src/test/lama/test016.t new file mode 100644 index 0000000..b756b18 --- /dev/null +++ b/src/test/lama/test016.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test016.lama < test016.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test017.input b/src/test/lama/test017.input new file mode 100644 index 0000000..209e3ef --- /dev/null +++ b/src/test/lama/test017.input @@ -0,0 +1 @@ +20 diff --git a/src/test/lama/test017.lama b/src/test/lama/test017.lama new file mode 100644 index 0000000..4c91a69 --- /dev/null +++ b/src/test/lama/test017.lama @@ -0,0 +1,17 @@ +var n, fib_1, fib_2, fib, i; + +n := read (); + +i := 2; +fib_1 := 1; +fib_2 := 1; +fib := 1; + +while i < n do + fib := fib_1 + fib_2; + fib_2 := fib_1; + fib_1 := fib; + i := i+1 +od; + +write (fib) \ No newline at end of file diff --git a/src/test/lama/test017.t b/src/test/lama/test017.t new file mode 100644 index 0000000..ed92d09 --- /dev/null +++ b/src/test/lama/test017.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test017.lama < test017.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test018.input b/src/test/lama/test018.input new file mode 100644 index 0000000..123af9e --- /dev/null +++ b/src/test/lama/test018.input @@ -0,0 +1 @@ +23409 diff --git a/src/test/lama/test018.lama b/src/test/lama/test018.lama new file mode 100644 index 0000000..77e76fe --- /dev/null +++ b/src/test/lama/test018.lama @@ -0,0 +1,44 @@ +var n, c, p, q, i, m, d; + +n := read (); + +c := 1; +p := 2; + +while c do + + var cc = 1; + + while cc do + q := 2; + + while q * q <= p && cc do + cc := p % q != 0; + q := q + 1 + od; + + if cc then cc := 0 else p := p + 1; cc := 1 fi + od; + + d := p; + i := 0; + + q := n / d; + m := n % d; + + while q > 0 && m == 0 do + i := i + 1; + d := d * p; + m := n % d; + if m == 0 then q := n / d else skip fi + od; + + write (p); + write (i); + + n := n / (d / p); + p := p + 1; + c := n != 1 + +od + diff --git a/src/test/lama/test018.t b/src/test/lama/test018.t new file mode 100644 index 0000000..07b5b96 --- /dev/null +++ b/src/test/lama/test018.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test018.lama < test018.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test019.input b/src/test/lama/test019.input new file mode 100644 index 0000000..e69de29 diff --git a/src/test/lama/test019.lama b/src/test/lama/test019.lama new file mode 100644 index 0000000..39b2fb4 --- /dev/null +++ b/src/test/lama/test019.lama @@ -0,0 +1,17 @@ +var i, s; + +i := 0; +s := 0; + +for i := 0, i < 100, i := i+1 +do + var j; + + for j := 0, j < 100, j := j+1 + do + s := s + j + od; + s := s + i +od; + +write (s) diff --git a/src/test/lama/test019.t b/src/test/lama/test019.t new file mode 100644 index 0000000..6ab1b2f --- /dev/null +++ b/src/test/lama/test019.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test019.lama < test019.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test020.input b/src/test/lama/test020.input new file mode 100644 index 0000000..83b33d2 --- /dev/null +++ b/src/test/lama/test020.input @@ -0,0 +1 @@ +1000 diff --git a/src/test/lama/test020.lama b/src/test/lama/test020.lama new file mode 100644 index 0000000..d5737a0 --- /dev/null +++ b/src/test/lama/test020.lama @@ -0,0 +1,22 @@ +var s, n, p; + +s := 0; +n := read (); +p := 2; + +while n > 0 do + var c = 2; + var f = 1; + + for c := 2, c*c <= p && f, c := c+1 + do + f := p % c != 0 + od; + + if f != 0 then + if n == 1 then write (p) fi; + n := n - 1 + fi; + + p := p + 1 +od diff --git a/src/test/lama/test020.t b/src/test/lama/test020.t new file mode 100644 index 0000000..a9fa2ee --- /dev/null +++ b/src/test/lama/test020.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test020.lama < test020.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test021.input b/src/test/lama/test021.input new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/src/test/lama/test021.input @@ -0,0 +1 @@ +10 diff --git a/src/test/lama/test021.lama b/src/test/lama/test021.lama new file mode 100644 index 0000000..3a01742 --- /dev/null +++ b/src/test/lama/test021.lama @@ -0,0 +1,11 @@ +var n, f; + +n := read (); +f := 1; + +for skip, n >= 1, n := n-1 +do + f := f * n +od; + +write (f) \ No newline at end of file diff --git a/src/test/lama/test021.t b/src/test/lama/test021.t new file mode 100644 index 0000000..8adcfb8 --- /dev/null +++ b/src/test/lama/test021.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test021.lama < test021.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test022.input b/src/test/lama/test022.input new file mode 100644 index 0000000..209e3ef --- /dev/null +++ b/src/test/lama/test022.input @@ -0,0 +1 @@ +20 diff --git a/src/test/lama/test022.lama b/src/test/lama/test022.lama new file mode 100644 index 0000000..da3773f --- /dev/null +++ b/src/test/lama/test022.lama @@ -0,0 +1,16 @@ +var n, fib_1, fib_2, fib, i; + +n := read (); + +fib_1 := 1; +fib_2 := 1; +fib := 1; + +for i := 2, i < n, i := i+1 +do + fib := fib_1 + fib_2; + fib_2 := fib_1; + fib_1 := fib +od; + +write (fib) \ No newline at end of file diff --git a/src/test/lama/test022.t b/src/test/lama/test022.t new file mode 100644 index 0000000..1064c82 --- /dev/null +++ b/src/test/lama/test022.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test022.lama < test022.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test023.input b/src/test/lama/test023.input new file mode 100644 index 0000000..b4ce092 --- /dev/null +++ b/src/test/lama/test023.input @@ -0,0 +1,6 @@ +5 +6 +7 +8 +9 +0 \ No newline at end of file diff --git a/src/test/lama/test023.lama b/src/test/lama/test023.lama new file mode 100644 index 0000000..8d1dd14 --- /dev/null +++ b/src/test/lama/test023.lama @@ -0,0 +1,10 @@ +var s, n; + +s := 0; + +do + n := read (); + s := s + n +while n != 0 od; + +write (s) diff --git a/src/test/lama/test023.t b/src/test/lama/test023.t new file mode 100644 index 0000000..d1819e2 --- /dev/null +++ b/src/test/lama/test023.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test023.lama < test023.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test024.input b/src/test/lama/test024.input new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/src/test/lama/test024.input @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/src/test/lama/test024.lama b/src/test/lama/test024.lama new file mode 100644 index 0000000..2936d74 --- /dev/null +++ b/src/test/lama/test024.lama @@ -0,0 +1,17 @@ +fun test1 () { + a := 3 +} + +fun test2 (b) { + a := b +} + +var x, a, b; + +x := read (); + +test1 (); +write (a); + +test2 (8); +write (a) \ No newline at end of file diff --git a/src/test/lama/test024.t b/src/test/lama/test024.t new file mode 100644 index 0000000..7cd9205 --- /dev/null +++ b/src/test/lama/test024.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test024.lama < test024.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test025.input b/src/test/lama/test025.input new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/src/test/lama/test025.input @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/src/test/lama/test025.lama b/src/test/lama/test025.lama new file mode 100644 index 0000000..b299d36 --- /dev/null +++ b/src/test/lama/test025.lama @@ -0,0 +1,33 @@ +var x, a, b, c; + +fun test1 (a) { + write (a) +} + +fun test2 (b) { + write (b) +} + +fun test3 (c) { + write (c) +} + +fun print () { + write (a); + write (b); + write (c) +} + +x := read (); + +a := 100; +b := 200; +c := 300; + +test1 (1); +print (); +test2 (2); +print (); +test3 (3); +print () + diff --git a/src/test/lama/test025.t b/src/test/lama/test025.t new file mode 100644 index 0000000..f22a467 --- /dev/null +++ b/src/test/lama/test025.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test025.lama < test025.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test026.input b/src/test/lama/test026.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test026.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test026.lama b/src/test/lama/test026.lama new file mode 100644 index 0000000..72ff2c1 --- /dev/null +++ b/src/test/lama/test026.lama @@ -0,0 +1,36 @@ +var x, a, b, c; + +fun test1 (a) { + write (a); + print () +} + +fun test2 (b) { + write (b); + print () +} + +fun test3 (c) { + write (c); + print () +} + +fun print () { + write (a); + write (b); + write (c) +} + +x := read (); + +a := 100; +b := 200; +c := 300; + +test1 (1); +print (); +test2 (2); +print (); +test3 (3); +print () + diff --git a/src/test/lama/test026.t b/src/test/lama/test026.t new file mode 100644 index 0000000..853e1f5 --- /dev/null +++ b/src/test/lama/test026.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test026.lama < test026.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test027.input b/src/test/lama/test027.input new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/src/test/lama/test027.input @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/src/test/lama/test027.lama b/src/test/lama/test027.lama new file mode 100644 index 0000000..d25da91 --- /dev/null +++ b/src/test/lama/test027.lama @@ -0,0 +1,32 @@ +var x, a, b, c; + +fun print () { + write (a); + write (b); + write (c) +} + +fun test1 (a) { + write (a); + print (); + write (a); + if a < 4 then + test2 (a+1); + print () + fi +} + +fun test2 (b) { + write (b); + print (); + test1 (b+1); + print () +} + +x := read (); + +a := 100; +b := 200; +c := 300; + +test1 (1) diff --git a/src/test/lama/test027.t b/src/test/lama/test027.t new file mode 100644 index 0000000..8540028 --- /dev/null +++ b/src/test/lama/test027.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test027.lama < test027.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test028.input b/src/test/lama/test028.input new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/src/test/lama/test028.input @@ -0,0 +1 @@ +7 diff --git a/src/test/lama/test028.lama b/src/test/lama/test028.lama new file mode 100644 index 0000000..92dfe45 --- /dev/null +++ b/src/test/lama/test028.lama @@ -0,0 +1,18 @@ +var n, i, result; + +fun fact (n) { + if n <= 1 + then result := 1 + else + fact (n-1); + result := result * n + fi +} + +n := read (); + +for i := n, i >= 1, i := i-1 do + fact (i); + write (i); + write (result) +od \ No newline at end of file diff --git a/src/test/lama/test028.t b/src/test/lama/test028.t new file mode 100644 index 0000000..7091a47 --- /dev/null +++ b/src/test/lama/test028.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test028.lama < test028.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test029.input b/src/test/lama/test029.input new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/src/test/lama/test029.input @@ -0,0 +1 @@ +9 diff --git a/src/test/lama/test029.lama b/src/test/lama/test029.lama new file mode 100644 index 0000000..9fe88a7 --- /dev/null +++ b/src/test/lama/test029.lama @@ -0,0 +1,21 @@ +var i, n, result; + +fun fib (n) { + var r; + if n <= 1 + then result := 1 + else + fib (n-1); + r := result; + fib (n-2); + result := result + r + fi +} + +n := read (); + +for i := n, i >= 1, i := i-1 do + fib (i); + write (i); + write (result) +od \ No newline at end of file diff --git a/src/test/lama/test029.t b/src/test/lama/test029.t new file mode 100644 index 0000000..04d4f1a --- /dev/null +++ b/src/test/lama/test029.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test029.lama < test029.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test034.input b/src/test/lama/test034.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test034.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test034.lama b/src/test/lama/test034.lama new file mode 100644 index 0000000..af4e5ff --- /dev/null +++ b/src/test/lama/test034.lama @@ -0,0 +1,19 @@ +var n, x, i; + +fun printString (x) { + for i:=0, i write (1) + | B -> write (2) + | C -> write (3) + | _ -> write (4) + esac +} + +x := read (); + +f (A); +f (B); +f (C); +f (D) \ No newline at end of file diff --git a/src/test/lama/test040.t b/src/test/lama/test040.t new file mode 100644 index 0000000..2c7563e --- /dev/null +++ b/src/test/lama/test040.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test040.lama < test040.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test041.input b/src/test/lama/test041.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test041.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test041.lama b/src/test/lama/test041.lama new file mode 100644 index 0000000..486832c --- /dev/null +++ b/src/test/lama/test041.lama @@ -0,0 +1,13 @@ +var x; + +fun f (a) { + case a of + A (x, y, z) -> write (x + y + z) + | B (x, y, z) -> write (x + y + z) + esac +} + +x := read (); + +f (A (100, 200, 300)); +f (B (500, 600, 700)) \ No newline at end of file diff --git a/src/test/lama/test041.t b/src/test/lama/test041.t new file mode 100644 index 0000000..0e725f3 --- /dev/null +++ b/src/test/lama/test041.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test041.lama < test041.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test042.input b/src/test/lama/test042.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test042.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test042.lama b/src/test/lama/test042.lama new file mode 100644 index 0000000..a97c459 --- /dev/null +++ b/src/test/lama/test042.lama @@ -0,0 +1,19 @@ +var x, y, i; + +fun f (x) { + case x of + Nil -> write (0) + | Cons (_, Nil) -> write (1) + | Cons (_, Cons (_, Nil)) -> write (2) + | Cons (_, Cons (_, Cons (_, Nil))) -> write (3) + | _ -> write (4) + esac +} + +x := read (); +y := Nil; + +for i := 0, i < 10, i := i + 1 do + f (y); + y := Cons (i, y) +od \ No newline at end of file diff --git a/src/test/lama/test042.t b/src/test/lama/test042.t new file mode 100644 index 0000000..5ab5935 --- /dev/null +++ b/src/test/lama/test042.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test042.lama < test042.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test045.input b/src/test/lama/test045.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test045.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test045.lama b/src/test/lama/test045.lama new file mode 100644 index 0000000..5000290 --- /dev/null +++ b/src/test/lama/test045.lama @@ -0,0 +1,15 @@ +var x; + +fun printString (s) { + var i; + for i := 0, i < s.length, i := i + 1 do + write (s[i]) + od +} + +x := read (); +printString (1.string); +printString ("abc".string); +printString ([].string); +printString ([1, 2, 3].string); +printString (Cons (1, Cons (2, Nil)).string) \ No newline at end of file diff --git a/src/test/lama/test045.t b/src/test/lama/test045.t new file mode 100644 index 0000000..d135df2 --- /dev/null +++ b/src/test/lama/test045.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test045.lama < test045.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test046.input b/src/test/lama/test046.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test046.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test046.lama b/src/test/lama/test046.lama new file mode 100644 index 0000000..6c6268b --- /dev/null +++ b/src/test/lama/test046.lama @@ -0,0 +1,40 @@ +var n; + +n := read (); + +case 3 of + a -> write (a) +| _ -> write (0) +esac; + +case 3 of + a -> write (a) +esac; + +case 3 of + a@_ -> write (a) +esac; + +case A (1, 2, 3) of + A -> write (1) +| a@A (_, _, _) -> case a of + A (x, y, z) -> write (x); write (y); write (z) + esac +esac; + +case A (1, 2, 3, 4, 5) of + A -> write (0) +| A (_) -> write (1) +| A (_, _) -> write (2) +| A (_, _, _) -> write (3) +| A (_, _, _, _) -> write (4) +| A (_, _, _, _, _) -> write (5) +esac; + +write (A (1, 2, 3, 4, 5).length); + +write (A (1, 2, 3, 4, 5)[0]); +write (A (1, 2, 3, 4, 5)[1]); +write (A (1, 2, 3, 4, 5)[2]); +write (A (1, 2, 3, 4, 5)[3]); +write (A (1, 2, 3, 4, 5)[4]) diff --git a/src/test/lama/test046.t b/src/test/lama/test046.t new file mode 100644 index 0000000..6c920bc --- /dev/null +++ b/src/test/lama/test046.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test046.lama < test046.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test050.input b/src/test/lama/test050.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test050.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test050.lama b/src/test/lama/test050.lama new file mode 100644 index 0000000..fcbcea1 --- /dev/null +++ b/src/test/lama/test050.lama @@ -0,0 +1,7 @@ +var n, x, y; + +n := read (); +x := [1]; +y := [x, x]; +y[1][0] := 2; +write (y[0][0]) \ No newline at end of file diff --git a/src/test/lama/test050.t b/src/test/lama/test050.t new file mode 100644 index 0000000..474a590 --- /dev/null +++ b/src/test/lama/test050.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test050.lama < test050.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test054.input b/src/test/lama/test054.input new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/src/test/lama/test054.input @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/src/test/lama/test054.lama b/src/test/lama/test054.lama new file mode 100644 index 0000000..4ccba1c --- /dev/null +++ b/src/test/lama/test054.lama @@ -0,0 +1,28 @@ +var x, y, z, s, i, n; + +x := y := z := 105; + +n := read (); + +write (x); +write (y); +write (z); + +if z then x else y fi := 230; + +write (x); +write (y); +write (z); + +(write (z); z) := 250; + +write (x); +write (y); +write (z); + +s := [1, 2, 3, 4]; +i := -1; + +while n := s[i := i + 1]; n == 1 !! n == 2 !! n == 3 do + write (n) +od diff --git a/src/test/lama/test054.t b/src/test/lama/test054.t new file mode 100644 index 0000000..f5e6ab4 --- /dev/null +++ b/src/test/lama/test054.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test054.lama < test054.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test059.input b/src/test/lama/test059.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test059.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test059.lama b/src/test/lama/test059.lama new file mode 100644 index 0000000..cc4dcb9 --- /dev/null +++ b/src/test/lama/test059.lama @@ -0,0 +1,22 @@ +fun f (l) { + case l of + {} -> skip + | h : tl -> h (); f (tl) + esac +} + +fun a () { + write (0) +} + +fun b () { + write (1) +} + +fun c () { + write (2) +} + +var x = read (); + +f ({a, b, c}) \ No newline at end of file diff --git a/src/test/lama/test059.t b/src/test/lama/test059.t new file mode 100644 index 0000000..3677104 --- /dev/null +++ b/src/test/lama/test059.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test059.lama < test059.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test063.input b/src/test/lama/test063.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test063.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test063.lama b/src/test/lama/test063.lama new file mode 100644 index 0000000..28d8203 --- /dev/null +++ b/src/test/lama/test063.lama @@ -0,0 +1,11 @@ +fun traverse (l) { + case l of + {} -> skip + | (f@#fun) : tl -> f (); traverse (tl) + | _ : tl -> traverse (tl) + esac +} + +var x = read (); + +traverse ({1, fun () {write(100)}, 2, 3, 4, 5, fun () {write (200)}, 6, 7}) \ No newline at end of file diff --git a/src/test/lama/test063.t b/src/test/lama/test063.t new file mode 100644 index 0000000..5cbcaf3 --- /dev/null +++ b/src/test/lama/test063.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test063.lama < test063.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test072.input b/src/test/lama/test072.input new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/src/test/lama/test072.input @@ -0,0 +1 @@ +9 diff --git a/src/test/lama/test072.lama b/src/test/lama/test072.lama new file mode 100644 index 0000000..1554087 --- /dev/null +++ b/src/test/lama/test072.lama @@ -0,0 +1,16 @@ +var n, i; + +fun fib (n) { + if n <= 1 + then 1 + else + (fib (n-1) + fib (n-2)) + fi +} + +n := read (); + +for i := n, i >= 1, i := i-1 do + write (i); + write (fib (i)) +od \ No newline at end of file diff --git a/src/test/lama/test072.t b/src/test/lama/test072.t new file mode 100644 index 0000000..c669333 --- /dev/null +++ b/src/test/lama/test072.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test072.lama < test072.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test073.input b/src/test/lama/test073.input new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/src/test/lama/test073.input @@ -0,0 +1 @@ +7 diff --git a/src/test/lama/test073.lama b/src/test/lama/test073.lama new file mode 100644 index 0000000..496fa0a --- /dev/null +++ b/src/test/lama/test073.lama @@ -0,0 +1,16 @@ +var n, i; + +fun fact (n) { + if n <= 1 + then 1 + else + (n * fact (n-1)) + fi +} + +n := read (); + +for i := n, i >= 1, i := i-1 do + write (i); + write (fact (i)) +od \ No newline at end of file diff --git a/src/test/lama/test073.t b/src/test/lama/test073.t new file mode 100644 index 0000000..08743d8 --- /dev/null +++ b/src/test/lama/test073.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test073.lama < test073.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test074.input b/src/test/lama/test074.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test074.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test074.lama b/src/test/lama/test074.lama new file mode 100644 index 0000000..e09afe8 --- /dev/null +++ b/src/test/lama/test074.lama @@ -0,0 +1,16 @@ +var x, m, n; + +fun ack (m, n) { + if m == 0 then (n+1) + elif m > 0 && n == 0 then ack (m-1, 1) + else ack (m-1, ack (m, n-1)) + fi +} + +x := read (); + +for m := 0, m <= 3, m := m+1 do + for n := 0, n <= 8, n := n+1 do + write (ack (m, n)) + od +od \ No newline at end of file diff --git a/src/test/lama/test074.t b/src/test/lama/test074.t new file mode 100644 index 0000000..be1774e --- /dev/null +++ b/src/test/lama/test074.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test074.lama < test074.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test077.input b/src/test/lama/test077.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test077.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test077.lama b/src/test/lama/test077.lama new file mode 100644 index 0000000..7ebef4b --- /dev/null +++ b/src/test/lama/test077.lama @@ -0,0 +1,29 @@ +var n, x, i; + +fun sort (x) { + var i, j, y, n; + n := x.length; + + if n == 0 then x fi; + + for i := 0, i y + | Cons (h, t) -> Cons (h, append (t, y)) + esac +} + +fun printList (x) { + case x of + Nil -> skip + | Cons (h, t) -> write (h); printList (t) + esac +} + +n := read (); + +x := Cons (1, Cons (2, Nil)); +y := Cons (3, Cons (4, Nil)); + +printList (x); +printList (y); +printList (append (x, y)); +printList (append (y, x)) diff --git a/src/test/lama/test078.t b/src/test/lama/test078.t new file mode 100644 index 0000000..0dbc6bc --- /dev/null +++ b/src/test/lama/test078.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test078.lama < test078.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test079.input b/src/test/lama/test079.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test079.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test079.lama b/src/test/lama/test079.lama new file mode 100644 index 0000000..5a900d6 --- /dev/null +++ b/src/test/lama/test079.lama @@ -0,0 +1,32 @@ +var n, t; + +fun insert (t, x) { + case t of + Leaf -> Node (x, Leaf, Leaf) + | Node (y, l, r) -> if x > y + then Node (y, insert (l, x), r) + else Node (y, l, insert (r, x)) + fi + esac +} + +fun find (t, x) { + case t of + Leaf -> 0 + | Node (y, l, r) -> if x == y then 1 + elif x > y then find (l, x) + else find (r, x) + fi + esac +} + +n := read (); + +t := insert (insert (insert (insert (Leaf, 5), 4), 6), 3); + +write (find (t, 5)); +write (find (t, 4)); +write (find (t, 6)); +write (find (t, 3)); +write (find (t, 2)); +write (find (t, 1)) diff --git a/src/test/lama/test079.t b/src/test/lama/test079.t new file mode 100644 index 0000000..1b61aac --- /dev/null +++ b/src/test/lama/test079.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test079.lama < test079.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test080.input b/src/test/lama/test080.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test080.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test080.lama b/src/test/lama/test080.lama new file mode 100644 index 0000000..ec3b79a --- /dev/null +++ b/src/test/lama/test080.lama @@ -0,0 +1,14 @@ +var x; + +fun sum (x) { + case x of + Nil -> 0 + | Cons (x, tl) -> (x + sum (tl)) + esac +} + +x := read (); + +write (sum (Nil)); +write (sum (Cons (100, Nil))); +write (sum (Cons (100, Cons (200, Nil)))) \ No newline at end of file diff --git a/src/test/lama/test080.t b/src/test/lama/test080.t new file mode 100644 index 0000000..b58eacc --- /dev/null +++ b/src/test/lama/test080.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test080.lama < test080.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test081.input b/src/test/lama/test081.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test081.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test081.lama b/src/test/lama/test081.lama new file mode 100644 index 0000000..f132e2b --- /dev/null +++ b/src/test/lama/test081.lama @@ -0,0 +1,39 @@ +var x, y, z; + +fun zip (x) { + case x of Pair (x, y) -> + case x of + Nil -> Nil + | Cons (x, xs) -> case y of + Nil -> Nil + | Cons (y, ys) -> Cons (Pair (x, y), zip (Pair (xs, ys))) + esac + esac + esac +} + +fun unzip (x) { + case x of + Nil -> Pair (Nil, Nil) + | Cons (Pair (x, y), tl) -> + case unzip (tl) of + Pair (xs, ys) -> Pair (Cons (x, xs), Cons (y, ys)) + esac + esac +} + +fun printList (l) { + case l of + Nil -> skip + | Cons (x, xs) -> write (x); printList (xs) + esac +} + +z := read (); + +x := Cons (1, Cons (2, Cons (3, Nil))); +y := Cons (100, Cons (200, Cons (300, Nil))); + +case unzip (zip (Pair (x, y))) of + Pair (x, y) -> printList (x); printList (y) +esac \ No newline at end of file diff --git a/src/test/lama/test081.t b/src/test/lama/test081.t new file mode 100644 index 0000000..87a0687 --- /dev/null +++ b/src/test/lama/test081.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test081.lama < test081.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test082.input b/src/test/lama/test082.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test082.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test082.lama b/src/test/lama/test082.lama new file mode 100644 index 0000000..1087677 --- /dev/null +++ b/src/test/lama/test082.lama @@ -0,0 +1,75 @@ +var n; + +fun collect_ints_acc (v, tail) { + var i; + case v of + a@#val -> Cons (a, tail) + | #str -> tail + | _ -> + for i := 0, i < v.length, i := i + 1 do + tail := collect_ints_acc (v[i], tail) + od; + tail + esac +} + +fun collect_ints (v) { + collect_ints_acc (v, Nil) +} + +fun print_list (l) { + case l of + Nil -> skip + | Cons (n, t) -> write (n); print_list (t) + esac +} + +n := read (); + +case 1 of + 5 -> write (5) +| 4 -> write (4) +| 3 -> write (3) +| 2 -> write (2) +| 1 -> write (1) +| 0 -> write (0) +esac; + +case 1 of + a@5 -> write (a) +| a@4 -> write (a) +| a@3 -> write (a) +| a@2 -> write (a) +| a@1 -> write (a) +| a@0 -> write (a) +esac; + +case A (1, 2, 3) of + A (1, 3, 5) -> write (0) +| A (3, 4, 5) -> write (0) +| A (1, 2, 3) -> write (1) +| A (6, 7, 8) -> write (0) +esac; + +case "abc" of + "def" -> write (0) +| "ab" -> write (0) +| "abc" -> write (1) +| "" -> write (0) +esac; + +case [1, 2, 3] of + [] -> write (0) +| [a, b] -> write (0) +| [a, b, c] -> write (a); write (b); write (c) +| [_, _, _] -> write (0) +esac; + +case [1, 2, 3] of + [] -> write (0) +| [a, b] -> write (0) +| [_, _, _] -> write (100) +| [a, b, c] -> write (a); write (b); write (c) +esac; + +print_list (collect_ints ([1, 2, 3, [4, 5, 6, Cons (1, 2, 3)]])) diff --git a/src/test/lama/test082.t b/src/test/lama/test082.t new file mode 100644 index 0000000..9099a22 --- /dev/null +++ b/src/test/lama/test082.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test082.lama < test082.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test083.input b/src/test/lama/test083.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test083.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test083.lama b/src/test/lama/test083.lama new file mode 100644 index 0000000..282af71 --- /dev/null +++ b/src/test/lama/test083.lama @@ -0,0 +1,12 @@ +var n, y; + +fun test (n, m) { + var i, s; + write (n); + write (m); + n +} + +n := read (); +y := 1 + (2 + (3 + (4 + (5 + (6 + test (7, 7)))))); +write (y) \ No newline at end of file diff --git a/src/test/lama/test083.t b/src/test/lama/test083.t new file mode 100644 index 0000000..545e389 --- /dev/null +++ b/src/test/lama/test083.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test083.lama < test083.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test084.input b/src/test/lama/test084.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test084.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test084.lama b/src/test/lama/test084.lama new file mode 100644 index 0000000..4a6207a --- /dev/null +++ b/src/test/lama/test084.lama @@ -0,0 +1,23 @@ +var n, y, y2, t; + +fun test (n, m) { + var i, s; + s := 0; + for i := 0, i <= n, i := i + 1 do + s := s + i; + if s > m then s fi + od; + + s +} + +n := read (); +y := ((((((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))))) + (((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))))) + ((((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))))) + (((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))))))) + (((((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))))) + (((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))))) + ((((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))))) + (((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + test(10, 100))))))))); + +t := test (10, 100); +y2 := ((((((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))))) + (((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))))) + ((((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))))) + (((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))))))) + (((((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))))) + (((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))))) + ((((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))))) + (((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1)))) + ((((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + 1))) + (((1 + 1) + (1 + 1)) + ((1 + 1) + (1 + t)))))))); + +write (t); +write (y2); +write (y) + diff --git a/src/test/lama/test084.t b/src/test/lama/test084.t new file mode 100644 index 0000000..497f830 --- /dev/null +++ b/src/test/lama/test084.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test084.lama < test084.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test085.input b/src/test/lama/test085.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test085.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test085.lama b/src/test/lama/test085.lama new file mode 100644 index 0000000..adfef72 --- /dev/null +++ b/src/test/lama/test085.lama @@ -0,0 +1,30 @@ +var n; + +fun sum (l) { + case l of + {} -> 0 + | h : t -> (h + sum (t)) + esac +} + +fun print_list (l) { + case l of + {} -> skip + | h : t -> write (h); print_list (t) + esac +} + +fun array_to_list (a) { + var l, i; + l := {}; + for i := a.length, i > 0, i := i-1 do + l := a[i-1] : l + od; + l +} + +n := read (); +write (sum ({})); +write (sum ({1, 2, 3, 4, 5})); +write (sum (1:2:3:4:5:{})); +print_list (array_to_list ([1, 2, 3, 4, 5])) diff --git a/src/test/lama/test085.t b/src/test/lama/test085.t new file mode 100644 index 0000000..98dbc56 --- /dev/null +++ b/src/test/lama/test085.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test085.lama < test085.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test086.input b/src/test/lama/test086.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test086.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test086.lama b/src/test/lama/test086.lama new file mode 100644 index 0000000..ceb01fa --- /dev/null +++ b/src/test/lama/test086.lama @@ -0,0 +1,26 @@ +var n; + +fun hd (l) { + case l of + h : _ -> h + esac +} + + +fun tl (l) { + case l of + _ : tl -> tl + esac +} + +fun print_list (l) { + case l of + {} -> skip + | h : t -> write (h); print_list (t) + esac +} + +n := read (); +write ({1, 2, 3}.hd); +print_list ({1, 2, 3}.tl) + diff --git a/src/test/lama/test086.t b/src/test/lama/test086.t new file mode 100644 index 0000000..8fb0841 --- /dev/null +++ b/src/test/lama/test086.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test086.lama < test086.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test088.input b/src/test/lama/test088.input new file mode 100644 index 0000000..e69de29 diff --git a/src/test/lama/test088.lama b/src/test/lama/test088.lama new file mode 100644 index 0000000..e9c5208 --- /dev/null +++ b/src/test/lama/test088.lama @@ -0,0 +1,8 @@ +fun len(l) { + case l of + _ : xs -> len(xs) + 1 + |{} -> 0 + esac +} +write(len({})); +write(len({1, 2, 3})) \ No newline at end of file diff --git a/src/test/lama/test088.t b/src/test/lama/test088.t new file mode 100644 index 0000000..bdd2970 --- /dev/null +++ b/src/test/lama/test088.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test088.lama < test088.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test089.input b/src/test/lama/test089.input new file mode 100644 index 0000000..01e79c3 --- /dev/null +++ b/src/test/lama/test089.input @@ -0,0 +1,3 @@ +1 +2 +3 diff --git a/src/test/lama/test089.lama b/src/test/lama/test089.lama new file mode 100644 index 0000000..f70f99a --- /dev/null +++ b/src/test/lama/test089.lama @@ -0,0 +1,8 @@ +fun test (a, b, c) { + var x = a + b, y = b + c; + (var e = x + y; + e + ) +} + +write (test (read (), read (), read ())) \ No newline at end of file diff --git a/src/test/lama/test089.t b/src/test/lama/test089.t new file mode 100644 index 0000000..1136264 --- /dev/null +++ b/src/test/lama/test089.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test089.lama < test089.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test090.input b/src/test/lama/test090.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test090.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test090.lama b/src/test/lama/test090.lama new file mode 100644 index 0000000..ad721a5 --- /dev/null +++ b/src/test/lama/test090.lama @@ -0,0 +1,12 @@ +fun a (x) { x + 1} +fun b (x) { x + 2} +fun c (x) { x + 3} + +( + var funs = [a, b, c]; + var n = read (), i; + + for i := 0, i < 3, i := i+1 do + write (funs[i] (n)) + od +) \ No newline at end of file diff --git a/src/test/lama/test090.t b/src/test/lama/test090.t new file mode 100644 index 0000000..ae4d684 --- /dev/null +++ b/src/test/lama/test090.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test090.lama < test090.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test091.input b/src/test/lama/test091.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test091.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test091.lama b/src/test/lama/test091.lama new file mode 100644 index 0000000..1236d54 --- /dev/null +++ b/src/test/lama/test091.lama @@ -0,0 +1,23 @@ +fun map (f, l) { + case l of + {} -> {} + | h : tl -> (f (h) : map (f, tl)) + esac +} + +fun a (x) { x + 1} +fun b (x) { x + 2} + +fun print_list (x) { + case x of + {} -> skip + | h : tl -> write (h); print_list (tl) + esac +} + +var x = read (); + +print_list ({1, 2, 3}); +print_list (map (a, {1, 2, 3})); +print_list (map (b, {1, 2, 3})) + diff --git a/src/test/lama/test091.t b/src/test/lama/test091.t new file mode 100644 index 0000000..299bf17 --- /dev/null +++ b/src/test/lama/test091.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test091.lama < test091.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test092.input b/src/test/lama/test092.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test092.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test092.lama b/src/test/lama/test092.lama new file mode 100644 index 0000000..b83511b --- /dev/null +++ b/src/test/lama/test092.lama @@ -0,0 +1,19 @@ +fun f (l) { + infix === at == (a, b) { + a == b + } + + case l of + {} -> 1 + | {_} -> 1 + | a : b : tl -> a === b && f (b : tl) + esac +} + +var x = read (); + +write (f ({})); +write (f (1:{})); +write (f ({1, 1})); +write (f ({1, 1, 1})); +write (f ({1, 2, 1})) diff --git a/src/test/lama/test092.t b/src/test/lama/test092.t new file mode 100644 index 0000000..c09945b --- /dev/null +++ b/src/test/lama/test092.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test092.lama < test092.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test093.input b/src/test/lama/test093.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test093.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test093.lama b/src/test/lama/test093.lama new file mode 100644 index 0000000..a6b79d7 --- /dev/null +++ b/src/test/lama/test093.lama @@ -0,0 +1,12 @@ +fun plus (x) { + fun f (y) { + x + y + } + + f +} + +var x = read (); + +write (plus(5)(6)); +write (plus(8)(10)) \ No newline at end of file diff --git a/src/test/lama/test093.t b/src/test/lama/test093.t new file mode 100644 index 0000000..bcfad3b --- /dev/null +++ b/src/test/lama/test093.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test093.lama < test093.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test094.input b/src/test/lama/test094.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test094.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test094.lama b/src/test/lama/test094.lama new file mode 100644 index 0000000..76d3b67 --- /dev/null +++ b/src/test/lama/test094.lama @@ -0,0 +1,22 @@ +fun a (x, y) { + var a = x + y, b = x - y; + ( + var f = fun () { + write (x); + write (y); + write (a); + write (b) + }; + + a := 100; + b := 200; + x := 800; + y := 1000; + + f + ) +} + +var x = read (); + +a (5, 7) () \ No newline at end of file diff --git a/src/test/lama/test094.t b/src/test/lama/test094.t new file mode 100644 index 0000000..c6c4ef1 --- /dev/null +++ b/src/test/lama/test094.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test094.lama < test094.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test095.input b/src/test/lama/test095.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test095.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test095.lama b/src/test/lama/test095.lama new file mode 100644 index 0000000..98cbc52 --- /dev/null +++ b/src/test/lama/test095.lama @@ -0,0 +1,5 @@ +infix +++ at + (a, b) { a+b} + +var x = read (); + +write (infix +++ (2, 3)) \ No newline at end of file diff --git a/src/test/lama/test095.t b/src/test/lama/test095.t new file mode 100644 index 0000000..ac74eb1 --- /dev/null +++ b/src/test/lama/test095.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test095.lama < test095.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test096.input b/src/test/lama/test096.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test096.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test096.lama b/src/test/lama/test096.lama new file mode 100644 index 0000000..37f580d --- /dev/null +++ b/src/test/lama/test096.lama @@ -0,0 +1,23 @@ +fun f () { + var x, l = {}; + fun g () { x} + + x := 1; + l := g : l; + + x := 2; + l := g : l; + + l +} + +fun p (l) { + case l of + {} -> skip + | h : tl -> write (h ()); p (tl) + esac +} + +var x = read (); + +p (f ()) \ No newline at end of file diff --git a/src/test/lama/test096.t b/src/test/lama/test096.t new file mode 100644 index 0000000..5cc29a0 --- /dev/null +++ b/src/test/lama/test096.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test096.lama < test096.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test097.input b/src/test/lama/test097.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test097.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test097.lama b/src/test/lama/test097.lama new file mode 100644 index 0000000..d270d6e --- /dev/null +++ b/src/test/lama/test097.lama @@ -0,0 +1,13 @@ +fun f (a) { + fun g (b) { + fun h (c) { + fun (x) { x + a + b + c} + } + h (b) + } + g (a) +} + +var x = read (); + +write (f(10)(5)) \ No newline at end of file diff --git a/src/test/lama/test097.t b/src/test/lama/test097.t new file mode 100644 index 0000000..a298e83 --- /dev/null +++ b/src/test/lama/test097.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test097.lama < test097.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test098.input b/src/test/lama/test098.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test098.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test098.lama b/src/test/lama/test098.lama new file mode 100644 index 0000000..23cd57b --- /dev/null +++ b/src/test/lama/test098.lama @@ -0,0 +1,7 @@ +infixr ** before * (f, g) { + fun (x) { f (g (x))} +} + +var x = read (); + +write ((fun (x) { x+2} ** fun (x) { x+3})(7)) \ No newline at end of file diff --git a/src/test/lama/test098.t b/src/test/lama/test098.t new file mode 100644 index 0000000..c47319e --- /dev/null +++ b/src/test/lama/test098.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test098.lama < test098.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test099.input b/src/test/lama/test099.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test099.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test099.lama b/src/test/lama/test099.lama new file mode 100644 index 0000000..35c2eb6 --- /dev/null +++ b/src/test/lama/test099.lama @@ -0,0 +1,19 @@ +fun makeLazy (f) { + var flag = 0, value = 0; + + fun () { + if flag + then value + else + value := f (); + flag := 1; + value + fi + } +} + +var l = makeLazy (fun () {write (1); 800}); +var x = read (); + +write (l ()); +write (l ()) \ No newline at end of file diff --git a/src/test/lama/test099.t b/src/test/lama/test099.t new file mode 100644 index 0000000..9e21031 --- /dev/null +++ b/src/test/lama/test099.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test099.lama < test099.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test100.input b/src/test/lama/test100.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test100.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test100.lama b/src/test/lama/test100.lama new file mode 100644 index 0000000..f623e31 --- /dev/null +++ b/src/test/lama/test100.lama @@ -0,0 +1,11 @@ +fun f (x) { + fun inner (y) { + if y == 0 then 0 else inner (y-1) fi + } + + inner (x) +} + +var n = read (); + +write (f (5)) \ No newline at end of file diff --git a/src/test/lama/test100.t b/src/test/lama/test100.t new file mode 100644 index 0000000..21ab731 --- /dev/null +++ b/src/test/lama/test100.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test100.lama < test100.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test101.input b/src/test/lama/test101.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test101.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test101.lama b/src/test/lama/test101.lama new file mode 100644 index 0000000..fdbc02b --- /dev/null +++ b/src/test/lama/test101.lama @@ -0,0 +1,15 @@ +fun f (x) { + fun inner1 (y) { + if y == 0 then 0 else inner2 (y-1) fi + } + + fun inner2 (y) { + if y == 0 then 0 else inner1 (y-1) fi + } + + inner1 (x) +} + +var n = read (); + +write (f (5)) \ No newline at end of file diff --git a/src/test/lama/test101.t b/src/test/lama/test101.t new file mode 100644 index 0000000..62f822d --- /dev/null +++ b/src/test/lama/test101.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test101.lama < test101.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test102.input b/src/test/lama/test102.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test102.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test102.lama b/src/test/lama/test102.lama new file mode 100644 index 0000000..a0b4fa2 --- /dev/null +++ b/src/test/lama/test102.lama @@ -0,0 +1,9 @@ +fun f (x) { + fun g () { x} + fun h () { g} + g +} + +var n = read (); + +write (f(5)()) \ No newline at end of file diff --git a/src/test/lama/test102.t b/src/test/lama/test102.t new file mode 100644 index 0000000..b56ff18 --- /dev/null +++ b/src/test/lama/test102.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test102.lama < test102.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test103.input b/src/test/lama/test103.input new file mode 100644 index 0000000..8c3cb49 --- /dev/null +++ b/src/test/lama/test103.input @@ -0,0 +1,3 @@ +0 +0 +5 diff --git a/src/test/lama/test103.lama b/src/test/lama/test103.lama new file mode 100644 index 0000000..1bf0489 --- /dev/null +++ b/src/test/lama/test103.lama @@ -0,0 +1,8 @@ +var x; + +do + var n = read (); + x := n +while n <= 0 od; + +write (x) diff --git a/src/test/lama/test103.t b/src/test/lama/test103.t new file mode 100644 index 0000000..b67ea1e --- /dev/null +++ b/src/test/lama/test103.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test103.lama < test103.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test104.input b/src/test/lama/test104.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test104.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test104.lama b/src/test/lama/test104.lama new file mode 100644 index 0000000..d6c9c19 --- /dev/null +++ b/src/test/lama/test104.lama @@ -0,0 +1,5 @@ +var n = read (); + +for var i; i := 0, i<10, i := i + 1 do + write (i) +od \ No newline at end of file diff --git a/src/test/lama/test104.t b/src/test/lama/test104.t new file mode 100644 index 0000000..9a230d2 --- /dev/null +++ b/src/test/lama/test104.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test104.lama < test104.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test105.input b/src/test/lama/test105.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test105.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test105.lama b/src/test/lama/test105.lama new file mode 100644 index 0000000..ad41e94 --- /dev/null +++ b/src/test/lama/test105.lama @@ -0,0 +1,6 @@ +fun f (x) {write (x)} + +var g = eta f, n = read (); + + +g (3) \ No newline at end of file diff --git a/src/test/lama/test105.t b/src/test/lama/test105.t new file mode 100644 index 0000000..f51ca70 --- /dev/null +++ b/src/test/lama/test105.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test105.lama < test105.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test106.input b/src/test/lama/test106.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test106.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test106.lama b/src/test/lama/test106.lama new file mode 100644 index 0000000..5d39010 --- /dev/null +++ b/src/test/lama/test106.lama @@ -0,0 +1,9 @@ +fun f (_) {write (1)} +fun g (h : tl) { + write (h) +} + +var n = read (); + +f (1); +g ({2, 3}) \ No newline at end of file diff --git a/src/test/lama/test106.t b/src/test/lama/test106.t new file mode 100644 index 0000000..bc9a9b6 --- /dev/null +++ b/src/test/lama/test106.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test106.lama < test106.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test107.input b/src/test/lama/test107.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/src/test/lama/test107.input @@ -0,0 +1 @@ +5 diff --git a/src/test/lama/test107.lama b/src/test/lama/test107.lama new file mode 100644 index 0000000..7b29c35 --- /dev/null +++ b/src/test/lama/test107.lama @@ -0,0 +1,7 @@ +var n = read (); + +case 0 of + 0 -> 0 + 0 + 0 +esac; + +write (0) \ No newline at end of file diff --git a/src/test/lama/test107.t b/src/test/lama/test107.t new file mode 100644 index 0000000..603c339 --- /dev/null +++ b/src/test/lama/test107.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test107.lama < test107.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test110.input b/src/test/lama/test110.input new file mode 100644 index 0000000..573541a --- /dev/null +++ b/src/test/lama/test110.input @@ -0,0 +1 @@ +0 diff --git a/src/test/lama/test110.lama b/src/test/lama/test110.lama new file mode 100644 index 0000000..2b61d1f --- /dev/null +++ b/src/test/lama/test110.lama @@ -0,0 +1,16 @@ +var x = [0], y = [0]; + +read (); + +write (x[0]); +write (y[0]); + +if 1 then x[0] else y[0] fi := 10; + +write (x[0]); +write (y[0]); + +if 0 then x[0] else y[0] fi := 100; + +write (x[0]); +write (y[0]) diff --git a/src/test/lama/test110.t b/src/test/lama/test110.t new file mode 100644 index 0000000..7bc8c67 --- /dev/null +++ b/src/test/lama/test110.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test110.lama < test110.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test111.input b/src/test/lama/test111.input new file mode 100644 index 0000000..e69de29 diff --git a/src/test/lama/test111.lama b/src/test/lama/test111.lama new file mode 100644 index 0000000..464e1aa --- /dev/null +++ b/src/test/lama/test111.lama @@ -0,0 +1,21 @@ +import Std; + +fun printString (s) { + var i; + for i := 0, i < s.length, i := i + 1 do + write (s[i]) + od +} + +fun printListConcat ( str_list ) { + printString (stringcat ( str_list )) +} + +var l = { "a" , "b" , "c" , "d" }; +printListConcat (l); + +l := { "ab" }; +printListConcat (l); + +l := {}; +printListConcat (l) \ No newline at end of file diff --git a/src/test/lama/test111.t b/src/test/lama/test111.t new file mode 100644 index 0000000..2579876 --- /dev/null +++ b/src/test/lama/test111.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test111.lama < test111.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test112.input b/src/test/lama/test112.input new file mode 100644 index 0000000..e69de29 diff --git a/src/test/lama/test112.lama b/src/test/lama/test112.lama new file mode 100644 index 0000000..f965c63 --- /dev/null +++ b/src/test/lama/test112.lama @@ -0,0 +1,16 @@ +-- let A (x,y) be A(5,6) in write(x); write(y) ni; +-- case A(5,6) of A(x,y) -> write(x); write(y) esac; +-- let A (x,y) be A(5,6) in .... +-- let A (x,y) be A(5,6) <----- void then ; + +fun f (x) { + write(x) +} + +f(let x = A(1,2) in x[0]); +f(let x = A(1,2) in x[1]); + +let A (x,y) = A(5,6) in let B(z,e) = B(7,8) in write(x); write(y); write(z); write(e); +let A (x,y) = A(5,6) in (let B(z,e) = B(7,8) in write(x); write(y); write(z); write(e)); + +let x = (let x = C(1,2) in x[1]) + (let x = C(1,2) in x[0]) in write(x) diff --git a/src/test/lama/test112.t b/src/test/lama/test112.t new file mode 100644 index 0000000..520d603 --- /dev/null +++ b/src/test/lama/test112.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test112.lama < test112.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test801.input b/src/test/lama/test801.input new file mode 100644 index 0000000..e69de29 diff --git a/src/test/lama/test801.lama b/src/test/lama/test801.lama new file mode 100644 index 0000000..5f17669 --- /dev/null +++ b/src/test/lama/test801.lama @@ -0,0 +1,10 @@ +fun f (a, b, c, d, e) { + var i = d / b; + write (a); + write (b); + write (c); + write (d); + write (e) +} + +f (1, 2, 3, 4, 5) diff --git a/src/test/lama/test801.t b/src/test/lama/test801.t new file mode 100644 index 0000000..f99da3e --- /dev/null +++ b/src/test/lama/test801.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test801.lama < test801.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test802.input b/src/test/lama/test802.input new file mode 100644 index 0000000..e69de29 diff --git a/src/test/lama/test802.lama b/src/test/lama/test802.lama new file mode 100644 index 0000000..f02868f --- /dev/null +++ b/src/test/lama/test802.lama @@ -0,0 +1,15 @@ +fun f (a, b, c, d, e, f, g, h) { + var i = 9, j = 10; + write (a); + write (b); + write (c); + write (d); + write (e); + write (f); + write (g); + write (h); + write (i); + write (j) +} + +f (1, 2, 3, 4, 5, 6, 7, 8) diff --git a/src/test/lama/test802.t b/src/test/lama/test802.t new file mode 100644 index 0000000..df6e1d2 --- /dev/null +++ b/src/test/lama/test802.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test802.lama < test802.input + Error: could not find an interface file for import "Std" + [255] diff --git a/src/test/lama/test803.input b/src/test/lama/test803.input new file mode 100644 index 0000000..e69de29 diff --git a/src/test/lama/test803.lama b/src/test/lama/test803.lama new file mode 100644 index 0000000..454c793 --- /dev/null +++ b/src/test/lama/test803.lama @@ -0,0 +1,18 @@ +fun f (a, b, c, d, e, f, g, h) { + fun g (unit) { + var tmp1 = 1 + (1 + (1 + (1 + (1 + 1 + (1 + (1 + (1 + (1 + 1 + (1 + (1 + (1 + (1 + 1)))))))))))); + var tmp2 = (((((((((((((1 + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1; + write (a); + write (b); + write (c); + write (d); + write (e); + write (f); + write (g); + write (h) + } + + g +} + +f (1, 2, 3, 4, 5, 6, 7, 8)(0) diff --git a/src/test/lama/test803.t b/src/test/lama/test803.t new file mode 100644 index 0000000..61ae4e9 --- /dev/null +++ b/src/test/lama/test803.t @@ -0,0 +1,3 @@ + $ ../src/Driver.exe -i test803.lama < test803.input + Error: could not find an interface file for import "Std" + [255]