about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-16 22:47:28 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-16 22:48:41 -0700
commit100157d1a83ccb02d82af21c5767ecda3d7cb1c2 (patch)
treed540d4a6351473119bf49c4ad03de9856caacc61
parent5df82e48a2548e7d30b3e86dab0d866851a1c47d (diff)
downloadmu-100157d1a83ccb02d82af21c5767ecda3d7cb1c2.tar.gz
939 - c++: fix an old parsing hack
-rw-r--r--cpp/.traces/jump_backward11
-rw-r--r--cpp/.traces/parse_comment_after_instruction3
-rw-r--r--cpp/.traces/parse_comment_amongst_instruction3
-rw-r--r--cpp/.traces/parse_comment_amongst_instruction23
-rw-r--r--cpp/.traces/parse_comment_amongst_instruction36
-rw-r--r--cpp/.traces/parse_comment_outside_recipe3
-rw-r--r--cpp/011load58
-rw-r--r--cpp/015jump9
8 files changed, 81 insertions, 15 deletions
diff --git a/cpp/.traces/jump_backward b/cpp/.traces/jump_backward
index 6d9e433f..48164312 100644
--- a/cpp/.traces/jump_backward
+++ b/cpp/.traces/jump_backward
@@ -1,20 +1,9 @@
 parse/0: instruction: 10
 parse/0:   ingredient: {name: "1", type: 0}
-parse/0:   ingredient: {name: "//", type: }
-parse/0:   ingredient: {name: "0", type: }
-parse/0:   ingredient: {name: "-+", type: }
 parse/0: instruction: 10
 parse/0:   ingredient: {name: "1", type: 0}
-parse/0:   ingredient: {name: "//", type: }
-parse/0:   ingredient: {name: "|", type: }
-parse/0:   ingredient: {name: "1", type: }
-parse/0:   ingredient: {name: "+-+", type: }
 parse/0: instruction: 10
 parse/0:   ingredient: {name: "-2", type: 0}
-parse/0:   ingredient: {name: "//", type: }
-parse/0:   ingredient: {name: "2", type: }
-parse/0:   ingredient: {name: "+-->+", type: }
-parse/0:   ingredient: {name: "|", type: }
 run/0: instruction main/0
 run/0: ingredient 0 is 1
 run/0: instruction main/2
diff --git a/cpp/.traces/parse_comment_after_instruction b/cpp/.traces/parse_comment_after_instruction
new file mode 100644
index 00000000..d20319d2
--- /dev/null
+++ b/cpp/.traces/parse_comment_after_instruction
@@ -0,0 +1,3 @@
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "23", type: 0}
+parse/0:   product: {name: "1", type: 1}
diff --git a/cpp/.traces/parse_comment_amongst_instruction b/cpp/.traces/parse_comment_amongst_instruction
new file mode 100644
index 00000000..d20319d2
--- /dev/null
+++ b/cpp/.traces/parse_comment_amongst_instruction
@@ -0,0 +1,3 @@
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "23", type: 0}
+parse/0:   product: {name: "1", type: 1}
diff --git a/cpp/.traces/parse_comment_amongst_instruction2 b/cpp/.traces/parse_comment_amongst_instruction2
new file mode 100644
index 00000000..d20319d2
--- /dev/null
+++ b/cpp/.traces/parse_comment_amongst_instruction2
@@ -0,0 +1,3 @@
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "23", type: 0}
+parse/0:   product: {name: "1", type: 1}
diff --git a/cpp/.traces/parse_comment_amongst_instruction3 b/cpp/.traces/parse_comment_amongst_instruction3
new file mode 100644
index 00000000..7b755615
--- /dev/null
+++ b/cpp/.traces/parse_comment_amongst_instruction3
@@ -0,0 +1,6 @@
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "23", type: 0}
+parse/0:   product: {name: "1", type: 1}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "23", type: 0}
+parse/0:   product: {name: "2", type: 1}
diff --git a/cpp/.traces/parse_comment_outside_recipe b/cpp/.traces/parse_comment_outside_recipe
new file mode 100644
index 00000000..d20319d2
--- /dev/null
+++ b/cpp/.traces/parse_comment_outside_recipe
@@ -0,0 +1,3 @@
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "23", type: 0}
+parse/0:   product: {name: "1", type: 1}
diff --git a/cpp/011load b/cpp/011load
index 9806bfd0..d01c72d2 100644
--- a/cpp/011load
+++ b/cpp/011load
@@ -109,6 +109,8 @@ string next_word(istream& in) {
   ostringstream out;
   skip_whitespace(in);
   slurp_word(in, out);
+  skip_whitespace(in);
+  skip_comment(in);
   return out.str();
 }
 
@@ -144,12 +146,68 @@ void skip_comments_and_newlines(istream& in) {
   }
 }
 
+void skip_comment(istream& in) {
+  if (in.peek() == '#') {
+    in.get();
+    while (in.peek() != '\n') in.get();
+  }
+}
+
 void skip_comma(istream& in) {
   skip_whitespace(in);
   if (in.peek() == ',') in.get();
   skip_whitespace(in);
 }
 
+:(scenario parse_comment_outside_recipe)
+# comment
+recipe main [
+  1:integer <- copy 23:literal
+]
++parse: instruction: 1
++parse:   ingredient: {name: "23", type: 0}
++parse:   product: {name: "1", type: 1}
+
+:(scenario parse_comment_amongst_instruction)
+recipe main [
+  # comment
+  1:integer <- copy 23:literal
+]
++parse: instruction: 1
++parse:   ingredient: {name: "23", type: 0}
++parse:   product: {name: "1", type: 1}
+
+:(scenario parse_comment_amongst_instruction2)
+recipe main [
+  # comment
+  1:integer <- copy 23:literal
+  # comment
+]
++parse: instruction: 1
++parse:   ingredient: {name: "23", type: 0}
++parse:   product: {name: "1", type: 1}
+
+:(scenario parse_comment_amongst_instruction3)
+recipe main [
+  1:integer <- copy 23:literal
+  # comment
+  2:integer <- copy 23:literal
+]
++parse: instruction: 1
++parse:   ingredient: {name: "23", type: 0}
++parse:   product: {name: "1", type: 1}
++parse: instruction: 1
++parse:   ingredient: {name: "23", type: 0}
++parse:   product: {name: "2", type: 1}
+
+:(scenario parse_comment_after_instruction)
+recipe main [
+  1:integer <- copy 23:literal # comment
+]
++parse: instruction: 1
++parse:   ingredient: {name: "23", type: 0}
++parse:   product: {name: "1", type: 1}
+
 :(scenario parse_label)
 recipe main [
   +foo
diff --git a/cpp/015jump b/cpp/015jump
index 5b4a9624..2ce18859 100644
--- a/cpp/015jump
+++ b/cpp/015jump
@@ -24,10 +24,11 @@ recipe main [
 
 :(scenario "jump_backward")
 recipe main [
-  jump 1:offset  // 0 -+
-  jump 1:offset  //    | 1 +-+
-  jump -2:offset //  2 +-->+ |
-]                //       3 \/
+  jump 1:offset  # 0 -+
+  jump 1:offset  #    |   +-+ 1
+                 #   \/  /\ |
+  jump -2:offset #  2 +-->+ |
+]                #         \/ 3
 +run: instruction main/0
 +run: instruction main/2
 +run: instruction main/1
> 2010-02-15 21:40:47 +0100 updated README' href='/akspecs/ranger/commit/README?h=v1.5.2&id=4ea0f69aed8d4c173d9abbd0a1bd76d6afe69ccb'>4ea0f69a ^
0a32b684 ^
4ea0f69a ^


0a32b684 ^

4ea0f69a ^



36e4e71e ^
7582555b ^
36e4e71e ^
7582555b ^








36e4e71e ^
4ea0f69a ^


36e4e71e ^




4ea0f69a ^
e71c8103 ^

36e4e71e ^

f6ae504c ^
4ea0f69a ^
36e4e71e ^

4ea0f69a ^

36e4e71e ^






4ea0f69a ^

306c76d8 ^






b6aff4c3 ^

306c76d8 ^
4ea0f69a ^

45cf5174 ^

08bc4ef9 ^

b34fd133 ^
08bc4ef9 ^











b34fd133 ^
08bc4ef9 ^


45cf5174 ^





fab4dc54 ^
45cf5174 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156