emfrp 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +45 -12
  3. data/bin/emfrp +4 -1
  4. data/examples/LCDClock/LCDClock.mfrp +93 -93
  5. data/examples/LCDClock/LCDClock_LPC1768.bin +0 -0
  6. data/examples/LCDClock/README.md +24 -24
  7. data/examples/LCDPositioner/LCDPositioner.mfrp +30 -30
  8. data/examples/LCDPositioner/LCDPositionerMain.c +15 -15
  9. data/examples/MostDistantPoint/MostDistantPoint.mfrp +25 -25
  10. data/examples/MostDistantPoint/MostDistantPointMain.c +14 -14
  11. data/lib/emfrp/compile/c/alloc.rb +200 -200
  12. data/lib/emfrp/compile/c/codegen.rb +18 -18
  13. data/lib/emfrp/compile/c/codegen_context.rb +218 -218
  14. data/lib/emfrp/compile/c/monofy.rb +185 -185
  15. data/lib/emfrp/compile/c/syntax_codegen.rb +364 -364
  16. data/lib/emfrp/compile/c/syntax_exp_codegen.rb +119 -119
  17. data/lib/emfrp/compile/graphviz/graphviz.rb +53 -53
  18. data/lib/emfrp/compile_error.rb +95 -95
  19. data/lib/emfrp/interpreter/command_manager.rb +367 -367
  20. data/lib/emfrp/interpreter/evaluater.rb +146 -146
  21. data/lib/emfrp/interpreter/file_loader.rb +52 -52
  22. data/lib/emfrp/interpreter/interpreter.rb +200 -195
  23. data/lib/emfrp/parser/expression.rb +386 -386
  24. data/lib/emfrp/parser/misc.rb +184 -184
  25. data/lib/emfrp/parser/newnode_convert.rb +72 -72
  26. data/lib/emfrp/parser/operator.rb +25 -25
  27. data/lib/emfrp/parser/parser.rb +150 -150
  28. data/lib/emfrp/parser/parsing_error.rb +49 -49
  29. data/lib/emfrp/parser/toplevel.rb +555 -555
  30. data/lib/emfrp/pre_convert/pre_convert.rb +32 -32
  31. data/lib/emfrp/syntax.rb +171 -171
  32. data/lib/emfrp/typing/typing_error.rb +47 -47
  33. data/lib/emfrp/typing/union_type.rb +197 -197
  34. data/lib/emfrp/version.rb +1 -1
  35. data/mfrp_include/Std.mfrp +122 -122
  36. data/tests/Rakefile +8 -8
  37. data/tests/Rakefile.common +27 -27
  38. data/tests/command/Rakefile +2 -2
  39. data/tests/command/ReplaceNode.mfrp +39 -39
  40. data/tests/compiler/ComplexDataType/ComplexDataType.mfrp +14 -14
  41. data/tests/compiler/ComplexDataType/ComplexDataTypeMain.c +15 -15
  42. data/tests/compiler/ComplexDataType/Rakefile +2 -2
  43. data/tests/compiler/ComplexDataType/expected_out.txt +0 -0
  44. data/tests/compiler/ComplexDataType/in.txt +5 -5
  45. data/tests/compiler/LCDClock/LCDClock.mfrp +90 -90
  46. data/tests/compiler/LCDClock/LCDClockMain.c +0 -0
  47. data/tests/compiler/LCDClock/Rakefile +2 -2
  48. data/tests/compiler/LCDClock/expected_out.txt +0 -0
  49. data/tests/compiler/LCDClock/in.txt +0 -0
  50. data/tests/compiler/LCDPositioner/LCDPositioner.mfrp +30 -30
  51. data/tests/compiler/LCDPositioner/LCDPositionerMain.c +15 -15
  52. data/tests/compiler/LCDPositioner/Rakefile +2 -2
  53. data/tests/compiler/LCDPositioner/graph.dot +0 -0
  54. data/tests/compiler/LCDPositioner/graph.png +0 -0
  55. data/tests/compiler/Rakefile +8 -8
  56. data/tests/compiler/Rakefile.common +23 -23
  57. data/tests/compiler/UseData/Rakefile +2 -2
  58. data/tests/compiler/UseData/UseData.mfrp +8 -8
  59. data/tests/compiler/UseSubModule/Rakefile +2 -2
  60. data/tests/compiler/UseSubModule/SubModule.mfrp +8 -8
  61. data/tests/compiler/UseSubModule/SubModule2.mfrp +5 -5
  62. data/tests/compiler/UseSubModule/UseSubModule.mfrp +11 -11
  63. data/tests/core/FromAnnotation.mfrp +18 -18
  64. data/tests/core/Last.mfrp +10 -10
  65. data/tests/core/Rakefile +2 -2
  66. data/tests/core/TypingTest.mfrp +11 -11
  67. data/tests/core/WithoutInputs.mfrp +19 -19
  68. data/tests/load_time_error/Rakefile +32 -32
  69. data/tests/load_time_error/TypeMismatch.mfrp +4 -4
  70. metadata +3 -3
@@ -1,27 +1,27 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
- require 'emfrp'
3
-
4
- TARGETS = Dir.glob("./*.mfrp").map{|x| x =~ /^\.\/(.*).mfrp$/; $1}
5
-
6
- def exec_test(file_name)
7
- puts "TESTING #{file_name}".colorize(:light_blue)
8
- inter = Emfrp::Interpreter.new(Emfrp::IncludeDirs, STDOUT, file_name)
9
- unless inter.exec_embedded_commands(true)
10
- puts " => ok".colorize(:green)
11
- else
12
- puts " => fail".colorize(:red)
13
- end
14
- rescue => err
15
- puts err.inspect
16
- puts " => fail".colorize(:red)
17
- end
18
-
19
- TARGETS.each do |t|
20
- file t do
21
- exec_test(t)
22
- end
23
- end
24
-
25
- file "Std" do
26
- exec_test("Std")
27
- end
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'emfrp'
3
+
4
+ TARGETS = Dir.glob("./*.mfrp").map{|x| x =~ /^\.\/(.*).mfrp$/; $1}
5
+
6
+ def exec_test(file_name)
7
+ puts "TESTING #{file_name}".colorize(:light_blue)
8
+ inter = Emfrp::Interpreter.new(Emfrp::IncludeDirs, STDOUT, file_name)
9
+ unless inter.exec_embedded_commands(true)
10
+ puts " => ok".colorize(:green)
11
+ else
12
+ puts " => fail".colorize(:red)
13
+ end
14
+ rescue => err
15
+ puts err.inspect
16
+ puts " => fail".colorize(:red)
17
+ end
18
+
19
+ TARGETS.each do |t|
20
+ file t do
21
+ exec_test(t)
22
+ end
23
+ end
24
+
25
+ file "Std" do
26
+ exec_test("Std")
27
+ end
@@ -1,2 +1,2 @@
1
- load File.expand_path('../../Rakefile.common', __FILE__)
2
- task :default => TARGETS
1
+ load File.expand_path('../../Rakefile.common', __FILE__)
2
+ task :default => TARGETS
@@ -1,39 +1,39 @@
1
- module ReplaceNodeCommand in x : Int out y use Std
2
-
3
- node a = x + 1
4
- node b = a + 1
5
- node c = b + 1
6
-
7
- node i = x + 2
8
- node j = i + 2
9
- node k = j + 2
10
-
11
- node z = 1.0
12
-
13
- node init[0] p = 1
14
- node q = 0
15
-
16
- node y = c
17
-
18
- #@ :assert-error replace_node_err1 =>
19
- #- :replace-node hoge => b
20
-
21
- #@ :assert-error replace_node_err2 =>
22
- #- :replace-node b => hoge
23
-
24
- #@ :assert-error replace_node_err3 =>
25
- #- :replace-node b => z
26
-
27
- #@ :assert-error replace_node_err4 =>
28
- #- :replace-node c => b
29
-
30
- #@ :assert-error replace_node_err4 =>
31
- #- :replace-node a => b
32
-
33
- #@ :assert-error replace_node_err5 =>
34
- #- :replace-node p => q
35
-
36
- #@ :replace-node b => j
37
- #@ :assert-module
38
- #- 0 => 5
39
- #@ : 1 => 6
1
+ module ReplaceNodeCommand in x : Int out y use Std
2
+
3
+ node a = x + 1
4
+ node b = a + 1
5
+ node c = b + 1
6
+
7
+ node i = x + 2
8
+ node j = i + 2
9
+ node k = j + 2
10
+
11
+ node z = 1.0
12
+
13
+ node init[0] p = 1
14
+ node q = 0
15
+
16
+ node y = c
17
+
18
+ #@ :assert-error replace_node_err1 =>
19
+ #- :replace-node hoge => b
20
+
21
+ #@ :assert-error replace_node_err2 =>
22
+ #- :replace-node b => hoge
23
+
24
+ #@ :assert-error replace_node_err3 =>
25
+ #- :replace-node b => z
26
+
27
+ #@ :assert-error replace_node_err4 =>
28
+ #- :replace-node c => b
29
+
30
+ #@ :assert-error replace_node_err4 =>
31
+ #- :replace-node a => b
32
+
33
+ #@ :assert-error replace_node_err5 =>
34
+ #- :replace-node p => q
35
+
36
+ #@ :replace-node b => j
37
+ #@ :assert-module
38
+ #- 0 => 5
39
+ #@ : 1 => 6
@@ -1,14 +1,14 @@
1
- module ComplexDataType
2
- in i : Int
3
- out out1, out2
4
- use Std
5
-
6
- node x = ((i, i), (i, i), (i, i))
7
-
8
- node y = {
9
- ii = i.intToDouble
10
- ((ii, ii), (ii, ii), (ii, ii))
11
- }
12
-
13
- node out1 = x of ((a, _), _, _) -> a
14
- node out2 = y of ((a, _), _, _) -> a
1
+ module ComplexDataType
2
+ in i : Int
3
+ out out1, out2
4
+ use Std
5
+
6
+ node x = ((i, i), (i, i), (i, i))
7
+
8
+ node y = {
9
+ ii = i.intToDouble
10
+ ((ii, ii), (ii, ii), (ii, ii))
11
+ }
12
+
13
+ node out1 = x of ((a, _), _, _) -> a
14
+ node out2 = y of ((a, _), _, _) -> a
@@ -1,15 +1,15 @@
1
- #include "ComplexDataType.h"
2
- #include <stdio.h>
3
- #include <stdlib.h>
4
-
5
- void Input(int* i) {
6
- if (scanf("%d", i) == EOF) {
7
- exit(0);
8
- }
9
- }
10
- void Output(int* out1, double* out2) {
11
- printf("%d %.3lf\n", *out1, *out2);
12
- }
13
- int main() {
14
- ActivateComplexDataType();
15
- }
1
+ #include "ComplexDataType.h"
2
+ #include <stdio.h>
3
+ #include <stdlib.h>
4
+
5
+ void Input(int* i) {
6
+ if (scanf("%d", i) == EOF) {
7
+ exit(0);
8
+ }
9
+ }
10
+ void Output(int* out1, double* out2) {
11
+ printf("%d %.3lf\n", *out1, *out2);
12
+ }
13
+ int main() {
14
+ ActivateComplexDataType();
15
+ }
@@ -1,2 +1,2 @@
1
- NAME = "ComplexDataType"
2
- load File.expand_path('../../Rakefile.common', __FILE__)
1
+ NAME = "ComplexDataType"
2
+ load File.expand_path('../../Rakefile.common', __FILE__)
File without changes
@@ -1,5 +1,5 @@
1
- 1
2
- 2
3
- 3
4
- 4
5
- 5
1
+ 1
2
+ 2
3
+ 3
4
+ 4
5
+ 5
@@ -1,90 +1,90 @@
1
- module LCDClock
2
- in
3
- btnMode(False) : Bool, # Is mode-button pushed now?
4
- btnNext(False) : Bool, # Is next-button pushed now?
5
- btnRotate(False) : Bool, # Is rotate-button pushed now?
6
- pulse100ms : Bool # input to be True only once per 100ms
7
- out
8
- hour, min, sec, # current time to display
9
- maskHour, maskMin, maskSec # Is it now needed to display -- instead of two-digits?
10
- use
11
- Std
12
-
13
- # Functions
14
- # --------------------
15
-
16
- type Mode = Normal | Edit
17
- type TPos = HPos | MPos | SPos
18
- type Time = Time(Int, Int, Int)
19
-
20
- func nextMode(m) = m of Normal -> Edit, Edit -> Normal
21
-
22
- func editable(m) = m of Normal -> False, Edit -> True
23
-
24
- func nextPos(p) = p of HPos -> MPos, MPos -> SPos, SPos -> HPos
25
-
26
- func positiveEdge(a, b) = !a && b
27
-
28
- # proceed Time by 1sec
29
- func proceedTime(t) = {
30
- Time(h, m, s) = t
31
- newS = s + 1
32
- newM = m + (newS / 60)
33
- newH = h + (newM / 60)
34
- Time(newH % 24, newM % 60, newS % 60)
35
- }
36
-
37
- func roundingTime(t, dh, dm, ds) = {
38
- Time(h, m, s) = t
39
- Time((h + dh) % 24, (m + dm) % 60, (s + ds) % 60)
40
- }
41
-
42
- # Nodes
43
- # --------------------
44
-
45
- # mod-10 counter incremented by every 100ms
46
- node init[0] counter : Int =
47
- (if pulse100ms then counter@last + 1 else counter@last) % 10
48
-
49
- # time-varying value to be True only once per 1sec
50
- node pulse1s : Bool =
51
- counter == 0 && counter@last != 0
52
-
53
- # time-varying value switching True/False by every 500ms
54
- node flash : Bool =
55
- counter < 5
56
-
57
- # time-varying value representing current time-set mode
58
- node init[Normal] curMode : Mode =
59
- if btnMode@last `positiveEdge` btnMode then curMode@last.nextMode else curMode@last
60
-
61
- # time-varying value representing current editing-cursor-position
62
- node init[HPos] curPos : TPos =
63
- if btnNext@last `positiveEdge` btnNext then curPos@last.nextPos else curPos@last
64
-
65
- # time-varying value representing diffs to add to current time.
66
- node (dh, dm, ds) : (Int, Int, Int) =
67
- if curMode.editable && (btnRotate@last `positiveEdge` btnRotate) then
68
- curPos of:
69
- HPos -> (1, 0, 0)
70
- MPos -> (0, 1, 0)
71
- SPos -> (0, 0, 1)
72
- else
73
- (0, 0, 0)
74
-
75
- # time-varying value representing current time
76
- node init[Time(0, 0, 0)] Time(hour, min, sec) as curTime =
77
- if pulse1s then
78
- curTime@last.proceedTime.roundingTime(dh, dm, ds)
79
- else
80
- curTime@last.roundingTime(dh, dm, ds)
81
-
82
- # time-varying value representing need of masking
83
- node (maskHour, maskMin, maskSec) =
84
- if curMode.editable && flash then
85
- curPos of:
86
- HPos -> (True, False, False)
87
- MPos -> (False, True, False)
88
- SPos -> (False, False, True)
89
- else
90
- (False, False, False)
1
+ module LCDClock
2
+ in
3
+ btnMode(False) : Bool, # Is mode-button pushed now?
4
+ btnNext(False) : Bool, # Is next-button pushed now?
5
+ btnRotate(False) : Bool, # Is rotate-button pushed now?
6
+ pulse100ms : Bool # input to be True only once per 100ms
7
+ out
8
+ hour, min, sec, # current time to display
9
+ maskHour, maskMin, maskSec # Is it now needed to display -- instead of two-digits?
10
+ use
11
+ Std
12
+
13
+ # Functions
14
+ # --------------------
15
+
16
+ type Mode = Normal | Edit
17
+ type TPos = HPos | MPos | SPos
18
+ type Time = Time(Int, Int, Int)
19
+
20
+ func nextMode(m) = m of Normal -> Edit, Edit -> Normal
21
+
22
+ func editable(m) = m of Normal -> False, Edit -> True
23
+
24
+ func nextPos(p) = p of HPos -> MPos, MPos -> SPos, SPos -> HPos
25
+
26
+ func positiveEdge(a, b) = !a && b
27
+
28
+ # proceed Time by 1sec
29
+ func proceedTime(t) = {
30
+ Time(h, m, s) = t
31
+ newS = s + 1
32
+ newM = m + (newS / 60)
33
+ newH = h + (newM / 60)
34
+ Time(newH % 24, newM % 60, newS % 60)
35
+ }
36
+
37
+ func roundingTime(t, dh, dm, ds) = {
38
+ Time(h, m, s) = t
39
+ Time((h + dh) % 24, (m + dm) % 60, (s + ds) % 60)
40
+ }
41
+
42
+ # Nodes
43
+ # --------------------
44
+
45
+ # mod-10 counter incremented by every 100ms
46
+ node init[0] counter : Int =
47
+ (if pulse100ms then counter@last + 1 else counter@last) % 10
48
+
49
+ # time-varying value to be True only once per 1sec
50
+ node pulse1s : Bool =
51
+ counter == 0 && counter@last != 0
52
+
53
+ # time-varying value switching True/False by every 500ms
54
+ node flash : Bool =
55
+ counter < 5
56
+
57
+ # time-varying value representing current time-set mode
58
+ node init[Normal] curMode : Mode =
59
+ if btnMode@last `positiveEdge` btnMode then curMode@last.nextMode else curMode@last
60
+
61
+ # time-varying value representing current editing-cursor-position
62
+ node init[HPos] curPos : TPos =
63
+ if btnNext@last `positiveEdge` btnNext then curPos@last.nextPos else curPos@last
64
+
65
+ # time-varying value representing diffs to add to current time.
66
+ node (dh, dm, ds) : (Int, Int, Int) =
67
+ if curMode.editable && (btnRotate@last `positiveEdge` btnRotate) then
68
+ curPos of:
69
+ HPos -> (1, 0, 0)
70
+ MPos -> (0, 1, 0)
71
+ SPos -> (0, 0, 1)
72
+ else
73
+ (0, 0, 0)
74
+
75
+ # time-varying value representing current time
76
+ node init[Time(0, 0, 0)] Time(hour, min, sec) as curTime =
77
+ if pulse1s then
78
+ curTime@last.proceedTime.roundingTime(dh, dm, ds)
79
+ else
80
+ curTime@last.roundingTime(dh, dm, ds)
81
+
82
+ # time-varying value representing need of masking
83
+ node (maskHour, maskMin, maskSec) =
84
+ if curMode.editable && flash then
85
+ curPos of:
86
+ HPos -> (True, False, False)
87
+ MPos -> (False, True, False)
88
+ SPos -> (False, False, True)
89
+ else
90
+ (False, False, False)
File without changes
@@ -1,2 +1,2 @@
1
- NAME = "LCDClock"
2
- load File.expand_path('../../Rakefile.common', __FILE__)
1
+ NAME = "LCDClock"
2
+ load File.expand_path('../../Rakefile.common', __FILE__)
File without changes
File without changes
@@ -1,30 +1,30 @@
1
- module LCDPositioner
2
- in
3
- up : Bool,
4
- down : Bool,
5
- left : Bool,
6
- right : Bool,
7
- pulse10ms : Bool
8
- out
9
- x, y
10
- use
11
- Std
12
-
13
- node dy = down.boolToInt - up.boolToInt
14
- node dx = right.boolToInt - left.boolToInt
15
-
16
- node init[(False, 0)] (pulse40ms, pulse40msCount) as pulse = {
17
- c = (pulse40msCount@last + pulse10ms.boolToInt) % 4
18
- (c == 0 && pulse10ms, c)
19
- }
20
-
21
- node init[(0,0)] (x, y) as pos =
22
- if pulse40ms then (x@last + dx, y@last + dy) else pos@last
23
-
24
-
25
- #@ :assert-module
26
- #- True, False, False, False, True => 0, 0
27
- #@ : True, False, False, False, True => 0, 0
28
- #@ : True, False, False, False, True => 0, 0
29
- #@ : True, False, False, False, True => 0, -1
30
- #@ : True, False, False, False, True => 0, -1
1
+ module LCDPositioner
2
+ in
3
+ up : Bool,
4
+ down : Bool,
5
+ left : Bool,
6
+ right : Bool,
7
+ pulse10ms : Bool
8
+ out
9
+ x, y
10
+ use
11
+ Std
12
+
13
+ node dy = down.boolToInt - up.boolToInt
14
+ node dx = right.boolToInt - left.boolToInt
15
+
16
+ node init[(False, 0)] (pulse40ms, pulse40msCount) as pulse = {
17
+ c = (pulse40msCount@last + pulse10ms.boolToInt) % 4
18
+ (c == 0 && pulse10ms, c)
19
+ }
20
+
21
+ node init[(0,0)] (x, y) as pos =
22
+ if pulse40ms then (x@last + dx, y@last + dy) else pos@last
23
+
24
+
25
+ #@ :assert-module
26
+ #- True, False, False, False, True => 0, 0
27
+ #@ : True, False, False, False, True => 0, 0
28
+ #@ : True, False, False, False, True => 0, 0
29
+ #@ : True, False, False, False, True => 0, -1
30
+ #@ : True, False, False, False, True => 0, -1
@@ -1,15 +1,15 @@
1
- #include "LCDPositioner.h"
2
- #include <stdio.h>
3
- #include <stdlib.h>
4
-
5
- void Input(int* up, int* down, int* left, int* right, int* pulse10ms) {
6
- if (scanf("%d %d %d %d %d", up, down, left, right, pulse10ms) == EOF) {
7
- exit(0);
8
- }
9
- }
10
- void Output(int* x, int* y) {
11
- printf("%d %d\n", *x, *y);
12
- }
13
- int main() {
14
- ActivateLCDPositioner();
15
- }
1
+ #include "LCDPositioner.h"
2
+ #include <stdio.h>
3
+ #include <stdlib.h>
4
+
5
+ void Input(int* up, int* down, int* left, int* right, int* pulse10ms) {
6
+ if (scanf("%d %d %d %d %d", up, down, left, right, pulse10ms) == EOF) {
7
+ exit(0);
8
+ }
9
+ }
10
+ void Output(int* x, int* y) {
11
+ printf("%d %d\n", *x, *y);
12
+ }
13
+ int main() {
14
+ ActivateLCDPositioner();
15
+ }
@@ -1,2 +1,2 @@
1
- NAME = "LCDPositioner"
2
- load File.expand_path('../../Rakefile.common', __FILE__)
1
+ NAME = "LCDPositioner"
2
+ load File.expand_path('../../Rakefile.common', __FILE__)
File without changes
File without changes
@@ -1,8 +1,8 @@
1
- task :default do
2
- Dir.glob("[a-zA-Z0-9_]*") do |d|
3
- Dir.chdir(d) do
4
- puts "moved into directory `#{d}'"
5
- sh "rake"
6
- end if Dir.exist?(d)
7
- end
8
- end
1
+ task :default do
2
+ Dir.glob("[a-zA-Z0-9_]*") do |d|
3
+ Dir.chdir(d) do
4
+ puts "moved into directory `#{d}'"
5
+ sh "rake"
6
+ end if Dir.exist?(d)
7
+ end
8
+ end
@@ -1,23 +1,23 @@
1
- $LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
2
- require 'emfrp'
3
-
4
- task :default do
5
- begin
6
- puts "TESTING #{NAME}".colorize(:light_blue)
7
- sh "../../../bin/emfrp #{NAME}.mfrp"
8
- sh "cc -c #{NAME}.c"
9
- sh "cc -c #{NAME}Main.c"
10
- sh "cc #{NAME}.o #{NAME}Main.o -o #{NAME}"
11
- sh "./#{NAME} < in.txt > actual_out.txt"
12
- sh "rm #{NAME}Main.c.gen"
13
- sh "rm #{NAME}.c"
14
- sh "rm #{NAME}.h"
15
- sh "rm #{NAME}.o"
16
- sh "rm #{NAME}Main.o"
17
- sh "rm #{NAME}"
18
- sh "diff expected_out.txt actual_out.txt -u"
19
- puts " => ok".colorize(:green)
20
- rescue
21
- puts " => fail".colorize(:red)
22
- end
23
- end
1
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
2
+ require 'emfrp'
3
+
4
+ task :default do
5
+ begin
6
+ puts "TESTING #{NAME}".colorize(:light_blue)
7
+ sh "../../../bin/emfrp #{NAME}.mfrp"
8
+ sh "cc -c #{NAME}.c"
9
+ sh "cc -c #{NAME}Main.c"
10
+ sh "cc #{NAME}.o #{NAME}Main.o -o #{NAME}"
11
+ sh "./#{NAME} < in.txt > actual_out.txt"
12
+ sh "rm #{NAME}Main.c.gen"
13
+ sh "rm #{NAME}.c"
14
+ sh "rm #{NAME}.h"
15
+ sh "rm #{NAME}.o"
16
+ sh "rm #{NAME}Main.o"
17
+ sh "rm #{NAME}"
18
+ sh "diff expected_out.txt actual_out.txt -u"
19
+ puts " => ok".colorize(:green)
20
+ rescue
21
+ puts " => fail".colorize(:red)
22
+ end
23
+ end
@@ -1,2 +1,2 @@
1
- NAME = "UseData"
2
- load File.expand_path('../../Rakefile.common', __FILE__)
1
+ NAME = "UseData"
2
+ load File.expand_path('../../Rakefile.common', __FILE__)
@@ -1,8 +1,8 @@
1
- module UseData out x use Std
2
-
3
-
4
- data one = 1 # one
5
- data two = one + 1 # two
6
- data three = two + 1 # three
7
-
8
- node x = three
1
+ module UseData out x use Std
2
+
3
+
4
+ data one = 1 # one
5
+ data two = one + 1 # two
6
+ data three = two + 1 # three
7
+
8
+ node x = three
@@ -1,2 +1,2 @@
1
- NAME = "UseSubModule"
2
- load File.expand_path('../../Rakefile.common', __FILE__)
1
+ NAME = "UseSubModule"
2
+ load File.expand_path('../../Rakefile.common', __FILE__)
@@ -1,8 +1,8 @@
1
- module SubModule
2
- in i1 : Int, i2 : Int
3
- out x, y
4
- use Std
5
-
6
- newnode a = SubModule2(i1)
7
- node x = a * i2
8
- node init[0] y = y@last + i2
1
+ module SubModule
2
+ in i1 : Int, i2 : Int
3
+ out x, y
4
+ use Std
5
+
6
+ newnode a = SubModule2(i1)
7
+ node x = a * i2
8
+ node init[0] y = y@last + i2
@@ -1,5 +1,5 @@
1
- module SubModule2
2
- in x : Int
3
- out y
4
-
5
- node y = x
1
+ module SubModule2
2
+ in x : Int
3
+ out y
4
+
5
+ node y = x
@@ -1,11 +1,11 @@
1
- module UseSubModule
2
- in x : Int
3
- out a1, b1, a2, b2
4
- use Std
5
-
6
- newnode a1, b1 = SubModule(x, 2)
7
- newnode a2, b2 = SubModule(x + 1, 3)
8
-
9
- #@ :assert-module
10
- #- 0 => 0, 2, 3, 3
11
- #@ : 1 => 2, 4, 6, 6
1
+ module UseSubModule
2
+ in x : Int
3
+ out a1, b1, a2, b2
4
+ use Std
5
+
6
+ newnode a1, b1 = SubModule(x, 2)
7
+ newnode a2, b2 = SubModule(x + 1, 3)
8
+
9
+ #@ :assert-module
10
+ #- 0 => 0, 2, 3, 3
11
+ #@ : 1 => 2, 4, 6, 6