about summary refs log tree commit diff stats
path: root/cpp/011load
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/011load')
-rw-r--r--cpp/011load16
1 files changed, 11 insertions, 5 deletions
diff --git a/cpp/011load b/cpp/011load
index f2855e5f..0193eeac 100644
--- a/cpp/011load
+++ b/cpp/011load
@@ -13,6 +13,7 @@ int add_recipe(string form) {
   istringstream in(form);
   in >> std::noskipws;
 
+  skip_comments_and_newlines(in);
   string _recipe = next_word(in);
   if (_recipe != "recipe")
     raise << "top-level forms must be of the form 'recipe _name_ [ _instruction_ ... ]'\n";
@@ -25,7 +26,7 @@ int add_recipe(string form) {
   if (next_word(in) != "[")
     raise << "recipe body must begin with '['\n";
 
-  skip_newlines(in);
+  skip_comments_and_newlines(in);
 
   instruction curr;
   while (next_instruction(in, &curr)) {
@@ -38,7 +39,7 @@ bool next_instruction(istream& in, instruction* curr) {
   curr->clear();
   if (in.eof()) return false;
   skip_whitespace(in);  if (in.eof()) return false;
-  skip_newlines(in);  if (in.eof()) return false;
+  skip_comments_and_newlines(in);  if (in.eof()) return false;
 
   vector<string> words;
   while (in.peek() != '\n') {
@@ -47,7 +48,7 @@ bool next_instruction(istream& in, instruction* curr) {
     words.push_back(word);
     skip_whitespace(in);  if (in.eof()) return false;
   }
-  skip_newlines(in);  if (in.eof()) return false;
+  skip_comments_and_newlines(in);  if (in.eof()) return false;
 
   if (words.size() == 1 && *(words[0].end()-1) == ':') {
     curr->is_label = true;
@@ -112,9 +113,14 @@ void skip_whitespace(istream& in) {
   }
 }
 
-void skip_newlines(istream& in) {
-  while (in.peek() == '\n')
+void skip_comments_and_newlines(istream& in) {
+  while (in.peek() == '\n' || in.peek() == '#') {
+    if (in.peek() == '#') {
+      in.get();
+      while (in.peek() != '\n') in.get();
+    }
     in.get();
+  }
 }
 
 void skip_comma(istream& in) {
div>
f07bb12f ^









ef0157ff ^
f07bb12f ^
62cd83ba ^
ef0157ff ^
62cd83ba ^


ef0157ff ^

62cd83ba ^



f07bb12f ^








62cd83ba ^
ef0157ff ^
62cd83ba ^



































ef0157ff ^
62cd83ba ^
ef0157ff ^
62cd83ba ^








ef0157ff ^
62cd83ba ^



ef0157ff ^
62cd83ba ^

ef0157ff ^
62cd83ba ^

c776804d ^
62cd83ba ^
ef0157ff ^
62cd83ba ^

f07bb12f ^

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