about summary refs log tree commit diff stats
path: root/edit/005-sandbox.mu
Commit message (Expand)AuthorAgeFilesLines
...
* 3445Kartik K. Agaram2016-10-061-47/+47
* 3429 - standardize Mu scenariosKartik K. Agaram2016-09-281-67/+62
* 3396Kartik K. Agaram2016-09-171-73/+73
* 3391 - type abbreviations everywhereKartik K. Agaram2016-09-171-197/+197
* 3341Kartik K. Agaram2016-09-121-3/+3
* 3338Kartik K. Agaram2016-09-121-2/+2
* 3337 - first use of type abbreviations: textKartik K. Agaram2016-09-121-37/+37
* 3168 - skip loading recipe 'main' in edit/Kartik K. Agaram2016-08-121-1/+1
* 3067Kartik K. Agaram2016-06-251-2/+64
* 3052 - make edit/ render functions higher-orderKartik K. Agaram2016-06-121-14/+14
* 3025 - fix a minor annoyance in edit/Kartik K. Agaram2016-05-291-3/+157
* 2983 - migrate buttons over to sandbox/Kartik K. Agaram2016-05-191-7/+0
* 2982Kartik K. Agaram2016-05-191-6/+6
* 2980Kartik K. Agaram2016-05-191-0/+3
* 2977 - draw new sandbox menu in edit/Kartik K. Agaram2016-05-191-139/+160
* 2976Kartik K. Agaram2016-05-191-4/+18
* 2975Kartik K. Agaram2016-05-191-1/+1
* 2954 - bugfix: $systemKartik K. Agaram2016-05-111-8/+1
* 2953 - use pgup/pgdn to scroll through sandboxesKartik K. Agaram2016-05-111-48/+37
* 2928 - fix sandbox restore in edit/ and sandbox/Kartik K. Agaram2016-05-051-3/+7
* 2864 - replace all address:shared with just addressKartik K. Agaram2016-04-241-107/+107
* 2861 - 'maybe-convert' no longer returns addressKartik K. Agaram2016-04-231-3/+3
* 2853 - purge get-address from edit/ appKartik K. Agaram2016-04-221-41/+40
* 2782 - directly use string literals everywhereKartik K. Agaram2016-03-141-9/+4
* 2735 - define recipes using 'def'Kartik K. Agaram2016-03-081-22/+22
* 2716 - more holes in immutability checksKartik K. Agaram2016-02-261-1/+1
* 2707Kartik K. Agaram2016-02-251-5/+0
* 2624Kartik K. Agaram2016-02-011-9/+2
* 2623 - bugfix: editing sandboxesKartik K. Agaram2016-02-011-5/+1
* 2610 - warn when recipes don't use default-spaceKartik K. Agaram2016-01-271-9/+12
* 2608 - fix-up tests in sandbox/ appKartik K. Agaram2016-01-271-13/+6
* 2602Kartik K. Agaram2016-01-241-1/+1
* 2595 - bugfix: update state when restoring sandboxesKartik K. Agaram2016-01-231-0/+3
* 2594 - bugfixes: managing state when deletingKartik K. Agaram2016-01-231-84/+90
* 2592 - bugfix: sandbox title bar managementKartik K. Agaram2016-01-221-1/+85
* 2590 - support scrolling through sandboxesKartik K. Agaram2016-01-221-2/+371
* 2589 - tweak color for sandbox labelsKartik K. Agaram2016-01-221-2/+2
* 2586 - show first sandbox with error in statusKartik K. Agaram2016-01-221-5/+10
* 2585 - label sandboxes with a numberKartik K. Agaram2016-01-221-9/+18
* 2576 - distinguish allocated addresses from othersKartik K. Agaram2016-01-191-76/+76
* 2548 - teach 'print' to print integersKartik K. Agaram2015-12-281-6/+9
* three bugs fixedKartik K. Agaram2015-12-151-0/+3
* rest of edit/ fixedKartik K. Agaram2015-12-151-1/+1
* 2477Kartik K. Agaram2015-11-271-2/+2
* 2476Kartik K. Agaram2015-11-271-1/+1
* 2468 - overload print-character as just 'print'Kartik K. Agaram2015-11-211-7/+7
* 2467 - rename 'string' to 'text' everywhereKartik K. Agaram2015-11-211-8/+8
* 2466 - eliminate ':string' from scenariosKartik K. Agaram2015-11-211-1/+1
* 2446 - drop '-duplex' namespacing in recipesKartik K. Agaram2015-11-151-3/+3
* 2442Kartik K. Agaram2015-11-151-2/+1
c0d83d9004859d6e9452c5fdb'>e3fa6cc7 ^
3d6c13dc ^
d7494165 ^
c51043ab ^
23fd54f1 ^





c51043ab ^



35457609 ^
d7494165 ^

4f5cf668 ^
c51043ab ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
                                                                                        

                                                                          


                                                                              
 
                 
                          
             
                                                                                
 
                                                                                  
 
                                      
             
                                                 
 
                                                                                          
 



                                        





                                     



                                  
                           
                    
                      

                      
                                                            



                            

                                         


                                


                   
 
                                     


                                    

                           
                                






                                                                                
                                 
             
                                               
 
                                                                                      
 





                                                                                    



                                                    
                         

                                                                                
                      
         
//: For convenience, some instructions will take literal arrays of characters (strings).
//:
//: Instead of quotes, we'll use [] to delimit strings. That'll reduce the
//: 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.

:(scenarios load)
:(scenario string_literal)
recipe main [
  1:address:array:character <- copy [abc def]  # copy can't really take a string
]
+parse:   ingredient: {name: "abc def", properties: ["abc def": "literal-string"]}

:(scenario string_literal_with_colons)
recipe main [
  1:address:array:character <- copy [abc:def/ghi]
]
+parse:   ingredient: {name: "abc:def/ghi", properties: ["abc:def/ghi": "literal-string"]}

:(before "End Mu Types Initialization")
Type_number["literal-string"] = 0;

:(after "string next_word(istream& in)")
  if (in.peek() == '[') {
    string result = slurp_quoted(in);
    skip_whitespace(in);
    skip_comment(in);
    return result;
  }

:(code)
string slurp_quoted(istream& in) {
  assert(!in.eof());
  assert(in.peek() == '[');
  ostringstream out;
  int brace_depth = 0;
  while (!in.eof()) {
    char c = in.get();
//?     cout << (int)c << ": " << brace_depth << '\n'; //? 2
    if (c == '\\') {
      out << (char)in.get();
      continue;
    }
    out << c;
//?     cout << out.str() << "$\n"; //? 1
    if (c == '[') ++brace_depth;
    if (c == ']') --brace_depth;
    if (brace_depth == 0) break;
  }
  return out.str();
}

:(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, SIZE(s));
    name = s;
    types.push_back(0);
    properties.push_back(pair<string, vector<string> >(name, vector<string>()));
    properties.back().second.push_back("literal-string");
    return;
  }

:(scenario string_literal_nested)
recipe main [
  1:address:array:character <- copy [abc [def]]
]
+parse:   ingredient: {name: "abc [def]", properties: ["abc [def]": "literal-string"]}

:(scenario string_literal_escaped)
recipe main [
  1:address:array:character <- copy [abc \[def]
]
+parse:   ingredient: {name: "abc [def", properties: ["abc [def": "literal-string"]}

:(scenario string_literal_and_comment)
recipe main [
  1:address:array:character <- copy [abc]  # comment
]
+parse: instruction: copy
+parse:   ingredient: {name: "abc", properties: ["abc": "literal-string"]}
+parse:   product: {name: "1", properties: ["1": "address":"array":"character"]}
# no other ingredients
$parse: 3