summaryrefslogtreecommitdiffstats
path: root/_build/content/articles/xerl-0.4-expression-separator.asciidoc
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-03-28 15:36:42 +0200
committerLoïc Hoguin <[email protected]>2016-03-28 15:36:42 +0200
commitfe3492a98de29942477b061cd02c92246f4bf85a (patch)
tree2255b796a657e6e4dfb72beec1141258d17f1220 /_build/content/articles/xerl-0.4-expression-separator.asciidoc
downloadninenines.eu-fe3492a98de29942477b061cd02c92246f4bf85a.tar.gz
ninenines.eu-fe3492a98de29942477b061cd02c92246f4bf85a.tar.bz2
ninenines.eu-fe3492a98de29942477b061cd02c92246f4bf85a.zip
Initial commit, new website system
Diffstat (limited to '_build/content/articles/xerl-0.4-expression-separator.asciidoc')
-rw-r--r--_build/content/articles/xerl-0.4-expression-separator.asciidoc48
1 files changed, 48 insertions, 0 deletions
diff --git a/_build/content/articles/xerl-0.4-expression-separator.asciidoc b/_build/content/articles/xerl-0.4-expression-separator.asciidoc
new file mode 100644
index 00000000..c137cf1d
--- /dev/null
+++ b/_build/content/articles/xerl-0.4-expression-separator.asciidoc
@@ -0,0 +1,48 @@
++++
+date = "2013-03-01T00:00:00+01:00"
+title = "Xerl: expression separator"
+
++++
+
+As promised we are adding an expression separator this time.
+This will be short and easy.
+
+In the tokenizer we only need to add a line recognizing the
+comma as a valid token.
+
+[source,erlang]
+, : {token, {',', TokenLine}}.
+
+Then we need to change the following lines in the parser:
+
+[source,erlang]
+exprs -> expr : ['$1'].
+exprs -> expr exprs : ['$1' | '$2'].
+
+And add a comma between the expressions on the second line:
+
+[source,erlang]
+exprs -> expr : ['$1'].
+exprs -> expr ',' exprs : ['$1' | '$3'].
+
+That takes care of everything except the optional trailing
+comma at the end of our lists of expressions. We just need an
+additional rule to take care of this.
+
+[source,erlang]
+exprs -> expr ',' : ['$1'].
+
+That's it.
+
+Wondering why we don't have this optional trailing comma in
+Erlang considering how easy it was and the number of people
+complaining about it? Yeah, me too. But that's for someone else
+to answer.
+
+Another change I want to talk about is a simple modification
+of the compiler code to use an `#env{}` record for
+tracking state instead of passing around individual variables.
+This will be required later on when we make modules into proper
+expressions so I thought it was a good idea to anticipate.
+
+* https://github.com/extend/xerl/blob/0.4/[View the source]