mu/cpp/029string

30 lines
724 B
Plaintext
Raw Normal View History

2015-03-31 04:22:29 +00:00
:(scenario "string_literal")
recipe main [
s:address:array:character <- new [abc def]
]
2015-03-31 04:31:58 +00:00
+parse: ingredient: {name: "abc def", value: 0, type: 0, properties: ["abc def": "literal-string"]}
2015-03-31 04:22:29 +00:00
:(before "End Mu Types Initialization")
Type_number["literal-string"] = 0;
:(after "string next_word(istream& in)")
if (in.peek() == '[') return slurp_quoted(in);
:(code)
string slurp_quoted(istream& in) {
assert(!in.eof());
assert(in.get() == '[');
ostringstream out;
int size = 1;
while (!in.eof()) {
char c = in.get();
if (c == '[') ++size;
if (c == ']') --size;
if (size == 0) break;
//? cout << c << '\n'; //? 1
out << c;
//? cout << out.str() << "$\n"; //? 1
}
return out.str();
}