:(scenario recipe_with_header)
def main [
1:number/raw <- add2 3, 5
]
def add2 x:number, y:number -> z:number [
local-scope
load-ingredients
z:number <- add x, y
return z
]
+mem: storing 8 in location 1
:(before "End recipe Fields")
bool has_header;
vector<reagent> ingredients;
vector<reagent> products;
:(before "End recipe Constructor")
has_header = false;
:(before "End Recipe Refinements")
if (in.peek() != '[') {
trace(9999, "parse") << "recipe has a header; parsing" << end();
load_recipe_header(in, result);
}
:(code)
void load_recipe_header(istream& in, recipe& result) {
result.has_header = true;
while (has_data(in) && in.peek() != '[' && in.peek() != '\n') {
string s = next_word(in);
if (s == "<-")
raise << "recipe " << result.name << " should say '->' and not '<-'\n" << end();
if (s == "->") break;
result.ingredients.push_back(reagent(s));
trace(9999, "parse") << "header ingredient: " << result.ingredients.back().original_string << end();
skip_whitespace_but_not_newline(in);
}
while (has_data(in) && in.peek() != '[' && in.peek() != '\n') {
string s = next_word(in);
result.products.push_back(reagent(s));
trace(9999, "parse") << "header product: " << result.products.back().original_string << end();
skip_whitespace_but_not_newline(in);
}
}
:(scenario recipe_handles_stray_comma)
def main [
1:number/raw <- add2 3, 5
]
def add2 x:number, y:number -> z:number, [
local-scope
load-ingredients
z:number <- add x, y
return z
]
+mem: storing 8 in location 1
:(scenario recipe_handles_stray_comma_2)
def main [
foo
]
def foo, [
1:number/raw <- add 2, 2
]
def bar [
1:number/raw <- add 2, 3
]
+mem: storing 4 in location 1
:(scenario recipe_handles_wrong_arrow)
% Hide_errors = true;
def foo a:number <- b:number [
]
+error: recipe foo should say '->' and not '<-'
:(scenario recipe_handles_missing_bracket)
% Hide_errors = true;
def main
]
+error: main: recipe body must begin with '['
:(scenario recipe_handles_missing_bracket_2)
% Hide_errors = true;
def main
local-scope
{
}
]
-parse: header ingredient: local-scope
+error: main: recipe body must begin with '['
:(scenario recipe_handles_missing_bracket_3)
% Hide_errors = true;
def main
local-scope
{
}
]
-parse: header ingredient: local-scope
+error: main: recipe body must begin with '['
:(after "Begin debug_string(recipe x)")
out << "ingredients:\n";
for (int i = 0; i < SIZE(x.ingredients); ++i)
out << " " << debug_string(x.ingredients.at(i)) << '\n';
out << "products:\n";
for (int i = 0; i < SIZE(x.products); ++i)
out << " " << debug_string(x.products.at(i)) << '\n';
:(scenario recipe_without_ingredients_or_products_has_header)
def test [
1:number <- copy 34
]
+parse: recipe test has a header
:(before "End Recipe Body(result)")
if (!result.has_header) {
result.has_header = true;
for (int i = 0; i < SIZE(result.steps); ++i) {
const instruction& inst = result.steps.at(i);
if ((inst.name == "reply" && !inst.ingredients.empty())
|| (inst.name == "return" && !inst.ingredients.empty())
|| inst.name == "next-ingredient"
|| inst.name == "ingredient"
|| inst.name == "rewind-ingredients") {
result.has_header = false;
break;
}
}
}
if (result.has_header) {
trace(9999, "parse") << "recipe " << result.name << " has a header" << end();
}
:(before "End Rewrite Instruction(curr, recipe result)")
if (curr.name == "load-ingredients") {
curr.clear();
recipe_ordinal op = get(Recipe_ordinal, "next-ingredient-without-typechecking");
for (int i = pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module ranger.gui.widgets.titlebar</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="ranger.html"><font color="#ffffff">ranger</font></a>.<a href="ranger.gui.html"><font color="#ffffff">gui</font></a>.<a href="ranger.gui.widgets.html"><font color="#ffffff">widgets</font></a>.titlebar</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/hut/work/ranger/ranger/gui/widgets/titlebar.py">/home/hut/work/ranger/ranger/gui/widgets/titlebar.py</a></font></td></tr></table>
<p><tt>The <a href="#TitleBar">TitleBar</a> widget displays the current path and some other useful<br>
information.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="builtins.html#list">builtins.list</a>(<a href="builtins.html#object">builtins.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.gui.widgets.titlebar.html#BarSide">BarSide</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.gui.widgets.titlebar.html#Bar">Bar</a>
</font></dt><dt><font face="helvetica, arial"><a href="ranger.gui.widgets.titlebar.html#ColoredString">ColoredString</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="ranger.gui.widgets.html#Widget">ranger.gui.widgets.Widget</a>(<a href="ranger.gui.displayable.html#Displayable">ranger.gui.displayable.Displayable</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.gui.widgets.titlebar.html#TitleBar">TitleBar</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="Bar">class <strong>Bar</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Bar-__init__"><strong>__init__</strong></a>(self)</dt></dl>
<dl><dt><a name="Bar-add"><strong>add</strong></a>(self, *a, **kw)</dt></dl>
<dl><dt><a name="Bar-addright"><strong>addright</strong></a>(self, *a, **kw)</dt></dl>
<dl><dt><a name="Bar-combine"><strong>combine</strong></a>(self)</dt></dl>
<dl><dt><a name="Bar-fill_gap"><strong>fill_gap</strong></a>(self, char, wid, gapwidth<font color="#909090">=False</font>)</dt></dl>
<dl><dt><a name="Bar-fixedsize"><strong>fixedsize</strong></a>(self)</dt></dl>
<dl><dt><a name="Bar-shrink_by_cutting"><strong>shrink_by_cutting</strong></a>(self, wid)</dt></dl>
<dl><dt><a name="Bar-shrink_by_removing"><strong>shrink_by_removing</strong></a>(self, wid)</dt></dl>
<dl><dt><a name="Bar-sumsize"><strong>sumsize</strong></a>(self)</dt></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>gap</strong> = None</dl>
<dl><dt><strong>left</strong> = None</dl>
<dl><dt><strong>right</strong> = None</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="BarSide">class <strong>BarSide</strong></a>(<a href="builtins.html#list">builtins.list</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="ranger.gui.widgets.titlebar.html#BarSide">BarSide</a></dd>
<dd><a href="builtins.html#list">builtins.list</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="BarSide-add"><strong>add</strong></a>(self, string, *lst, **kw)</dt></dl>
<dl><dt><a name="BarSide-fixedsize"><strong>fixedsize</strong></a>(self)</dt></dl>
<dl><dt><a name="BarSide-nonfixed_items"><strong>nonfixed_items</strong></a>(self)</dt></dl>
<dl><dt><a name="BarSide-sumsize"><strong>sumsize</strong></a>(self)</dt></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="builtins.html#list">builtins.list</a>:<br>
<dl><dt><a name="BarSide-__add__"><strong>__add__</strong></a>(...)</dt><dd><tt>x.<a href="#BarSide-__add__">__add__</a>(y) <==> x+y</tt></dd></dl>
<dl><dt><a name="BarSide-__contains__"><strong>__contains__</strong></a>(...)</dt><dd><tt>x.<a href="#BarSide-__contains__">__contains__</a>(y) <==> y in x</tt></dd></dl>
<dl><dt><a name="BarSide-__delitem__"><strong>__delitem__</strong></a>(...)</dt><dd><tt>x.<a href="#BarSide-__delitem__">__delitem__</a>(y) <==> del x[y]</tt></dd></dl>
<dl><dt><a name="BarSide-__eq__"><