summaryrefslogtreecommitdiffstats
path: root/articles/xerl-0.3-atomic-expressions/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'articles/xerl-0.3-atomic-expressions/index.html')
-rw-r--r--articles/xerl-0.3-atomic-expressions/index.html22
1 files changed, 13 insertions, 9 deletions
diff --git a/articles/xerl-0.3-atomic-expressions/index.html b/articles/xerl-0.3-atomic-expressions/index.html
index e7c6ab25..086c0de3 100644
--- a/articles/xerl-0.3-atomic-expressions/index.html
+++ b/articles/xerl-0.3-atomic-expressions/index.html
@@ -70,7 +70,7 @@
</header>
<p>We will be adding atomic integer expressions to our language. These look as follow in Erlang:</p>
-<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
@@ -79,28 +79,28 @@ http://www.gnu.org/software/src-highlite -->
<p>And the result of this expression is of course 42.</p>
<p>We will be running this expression at compile time, since we don&apos;t have the means to run code at runtime yet. This will of course result in no module being compiled, but that&apos;s OK, it will allow us to discuss a few important things we&apos;ll have to plan for later on.</p>
<p>First, we must of course accept integers in the tokenizer.</p>
-<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt>{<font color="#009900">D</font>}<font color="#990000">+</font> <font color="#990000">:</font> {<font color="#FF6600">token</font>, {<b><font color="#000080">integer</font></b>, <font color="#009900">TokenLine</font>, <b><font color="#000080">list_to_integer</font></b>(<font color="#009900">TokenChars</font>)}}<font color="#990000">.</font></tt></pre>
</div></div>
<p>We must then accept atomic integer expressions in the parser. This is a simple change. The integer token is terminal so we need to add it to the list of terminals, and then we only need to add it as a possible expression.</p>
-<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><font color="#FF6600">expr</font> <font color="#990000">-&gt;</font> <font color="#FF6600">integer</font> <font color="#990000">:</font> <font color="#FF6600">'$1'</font><font color="#990000">.</font></tt></pre>
</div></div>
<p>A file containing only the number 42 (with no terminating dot) will give the following result when parsing it. This is incidentally the same result as when tokenizing.</p>
-<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt>[{<b><font color="#000080">integer</font></b>,<font color="#993399">1</font>,<font color="#993399">42</font>}]</tt></pre>
</div></div>
<p>We must then evaluate it. We&apos;re going to interpret it for now. Since the result of this expression is not stored in a variable, we are going to simply print it on the screen and discard it.</p>
-<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
@@ -117,28 +117,28 @@ http://www.gnu.org/software/src-highlite -->
</li>
</ul>
<p>This is what happens when we create a file that contains two integers on two separate lines:</p>
-<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt>[{<b><font color="#000080">integer</font></b>,<font color="#993399">1</font>,<font color="#993399">42</font>},{<b><font color="#000080">integer</font></b>,<font color="#993399">2</font>,<font color="#993399">43</font>}]</tt></pre>
</div></div>
<p>And on the same lines:</p>
-<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt>[{<b><font color="#000080">integer</font></b>,<font color="#993399">1</font>,<font color="#993399">42</font>},{<b><font color="#000080">integer</font></b>,<font color="#993399">1</font>,<font color="#993399">43</font>}]</tt></pre>
</div></div>
<p>Does this mean we do not need separators between expressions? Not quite. The <code>+</code> and <code>-</code> operators are an example of why we can&apos;t have nice things. They are ambiguous. They have two different meanings: make an atomic integer positive or negative, or perform an addition or a substraction between two integers. Without a separator you won&apos;t be able to know if the following snippet is one or two expressions:</p>
-<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><font color="#993399">42</font> <font color="#990000">-</font> <font color="#993399">12</font></tt></pre>
</div></div>
<p>Can we use the line ending as an expression separator then? Some languages make whitespace important, often the line separator becomes the expression separator. I do not think this is the best idea, it can lead to errors. For example the following snippet would be two expressions:</p>
-<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
@@ -166,6 +166,10 @@ http://www.gnu.org/software/src-highlite -->
+ <li><a href="https://ninenines.eu/articles/cowboy-2.7.0/">Cowboy 2.7</a></li>
+
+
+
<li><a href="https://ninenines.eu/articles/gun-2.0.0-pre.1/">Gun 2.0 pre-release 1</a></li>