Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Grammar and compiler support for strings

  • Loading branch information...
commit 9676cb7b139ec291b6223825e8978f5e1be71572 1 parent a2b3d1c
Tony Arcieri authored
View
1  src/compiler/reia_nodes.hrl
@@ -8,6 +8,7 @@
-record(integer, {line, value}).
-record(float, {line, value}).
-record(identifier, {line, name}).
+-record(string, {line, characters}).
-record(atom, {line, name}).
-record(true, {line}).
-record(false, {line}).
View
3  src/compiler/reia_parse.yrl
@@ -35,7 +35,7 @@ Nonterminals
Terminals
eol '(' ')' '[' ']' '{' '}'
- float integer atom true false nil
+ float integer string atom true false nil
identifier punctuated_identifier erl
'+' '-' '*' '/' '%' '**' ',' '.' '=' '=>'
'+=' '-=' '*=' '/=' '**='
@@ -79,6 +79,7 @@ call_expr -> call : '$1'.
call_expr -> max_expr : '$1'.
max_expr -> number : '$1'.
+max_expr -> string : '$1'.
max_expr -> list : '$1'.
max_expr -> tuple : '$1'.
max_expr -> map : '$1'.
View
9 src/compiler/reia_r2e.erl
@@ -8,6 +8,7 @@
-module(reia_r2e).
-export([transform/2]).
-include("reia_nodes.hrl").
+-include("reia_types.hrl").
-define(reia_dispatch(Receiver, Line, Method, Args, Block),
{call, Line,
{remote, Line, {atom, Line, reia_dispatch}, {atom, Line, call}},
@@ -50,6 +51,14 @@ transform(#true{line=Line}) -> {atom, Line, true};
transform(#false{line=Line}) -> {atom, Line, false};
transform(#nil{line=Line}) -> {atom, Line, nil};
transform(#identifier{line=Line, name=Name}) -> {var, Line, Name};
+transform(#string{line=Line, characters=Chars}) ->
+ {tuple, Line, [
+ {atom, Line, reia_string},
+ {cons, Line,
+ {bin, Line, [{bin_element, Line, {string, Line, Chars}, default, default}]},
+ {nil, Line}
+ }
+ ]};
% Matches
transform(#match{line=Line, left=Left, right=Right}) ->
Please sign in to comment.
Something went wrong with that request. Please try again.