summary refs log tree commit diff stats
path: root/doc
Commit message (Expand)AuthorAgeFilesLines
* Update vim_file_chooser.vimIsrael Chauca Fuentes2013-09-171-11/+27
* Changed email address in source codehut2013-08-081-1/+1
* doc/HACKING: updatedhut2013-06-241-10/+8
* rebuilt man pages with new pod2man versionhut2013-06-212-28/+46
* ranger.1: mention that some commands are based on :scouthut2013-06-212-0/+28
* ranger.1: more exhaustive documentation for :open_withhut2013-06-212-4/+14
* doc/colorschemes.txt: updatehut2013-06-101-3/+3
* RANGER! RANGER! HIGH VOLTAGE! v1.6.1hut2013-05-242-2/+2
* doc/ranger.1: put a list of resources at the tophut2013-04-302-25/+41
* ext.img_display: allow using W3MIMGDISPLAY_PATH env varhut2013-03-242-1/+10
* update examples (s/ranger.fsobject/ranger.container/)hut2013-03-172-5/+5
* added doc/config directory with symlinks to configshut2013-03-157-0/+7
* manpage: renamed example/ to /usr/share/doc/ranger/hut2013-03-092-9/+11
* move doc/print_{colors,keys}.py to doc/tools/hut2013-03-092-0/+0
* move examples to doc/exampleshut2013-03-0911-0/+200
* HACKING: remove part about tabs; ranger uses spaces nowhut2013-03-031-2/+0
* renamed container.settingobject to container.settingshut2013-03-011-1/+1
* settingobject: remove complexity of shorten_title settinghut2013-03-012-5/+5
* doc/ranger.1: removed obsolete reference to fm.envhut2013-03-012-2/+2
* rifle: added --version optionhut2013-03-011-1/+1
* doc/ranger.1: documented :scout commandhut2013-03-012-1/+50
* doc/ranger.1: Fixed --copy-config documentationhut2013-02-282-3/+3
* Merge branch 'vcs'hut2013-02-242-0/+24
|\
| * Merge branch 'master' into vcshut2013-02-223-99/+106
| |\
| * \ Merge branch 'master' into vcshut2013-02-194-0/+357
| |\ \
| * \ \ Merge branch 'master' into vcshut2013-02-183-83/+96
| |\ \ \
| * | | | document config options for vcs on the man pageAbdo Roig-Maranges2013-02-172-8/+16
| * | | | Rebuilt manpageAbdo Roig-Maranges2013-02-121-1/+8
| * | | | Adds config settings and documentation for the vcs featureAbdo Roig-Maranges2013-02-121-0/+9
* | | | | Fire in the Hole! v1.6.0hut2013-02-221-1/+1
| |_|_|/ |/| | |
* | | | core.main: added RANGER_LOAD_DEFAULT_RC environment variablehut2013-02-222-0/+11
* | | | doc/ranger.1: update ENVIRONMENT sectionhut2013-02-222-8/+4
* | | | doc/ranger.1: typohut2013-02-222-2/+2
* | | | update email address (romanz@lavabit.com -> hut@lavabit.com)hut2013-02-221-1/+1
* | | | doc/ranger.1: added chmod key bindings to man pagehut2013-02-222-0/+9
* | | | doc/ranger.1: remove midnight commander bindings from man pagehut2013-02-222-64/+0
* | | | doc/ranger.1: update KEY BINDINGS sectionhut2013-02-222-21/+52
* | | | doc/ranger.1: updated the CONCEPTS sectionhut2013-02-222-3/+27
| |_|/ |/| |
* | | doc/rifle.1: added whitespace at exampleshut2013-02-183-9/+28
* | | doc/rifle.1: Added man page for riflehut2013-02-183-0/+338
| |/ |/|
* | README: removed bash dependencyhut2013-02-182-2/+2
* | ranger.1: update list of ranger optionshut2013-02-182-17/+37
* | ranger.1: added missing docs of settingshut2013-02-182-2/+18
* | ranger.__init__: change [path/filename] to [path] in USAGEhut2013-02-182-2/+2
* | ranger.1: update doc of :open_withhut2013-02-182-6/+4
* | doc/ranger.1: update doc of :chmod, :delete, :find, :save_copy_bufferhut2013-02-182-26/+20
* | doc/ranger.1: fully removed --mode and --flags from man pagehut2013-02-171-9/+0
* | doc/ranger.1: added :travel to man pagehut2013-02-172-0/+17
* | core.main: made --mode and --flag deprecatedhut2013-02-172-15/+2
* | core.main: made --fail-unless-cd deprecatedhut2013-02-172-12/+3
14:38:57 -0700 2291 - parsing property trees' href='/akkartik/mu/commit/054dilated_reagent.cc?h=hlt&id=a17f9186c17073e07eef6f046dcc1b15f08ed73c'>a17f9186 ^
79eef536 ^
a17f9186 ^
a796831f ^
a796831f ^



79eef536 ^
a796831f ^
a072f674 ^
eb4eecea ^
a072f674 ^

a796831f ^

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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
                                                                             

                                                                          


                           
          

                                  
                                              
 
                                                   
          




                                     

                                        
          

                                                  
                                              


                                                              
          



                                                

                                                                
                                       




                                                             



                                                                          

                                            
                       
                         
                                      
                        
                
                      


































                                                                            
                                                   




                                    
                             


                        

                       
                                                                     


                    
                                                            







                                                        
                        
                               
                              
                             
                                                        
                                          
                                                                 
   



         
                               
                                
                                                    
                       

                                                

                
//: An alternative syntax for reagents that permits whitespace in properties,
//: grouped by brackets. We'll use this ability in the next layer, when we
//: generalize types from lists to trees of properties.

:(scenarios load)
:(scenario dilated_reagent)
def main [
  {1: number, foo: bar} <- copy 34
]
+parse:   product: {1: "number", "foo": "bar"}

:(scenario load_trailing_space_after_curly_bracket)
def main [
  # line below has a space at the end
  { 
]
# successfully parsed

:(scenarios run)
:(scenario dilated_reagent_with_comment)
def main [
  {1: number, foo: bar} <- copy 34  # test comment
]
+parse:   product: {1: "number", "foo": "bar"}
$error: 0

:(scenario dilated_reagent_with_comment_immediately_following)
def main [
  1:number <- copy {34: literal}  # test comment
]
$error: 0

//: First augment next_word to group balanced brackets together.

:(before "End next_word Special-cases")
if (in.peek() == '(')
  return slurp_balanced_bracket(in);
// treat curlies mostly like parens, but don't mess up labels
if (start_of_dilated_reagent(in))
  return slurp_balanced_bracket(in);

:(code)
// A curly is considered a label if it's the last thing on a line. Dilated
// reagents should remain all on one line.
bool start_of_dilated_reagent(istream& in) {
  if (in.peek() != '{') return false;
  int pos = in.tellg();
  in.get();  // slurp '{'
  skip_whitespace_but_not_newline(in);
  char next = in.peek();
  in.seekg(pos);
  return next != '\n';
}

// Assume the first letter is an open bracket, and read everything until the
// matching close bracket.
// We balance {} () and []. And we skip one character after '\'.
string slurp_balanced_bracket(istream& in) {
  ostringstream result;
  char c;
  list<char> open_brackets;
  while (in >> c) {
    if (c == '\\') {
      // always silently skip the next character
      result << c;
      if (!(in >> c)) break;
      result << c;
      continue;
    }
    if (c == '(') open_brackets.push_back(c);
    if (c == ')') {
      assert(open_brackets.back() == '(');
      open_brackets.pop_back();
    }
    if (c == '[') open_brackets.push_back(c);
    if (c == ']') {
      assert(open_brackets.back() == '[');
      open_brackets.pop_back();
    }
    if (c == '{') open_brackets.push_back(c);
    if (c == '}') {
      assert(open_brackets.back() == '{');
      open_brackets.pop_back();
    }
    result << c;
    if (open_brackets.empty()) break;
  }
  skip_whitespace_and_comments_but_not_newline(in);
  return result.str();
}

:(after "Parsing reagent(string s)")
if (s.at(0) == '{') {
  assert(properties.empty());
  istringstream in(s);
  in >> std::noskipws;
  in.get();  // skip '{'
  name = slurp_key(in);
  if (name.empty()) {
    raise << "invalid reagent " << s << " without a name\n" << end();
    return;
  }
  if (name == "}") {
    raise << "invalid empty reagent " << s << '\n' << end();
    return;
  }
  {
    string_tree* value = new string_tree(next_word(in));
    // End Parsing Reagent Type Property(value)
    type = new_type_tree(value);
    delete value;
  }
  while (has_data(in)) {
    string key = slurp_key(in);
    if (key.empty()) continue;
    if (key == "}") continue;
    string_tree* value = new string_tree(next_word(in));
    // End Parsing Reagent Property(value)
    properties.push_back(pair<string, string_tree*>(key, value));
  }
  return;
}

:(code)
string slurp_key(istream& in) {
  string result = next_word(in);
  while (!result.empty() && *result.rbegin() == ':')
    strip_last(result);
  while (isspace(in.peek()) || in.peek() == ':')
    in.get();
  return result;
}