Permalink
Browse files

if statement is now when statment since it's a guard and not an if pe…

…r se
  • Loading branch information...
1 parent c9a960b commit 8d6f0e759cfd622044a725594fd44108d82442bf @marianoguerra committed May 26, 2010
Showing with 20 additions and 20 deletions.
  1. +1 −1 examples/attrs.ifn
  2. +3 −3 examples/demo.fn
  3. +3 −3 examples/demo.ifn
  4. +1 −1 lib/mod.ifn
  5. +2 −2 lib/obj.ifn
  6. +2 −2 lib/rest.ifn
  7. +8 −8 src/fn_parser.yrl
View
@@ -30,7 +30,7 @@ run = fn ()
create_or_update = fn (Dict, Key, Value)
IsKey = dict.is_key(Key, Dict)
- if IsKey
+ when IsKey
dict.append(Key, [Value], Dict)
else
dict.store(Key, [Value], Dict)
View
@@ -1,9 +1,9 @@
-# if statement
+# when statement
compare = fn (A, B) {
- if A < B {
+ when A < B {
lt
}
- else if A > B {
+ else when A > B {
gt
}
else {
View
@@ -1,10 +1,10 @@
# a demo that shows different expressions
-# if statement
+# when statement
compare = fn (A, B)
- if A < B
+ when A < B
lt
- else if A > B
+ else when A > B
gt
else
eq
View
@@ -31,7 +31,7 @@ fundoc = fn (Mod, Fun, Arity)
Info = Mod.module_info(attributes)
FilterDoc = fn ((doc, [((Fun1, Arity1), _)]))
- if Fun == Fun1 and Arity == Arity1
+ when Fun == Fun1 and Arity == Arity1
true
else
false
View
@@ -34,8 +34,8 @@ from_json = fn ([], Obj, Attrs, _BinaryToList)
fn ([(Key, Value):Data], Obj, Attrs, BinaryToList)
SKey = binary_to_list(Key)
- FValue = if BinaryToList
- if is_binary(Value)
+ FValue = when BinaryToList
+ when is_binary(Value)
binary_to_list(Value)
else
Value
View
@@ -40,7 +40,7 @@ loop = fn (Req, Api)
Request = request(Req)
Handler = find_handler(Api, Request)
- if Handler == notfound
+ when Handler == notfound
response(Req, 404, mime(text), "not found")
else
(Route, Captured) = Handler
@@ -309,7 +309,7 @@ request = fn (Req)
get_or_create_route = fn (Dict, Key, Module)
IsKey = dict.is_key(Key, Dict)
- if IsKey
+ when IsKey
(Dict, dict.fetch(Key, Dict))
else
Route = route[handler=(Module, element(1, Key))]
View
@@ -6,7 +6,7 @@ Nonterminals
bool_expr bool_and_expr comp_expr concat_expr
add_expr mul_expr unary_expr
block_expr arrow_expr
- if_expr if_patterns if_pattern
+ when_expr when_patterns when_pattern
case_expr case_body case_patterns case_pattern
try_expr catch_patterns catch_pattern
recv_expr receive_patterns receive_pattern
@@ -140,22 +140,22 @@ mul_expr -> unary_expr : '$1'.
unary_expr -> prefix_op literal : {op, line('$2'), op(unwrap('$1')), '$2'}.
unary_expr -> block_expr : '$1'.
-block_expr -> if_expr : '$1'.
+block_expr -> when_expr : '$1'.
block_expr -> arrow_expr : '$1'.
block_expr -> case_expr : '$1'.
block_expr -> try_expr : '$1'.
block_expr -> recv_expr : '$1'.
block_expr -> fun_def : '$1'.
-% if expression
-if_expr -> if if_patterns : {'if', line('$1'), '$2'}.
+% when expression
+when_expr -> when when_patterns : {'if', line('$1'), '$2'}.
-if_patterns -> if_pattern else fn_block :
+when_patterns -> when_pattern else fn_block :
['$1'|[{clause, line('$2'), [], [[{atom, line('$2'), true}]], '$3'}]].
-if_patterns -> if_pattern else if if_patterns : ['$1'|'$4'].
-if_patterns -> if_pattern : ['$1'].
-if_pattern -> bool_expr fn_block : {clause, line('$1'), [], [['$1']], '$2'}.
+when_patterns -> when_pattern else when when_patterns : ['$1'|'$4'].
+when_patterns -> when_pattern : ['$1'].
+when_pattern -> bool_expr fn_block : {clause, line('$1'), [], [['$1']], '$2'}.
% case expression
case_expr -> switch bool_expr case_body : {'case', line('$1'), '$2', '$3'}.

0 comments on commit 8d6f0e7

Please sign in to comment.