Skip to content

Commit

Permalink
Merge pull request #74 from fink-lang/features
Browse files Browse the repository at this point in the history
Features
  • Loading branch information
kollhof authored Jul 19, 2020
2 parents f22895c + 3e166c0 commit 9c87a0f
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 127 deletions.
191 changes: 84 additions & 107 deletions package-lock.json

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

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@
}
},
"devDependencies": {
"@fink/cli": "^6.0.0",
"@fink/jest": "^5.0.2",
"@fink/larix": "^12.0.0",
"@fink/loxia": "^12.0.1",
"@fink/cli": "^6.1.0",
"@fink/jest": "^5.1.0",
"@fink/larix": "^12.1.0",
"@fink/loxia": "^12.0.2",
"commitizen": "^4.1.2",
"cz-conventional-changelog": "^3.1.0",
"jest-cli": "^26.1.0",
"npx-run": "^2.1.2",
"semantic-release": "^17.1.1"
},
"dependencies": {
"@babel/core": "^7.10.4",
"@babel/traverse": "^7.10.4",
"@babel/types": "^7.10.4",
"@fink/js-interop": "^1.0.0",
"@fink/std-lib": "^3.0.0"
"@babel/core": "^7.10.5",
"@babel/traverse": "^7.10.5",
"@babel/types": "^7.10.5",
"@fink/js-interop": "^1.1.0",
"@fink/std-lib": "^3.1.1"
}
}
8 changes: 5 additions & 3 deletions src/lang/assignment/index.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
{add, any} = import '../context'
{transform_value} = import '../partial'


# TODO: std-lib
find_index = fn iterable, func:
iterable.findIndex func


is_spread_not_last = fn {left}:
has_spread_not_last = fn {left}:
match left:
{type: 'array', exprs: 1 < length ?}:
idx = find_index left.exprs, fn expr:
Expand All @@ -26,7 +27,8 @@ is_spread_not_last = fn {left}:
else: false

exprs_len = length left.exprs
idx > -1 and idx < exprs_len - 1
# TODO: add support for -1 < idx < exprs_len - 1
-1 < idx and idx < exprs_len - 1
else:
false

Expand Down Expand Up @@ -114,7 +116,7 @@ transform_spread_right = fn expr, ctx:

transform_assign = fn node, ctx:
match node:
is_spread_not_last ?:
has_spread_not_last ?:
left = transform_spread_left node, ctx
right = transform_spread_right node, ctx
assignmentExpression '=', left, right
Expand Down
16 changes: 13 additions & 3 deletions src/lang/comparison/index.fnk
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{binaryExpression} = import '@babel/types'
{binaryExpression, logicalExpression} = import '@babel/types'

{add, any} = import '../context'


transform_op = dict:
'==': '==='
'!=': '!=='
Expand All @@ -11,9 +12,18 @@ transform_comp = fn {op, left, right}, {transform}:
{(op): operator=op} = transform_op

bin_left = transform left
bin_right = transform right

binaryExpression operator, bin_left, bin_right
match left:
{op: ? in ['<', '>', '<=', '>=', '==', '!=']}:
bin_right = binaryExpression
operator
bin_left.right
transform right

logicalExpression '&&', bin_left, bin_right
else:
bin_right = transform right
binaryExpression operator, bin_left, bin_right


add_comparison = fn ctx:
Expand Down
Loading

0 comments on commit 9c87a0f

Please sign in to comment.