Skip to content

Commit

Permalink
improve function hush syntax to what I always think it is
Browse files Browse the repository at this point in the history
  • Loading branch information
gkz committed Jul 12, 2013
1 parent d19f1e8 commit 79e5d77
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 9 deletions.
3 changes: 2 additions & 1 deletion lib/ast.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/grammar.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion lib/lexer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/ast.ls
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ class exports.Existence extends Node implements Negatable
#### Fun
# A function definition. This is the only node that creates a `new Scope`.
class exports.Fun extends Node
(@params or [], @body or Block!, @bound and \this$, @curried or false) ~>
(@params or [], @body or Block!, @bound and \this$, @curried or false, @hushed = false) ~>

children: <[ params body ]>

Expand Down
2 changes: 1 addition & 1 deletion src/grammar.ls
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ bnf =

# The function literal can be either anonymous with `->`,
o 'PARAM( ArgList OptComma )PARAM -> Block'
, -> L Fun $2, $6, $5.charAt(0) is \~, $5.length is 3
, -> L Fun $2, $6, /~/.test($5), /--|~~/.test($5), /!/.test($5)
# or named with `function`.
o 'FUNCTION CALL( ArgList OptComma )CALL Block' -> L Fun($3, $6)named $1

Expand Down
6 changes: 3 additions & 3 deletions src/lexer.ls
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ exports import
case \~
return 1 if @dotcat val
tag = \UNARY
case \-> \~> \--> \~~> then up = \->; fallthrough
case \-> \~> \--> \~~> \!-> \!~> \!--> \!~~> then up = \->; fallthrough
case \<- \<~ \<-- \<~~ then @parameters tag = up || \<-
case \::
@adi!
Expand Down Expand Up @@ -1206,12 +1206,12 @@ SYMBOL = //
| \.(?:[&\|\^] | << | >>>?)\.=? # bitwise and shifts
| \.{1,3} # dot / cascade / splat/placeholder/yada*3
| \^\^ # clone
| --> | ~~> | <-- | <~~ # curry
| !?--> | !?~~> | <-- | <~~ # curry
| ([-+&|:])\1 # crement / logic / `prototype`
| %% # mod
| & # arguments
| \([^\n\S]*\) # call
| [-~]> # function, bound function
| !?[-~]> # function, bound function
| <[-~] # backcall
| [!=]==? # strict equality, deep equals
| !?\~= # fuzzy equality
Expand Down
5 changes: 5 additions & 0 deletions test/function.ls
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,11 @@ eq void do

eq false !!->

eq void do (x) !-> true
eq void do (x) !--> true
eq void do (x) !~> true
eq void do (x) !~~> true

### auto currying magic
times = (x, y) --> x * y
timesTwo = times 2
Expand Down

1 comment on commit 79e5d77

@vendethiel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES.

Please sign in to comment.