From 1f59be846a68a5a4ec456b4104a94e421d135cf1 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 28 Jul 2015 16:38:37 -0700 Subject: 1876 --- 010vm.cc | 2 ++ 013literal_string.cc | 25 ++++++++++++------------- 014literal_noninteger.cc | 18 +++++++++--------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/010vm.cc b/010vm.cc index 827e673e..9e6b4e24 100644 --- a/010vm.cc +++ b/010vm.cc @@ -176,6 +176,7 @@ void instruction::clear() { is_label=false; label.clear(); operation=IDLE; ingre // Reagents have the form :::...///... reagent::reagent(string s) :original_string(s), value(0), initialized(false) { + // Parsing reagent(string s) istringstream in(s); in >> std::noskipws; // properties @@ -206,6 +207,7 @@ reagent::reagent(string s) :original_string(s), value(0), initialized(false) { types.push_back(0); properties.at(0).second.push_back("dummy"); } + // End Parsing reagent } reagent::reagent() :value(0), initialized(false) { diff --git a/013literal_string.cc b/013literal_string.cc index 29a185b2..8054d60f 100644 --- a/013literal_string.cc +++ b/013literal_string.cc @@ -113,19 +113,18 @@ void slurp_quoted_comment_aware(istream& in, ostringstream& out) { out.clear(); } -:(after "reagent::reagent(string s)") -//? cout << s.at(0) << '\n'; //? 1 - if (s.at(0) == '[') { - assert(*s.rbegin() == ']'); - // delete [] delimiters - s.erase(0, 1); - s.erase(SIZE(s)-1); - name = s; - types.push_back(0); - properties.push_back(pair >(name, vector())); - properties.back().second.push_back("literal-string"); - return; - } +:(after "Parsing reagent(string s)") +if (s.at(0) == '[') { + assert(*s.rbegin() == ']'); + // delete [] delimiters + s.erase(0, 1); + s.erase(SIZE(s)-1); + name = s; + types.push_back(0); + properties.push_back(pair >(name, vector())); + properties.back().second.push_back("literal-string"); + return; +} //: Two tweaks to printing literal strings compared to other reagents: //: a) Don't print the string twice in the representation, just put '_' in diff --git a/014literal_noninteger.cc b/014literal_noninteger.cc index 7c6e19d3..11a3fc70 100644 --- a/014literal_noninteger.cc +++ b/014literal_noninteger.cc @@ -7,15 +7,15 @@ recipe main [ ] +parse: ingredient: {name: "3.14159", properties: ["3.14159": "literal-number"]} -:(after "reagent::reagent(string s)") - if (is_noninteger(s)) { - name = s; - types.push_back(0); - properties.push_back(pair >(name, vector())); - properties.back().second.push_back("literal-number"); - set_value(to_double(s)); - return; - } +:(after "Parsing reagent(string s)") +if (is_noninteger(s)) { + name = s; + types.push_back(0); + properties.push_back(pair >(name, vector())); + properties.back().second.push_back("literal-number"); + set_value(to_double(s)); + return; +} :(code) bool is_noninteger(const string& s) { -- cgit 1.4.1-2-gfad0