File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ grammar Rubyish::Grammar is HLL::Grammar {
224
224
# Operators - mostly stolen from NQP
225
225
token infix :sym <** > { <sym > <O (' %exponentiation, :op<pow_n>' )> }
226
226
227
- token prefix :sym <- > { <sym > <O (' %unary, :op<neg_n>' )> }
227
+ token prefix :sym <- > { <sym ><! [ > ] > <O (' %unary, :op<neg_n>' )> }
228
228
token prefix :sym <! > { <sym > <O (' %unary, :op<not_i>' )> }
229
229
230
230
token infix :sym <* > { <sym > <O (' %multiplicative, :op<mul_n>' )> }
@@ -324,6 +324,7 @@ grammar Rubyish::Grammar is HLL::Grammar {
324
324
325
325
token term :sym <lambda > {
326
326
'lambda' :s ['{' ['|' ~ '|' <signature >]? ] ~ '}' <stmtlist >
327
+ | '->' :s ['(' ~ ')' <signature > :s ]? '{' ~ '}' <stmtlist >
327
328
}
328
329
329
330
method builtin-init () {
Original file line number Diff line number Diff line change 1
- puts " 1..5 "
1
+ puts " 1..7 "
2
2
def make_iterator(n)
3
3
lambda { |incr,desc| n += incr; puts " ok #{n} - #{desc}" }
4
4
end
@@ -12,3 +12,9 @@ it2.call(0,"iterator 2")
12
12
it2.call(1," iterator 2" )
13
13
it1.call(3," iterator 1" )
14
14
15
+ # Ruby 1.9+ style lambda syntax
16
+
17
+ m = 5
18
+ test = -> (desc) {puts " ok #{m+=1} - #{desc}" }
19
+ test.call(" new lamba syntax" );
20
+ test.call(" new lamba syntax" );
You can’t perform that action at this time.
0 commit comments