Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support defining functions with zero parameters.
Add a simple test for that.
  • Loading branch information
pmurias committed Nov 27, 2014
1 parent 7af2d4d commit c3ba195
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -18,7 +18,7 @@ blib/%.moarvm: src/%.nqp
blib/Snake/Actions.moarvm: src/Snake/Actions.nqp blib/Snake/Metamodel/ClassHOW.moarvm

test: all
prove -r --exec ./snake t/sanity/*.t
prove -r --exec ./snake t/sanity/*.t t/*.t

clean:
-rm $(MOARS)
2 changes: 1 addition & 1 deletion src/Snake/Grammar.nqp
Expand Up @@ -311,7 +311,7 @@ token new_scope {
<suite>
}

rule parameter_list { <parameter>+ % [ ',' ]$<trailing>=[ ',' ]? }
rule parameter_list { <parameter>* % [ ',' ]$<trailing>=[ ',' ]? }

# TODO: Parameter annotations
token parameter { [:s<identifier> ['=' <EXPR>]?] }
Expand Down
12 changes: 12 additions & 0 deletions t/def.t
@@ -0,0 +1,12 @@
nqp::say("1..2");

def with_3_params(a,b,c):
nqp::print(a)
nqp::print(b)
nqp::say(c)

def with_0_params():
nqp::say("ok 2");

with_3_params("o","k"," 1");
with_0_params()

0 comments on commit c3ba195

Please sign in to comment.