From 96ac511e9e789dfe0dd16e5216b7a957338fe3d3 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 18 Feb 2015 10:56:19 -0800 Subject: 780 - some more scenarios --- cpp/literate/011load | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'cpp') diff --git a/cpp/literate/011load b/cpp/literate/011load index 5811f77a..4bc73365 100644 --- a/cpp/literate/011load +++ b/cpp/literate/011load @@ -1,5 +1,6 @@ // It's often convenient to express recipes in a textual fashion. -:(scenario add_recipe) +:(scenarios add_recipe) +:(scenario first_recipe) recipe main [ 1:integer <- copy 23:literal ] @@ -8,10 +9,6 @@ recipe main [ +parse: product: {name: "1", type: 1} :(code) -void run(string text) { - add_recipe(text); -} - void add_recipe(string form) { istringstream in(form); in >> std::noskipws; @@ -124,3 +121,29 @@ void skip_comma(istream& in) { if (in.peek() == ',') in.get(); skip_whitespace(in); } + +:(scenario parse_label) +recipe main [ + foo: +] ++parse: label: foo +-parse: instruction: 1 + +:(scenario parse_multiple_products) +recipe main [ + 1:integer, 2:integer <- copy 23:literal +] ++parse: instruction: 1 ++parse: ingredient: {name: "23", type: 0} ++parse: product: {name: "1", type: 1} ++parse: product: {name: "2", type: 1} + +:(scenario parse_multiple_ingredients) +recipe main [ + 1:integer, 2:integer <- copy 23:literal, 4:integer +] ++parse: instruction: 1 ++parse: ingredient: {name: "23", type: 0} ++parse: ingredient: {name: "4", type: 1} ++parse: product: {name: "1", type: 1} ++parse: product: {name: "2", type: 1} -- cgit 1.4.1-2-gfad0