999
This commit is contained in:
parent
5e21a9f608
commit
3d6c13dc43
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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 [
|
||||
|
|
Loading…
Reference in New Issue