Skip to content

Commit

Permalink
Fix #289.
Browse files Browse the repository at this point in the history
  • Loading branch information
munificent committed Dec 18, 2018
1 parent c64deec commit d4fb34c
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion book/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ Behold this innocuous-seeming expression:
"st" + "ri" + "ng"
```

When the compiler chrews through this, it allocates an ObjString for each of
When the compiler chews through this, it allocates an ObjString for each of
those three string literals and stores them in the chunk's constant table and
generates this <span name="stack">bytecode</span>:

Expand Down
2 changes: 1 addition & 1 deletion book/types-of-values.md
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ need to be able to *un*-generate it in the disassembler:
That wasn't too bad. Let's keep the momentum going and knock out the equality
and comparison operators too: `==`, `!=`, `<`, `>`, `<=`, and `>=`. That covers
all of the operators that return Boolean results except the logical operators
`&&` and `||`. Since those need to short-circuit -- basically do a little
`and` and `or`. Since those need to short-circuit -- basically do a little
control flow -- we aren't ready for them yet.

Here's the new instructions for those operators:
Expand Down
2 changes: 1 addition & 1 deletion c/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,8 @@ ParseRule rules[] = {
//> Types of Values table-false
{ literal, NULL, PREC_NONE }, // TOKEN_FALSE
//< Types of Values table-false
{ NULL, NULL, PREC_NONE }, // TOKEN_FUN
{ NULL, NULL, PREC_NONE }, // TOKEN_FOR
{ NULL, NULL, PREC_NONE }, // TOKEN_FUN
{ NULL, NULL, PREC_NONE }, // TOKEN_IF
/* Compiling Expressions rules < Types of Values table-nil
{ NULL, NULL, PREC_NONE }, // TOKEN_NIL
Expand Down
2 changes: 1 addition & 1 deletion c/scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef enum {

// Keywords.
TOKEN_AND, TOKEN_CLASS, TOKEN_ELSE, TOKEN_FALSE,
TOKEN_FUN, TOKEN_FOR, TOKEN_IF, TOKEN_NIL, TOKEN_OR,
TOKEN_FOR, TOKEN_FUN, TOKEN_IF, TOKEN_NIL, TOKEN_OR,
TOKEN_PRINT, TOKEN_RETURN, TOKEN_SUPER, TOKEN_THIS,
TOKEN_TRUE, TOKEN_VAR, TOKEN_WHILE,

Expand Down
4 changes: 0 additions & 4 deletions note/answers/chapter17_compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,3 @@ that the precedence of the operands is a little unusual. The precedence of the
last operand is *lower* than the conditional expression itself.

That might be surprising, but it's how C rolls.

## 3

TODO
2 changes: 1 addition & 1 deletion site/compiling-expressions.html
Original file line number Diff line number Diff line change
Expand Up @@ -1061,8 +1061,8 @@ <h2><a href="#a-pratt-parser" name="a-pratt-parser"><small>17&#8202;.&#8202;6</s
<span class="p">{</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">PREC_NONE</span> <span class="p">},</span> <span class="c1">// TOKEN_CLASS </span>
<span class="p">{</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">PREC_NONE</span> <span class="p">},</span> <span class="c1">// TOKEN_ELSE </span>
<span class="p">{</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">PREC_NONE</span> <span class="p">},</span> <span class="c1">// TOKEN_FALSE </span>
<span class="p">{</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">PREC_NONE</span> <span class="p">},</span> <span class="c1">// TOKEN_FUN </span>
<span class="p">{</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">PREC_NONE</span> <span class="p">},</span> <span class="c1">// TOKEN_FOR </span>
<span class="p">{</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">PREC_NONE</span> <span class="p">},</span> <span class="c1">// TOKEN_FUN </span>
<span class="p">{</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">PREC_NONE</span> <span class="p">},</span> <span class="c1">// TOKEN_IF </span>
<span class="p">{</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">PREC_NONE</span> <span class="p">},</span> <span class="c1">// TOKEN_NIL </span>
<span class="p">{</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">PREC_OR</span> <span class="p">},</span> <span class="c1">// TOKEN_OR </span>
Expand Down
2 changes: 1 addition & 1 deletion site/scanning-on-demand.html
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ <h2><a href="#a-token-at-a-time" name="a-token-at-a-time"><small>16&#8202;.&#820

<span class="c1">// Keywords. </span>
<span class="n">TOKEN_AND</span><span class="p">,</span> <span class="n">TOKEN_CLASS</span><span class="p">,</span> <span class="n">TOKEN_ELSE</span><span class="p">,</span> <span class="n">TOKEN_FALSE</span><span class="p">,</span>
<span class="n">TOKEN_FUN</span><span class="p">,</span> <span class="n">TOKEN_FOR</span><span class="p">,</span> <span class="n">TOKEN_IF</span><span class="p">,</span> <span class="n">TOKEN_NIL</span><span class="p">,</span> <span class="n">TOKEN_OR</span><span class="p">,</span>
<span class="n">TOKEN_FOR</span><span class="p">,</span> <span class="n">TOKEN_FUN</span><span class="p">,</span> <span class="n">TOKEN_IF</span><span class="p">,</span> <span class="n">TOKEN_NIL</span><span class="p">,</span> <span class="n">TOKEN_OR</span><span class="p">,</span>
<span class="n">TOKEN_PRINT</span><span class="p">,</span> <span class="n">TOKEN_RETURN</span><span class="p">,</span> <span class="n">TOKEN_SUPER</span><span class="p">,</span> <span class="n">TOKEN_THIS</span><span class="p">,</span>
<span class="n">TOKEN_TRUE</span><span class="p">,</span> <span class="n">TOKEN_VAR</span><span class="p">,</span> <span class="n">TOKEN_WHILE</span><span class="p">,</span>

Expand Down
2 changes: 1 addition & 1 deletion site/strings.html
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ <h2><a href="#freeing-objects" name="freeing-objects"><small>19&#8202;.&#8202;5<
</pre></div>


<p>When the compiler chrews through this, it allocates an ObjString for each of
<p>When the compiler chews through this, it allocates an ObjString for each of
those three string literals and stores them in the chunk&rsquo;s constant table and
generates this <span name="stack">bytecode</span>:</p>
<aside name="stack">
Expand Down
4 changes: 2 additions & 2 deletions site/types-of-values.html
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ <h2><a href="#two-new-types" name="two-new-types"><small>18&#8202;.&#8202;4</sma
</pre><div class="source-file"><em>compiler.c</em><br>
replace 1 line</div>
<pre class="insert"><span></span> <span class="p">{</span> <span class="n">literal</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">PREC_NONE</span> <span class="p">},</span> <span class="c1">// TOKEN_FALSE</span>
</pre><pre class="insert-after"><span></span> <span class="p">{</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">PREC_NONE</span> <span class="p">},</span> <span class="c1">// TOKEN_FUN </span>
</pre><pre class="insert-after"><span></span> <span class="p">{</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">PREC_NONE</span> <span class="p">},</span> <span class="c1">// TOKEN_FOR </span>
</pre></div>

<div class="source-file-narrow"><em>compiler.c</em>, replace 1 line</div>
Expand Down Expand Up @@ -783,7 +783,7 @@ <h3><a href="#equality-and-comparison-operators" name="equality-and-comparison-o
<p>That wasn&rsquo;t too bad. Let&rsquo;s keep the momentum going and knock out the equality
and comparison operators too: <code>==</code>, <code>!=</code>, <code>&lt;</code>, <code>&gt;</code>, <code>&lt;=</code>, and <code>&gt;=</code>. That covers
all of the operators that return Boolean results except the logical operators
<code>&amp;&amp;</code> and <code>||</code>. Since those need to short-circuit<span class="em">&mdash;</span>basically do a little
<code>and</code> and <code>or</code>. Since those need to short-circuit<span class="em">&mdash;</span>basically do a little
control flow<span class="em">&mdash;</span>we aren&rsquo;t ready for them yet.</p>
<p>Here&rsquo;s the new instructions for those operators:</p>
<div class="codehilite"><pre class="insert-before"><span></span> <span class="n">OP_FALSE</span><span class="p">,</span>
Expand Down

0 comments on commit d4fb34c

Please sign in to comment.