Permalink
Browse files

Grammar and compiler support for strings

  • Loading branch information...
1 parent a2b3d1c commit 9676cb7b139ec291b6223825e8978f5e1be71572 Tony Arcieri committed Dec 19, 2009
Showing with 12 additions and 1 deletion.
  1. +1 −0 src/compiler/reia_nodes.hrl
  2. +2 −1 src/compiler/reia_parse.yrl
  3. +9 −0 src/compiler/reia_r2e.erl
@@ -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}).
@@ -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'.
@@ -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}) ->

0 comments on commit 9676cb7

Please sign in to comment.