diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-10-27 12:20:13 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-10-27 12:20:13 -0700 |
commit | eb4eeceabcedd37c11680822b66b266111df261e (patch) | |
tree | c795d8ed0052fb2b9f12a7a88585f2f191a93e6d | |
parent | 4d1f4a660c8ce9226746f485757d7885eaaf8d61 (diff) | |
download | mu-eb4eeceabcedd37c11680822b66b266111df261e.tar.gz |
2289
Now dilated reagent parsing is much simpler. We still can't parse nested hashes. We may never need that. For now the syntax model is: program = collection of top levels top-level contains a list of lines lines may be instructions instructions have reagents reagents can be in compressed or dilated syntax (or literal strings) property values inside reagents can be s-expression trees We balance {} inside top-levels, [] inside strings, and () inside property values.
-rw-r--r-- | 054dilated_reagent.cc | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/054dilated_reagent.cc b/054dilated_reagent.cc index 756dc11d..5ed03cb5 100644 --- a/054dilated_reagent.cc +++ b/054dilated_reagent.cc @@ -79,6 +79,7 @@ if (s.at(0) == '{') { while (!in.eof()) { string key = next_dilated_word(in); if (key.empty()) continue; + if (key == "}") continue; string value = next_dilated_word(in); properties.push_back(pair<string, string_tree*>(key, new string_tree(value))); } @@ -97,17 +98,8 @@ if (s.at(0) == '{') { string next_dilated_word(istream& in) { while (in.peek() == ',') in.get(); string result = next_word(in); - while (true) { - if (result.empty()) - return result; - else if (*result.rbegin() == ':') - strip_last(result); - // if the word doesn't start with a bracket, next_word() was from previous - // layers when reading it, and therefore oblivious about brackets - else if (*result.begin() != '{' && *result.rbegin() == '}') - strip_last(result); - else - break; + while (!result.empty() && *result.rbegin() == ':') { + strip_last(result); } return result; } |