about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-31 10:17:19 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-31 10:17:19 -0700
commit3d6c13dc432917de73e17a3fd301a4cc3a2d851b (patch)
treeca0d21377427b4bc8a31125895a451b173f1f74f
parent5e21a9f608f413eb1df4736f4c143f18ba7ac1ec (diff)
downloadmu-3d6c13dc432917de73e17a3fd301a4cc3a2d851b.tar.gz
999
-rw-r--r--cpp/.traces/string_literal3
-rw-r--r--cpp/.traces/string_literal_nested8
-rw-r--r--cpp/029string11
3 files changed, 18 insertions, 4 deletions
diff --git a/cpp/.traces/string_literal b/cpp/.traces/string_literal
index 3f7ff417..eabc7af9 100644
--- a/cpp/.traces/string_literal
+++ b/cpp/.traces/string_literal
@@ -1,8 +1,7 @@
 parse/0: instruction: 24
 parse/0:   ingredient: {name: "abc def", value: 0, type: 0, properties: ["abc def": "literal-string"]}
-parse/0:   product: {name: "s", value: 0, type: 2-4-7, properties: ["s": "address":"array":"character"]}
+parse/0:   product: {name: "1", value: 0, type: 2-4-7, properties: ["1": "address":"array":"character"]}
 new/0: abc def -> 0
-name/0: assign s 1
 after-brace/0: recipe main
 after-brace/0: new ...
 run/0: instruction main/0
diff --git a/cpp/.traces/string_literal_nested b/cpp/.traces/string_literal_nested
new file mode 100644
index 00000000..5f54d8c3
--- /dev/null
+++ b/cpp/.traces/string_literal_nested
@@ -0,0 +1,8 @@
+parse/0: instruction: 24
+parse/0:   ingredient: {name: "abc [def]", value: 0, type: 0, properties: ["abc [def]": "literal-string"]}
+parse/0:   product: {name: "1", value: 0, type: 2-4-7, properties: ["1": "address":"array":"character"]}
+new/0: abc [def] -> 0
+after-brace/0: recipe main
+after-brace/0: new ...
+run/0: instruction main/0
+mem/0: storing 1000 in location 1
diff --git a/cpp/029string b/cpp/029string
index 209a1e7f..6778a3c4 100644
--- a/cpp/029string
+++ b/cpp/029string
@@ -1,8 +1,9 @@
 //: Some instructions can take string literals for convenience.
 //:
 //: Instead of quotes, we'll use [] to delimit strings. That'll reduce the
-//: need for escaping. And we can also imagine that 'recipe' might one day
-//: itself be defined in mu, doing its own parsing.
+//: need for escaping since we can support nested brackets. And we can also
+//: imagine that 'recipe' might one day itself be defined in mu, doing its own
+//: parsing.
 
 //: First extend the mu parser to support string literals.
 :(scenario "string_literal")
@@ -35,6 +36,12 @@ string slurp_quoted(istream& in) {
   return out.str();
 }
 
+:(scenario "string_literal_nested")
+recipe main [
+  1:address:array:character <- new [abc [def]]
+]
++parse:   ingredient: {name: "abc [def]", value: 0, type: 0, properties: ["abc [def]": "literal-string"]}
+
 //: Next, extend 'new' to handle a string literal argument.
 :(scenario "new_string")
 recipe main [