about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-02-16 17:08:49 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-02-16 17:08:49 -0800
commitf1e1cac414c34449113ca7196ceb82cbcbb2517f (patch)
tree1b5faad9841e501fee69d991497929b26c59cc15
parent5963dacdb07100af6662a5b0366b3fca18e4c2fb (diff)
downloadmu-f1e1cac414c34449113ca7196ceb82cbcbb2517f.tar.gz
768
-rw-r--r--cpp/002main.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/cpp/002main.cc b/cpp/002main.cc
index f042dbd5..1476150c 100644
--- a/cpp/002main.cc
+++ b/cpp/002main.cc
@@ -154,13 +154,28 @@ void compile(string form) {
   istringstream in(form);
   in >> std::noskipws;
 
-  if (next_word(in) != "recipe")
-    raise << "top-level forms must be of the form 'recipe _name_ [ _instruction_ ... ]'";
+  string _recipe = next_word(in);
+//?   cout << _recipe << '\n'; //? 1
+  if (_recipe != "recipe")
+    raise << "top-level forms must be of the form 'recipe _name_ [ _instruction_ ... ]'\n";
 
   string recipe_name = next_word(in);
+//?   cout << '^' << recipe_name << "$\n"; //? 1
   if (recipe_name.empty())
     raise << "empty recipe name in " << form << '\n';
   int r = Recipe_number[recipe_name] = Next_recipe_number++;
+
+//?   string foo = next_word(in); //? 1
+//?   cout << '^' << foo << "$ (" << foo.size() << ")\n"; //? 1
+  if (next_word(in) != "[")
+    raise << "recipe body must begin with '['\n";
+
+  skip_newlines(in);
+
+  instruction curr;
+//?   while (next_instruction(in, &curr)) { //? 1
+//?     Recipe[r].step.push_back(curr); //? 1
+//?   } //? 1
 }
 
 bool next_instruction(istream& in, instruction* curr) {
@@ -171,8 +186,11 @@ bool next_instruction(istream& in, instruction* curr) {
 
 string next_word(istream& in) {
   ostringstream out;
+//?   cout << "1: " << (int)in.peek() << '\n'; //? 1
   skip_whitespace(in);
+//?   cout << "2: " << (int)in.peek() << '\n'; //? 1
   slurp_word(in, out);
+//?   cout << "3: " << (int)in.peek() << '\n'; //? 1
 //?   cout << out.str() << '\n'; //? 1
   return out.str();
 }
@@ -181,7 +199,7 @@ void slurp_word(istream& in, ostream& out) {
   char c;
   while (in >> c) {
 //?     cout << c << '\n'; //? 1
-    if (isspace(c) && c != '\n' && c != ',') {
+    if (isspace(c) || c == ',') {
 //?       cout << "  space\n"; //? 1
       in.putback(c);
       break;
@@ -191,8 +209,10 @@ void slurp_word(istream& in, ostream& out) {
 }
 
 void skip_whitespace(istream& in) {
-  while (isspace(in.peek()) && in.peek() != '\n')
+  while (isspace(in.peek()) && in.peek() != '\n') {
+//?     cout << "skip\n"; //? 1
     in.get();
+  }
 }
 
 void skip_newlines(istream& in) {
049'>cdd6fd09 ^
7feea75b ^
cdd6fd09 ^

dfdfc7e9 ^


215365d4 ^

215365d4 ^

67bc24e7 ^
215365d4 ^
dfdfc7e9 ^
215365d4 ^
808e171d ^
1ead3562 ^
5d2a486d ^
f7631430 ^
f78f1907 ^
04209f72 ^
87f1cf60 ^

f78f1907 ^
5d2a486d ^


8a70ff4d ^
215365d4 ^


215365d4 ^
5d2a486d ^
dfdfc7e9 ^
215365d4 ^
f7631430 ^
215365d4 ^
5d2a486d ^

215365d4 ^
5d2a486d ^
1ead3562 ^
5d2a486d ^
1ead3562 ^
215365d4 ^
dfdfc7e9 ^
691b529e ^












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