Skip to content

Commit

Permalink
feat(deps): upgrade larix
Browse files Browse the repository at this point in the history
BREAKING CHANGE: upgrade to lates larix introduced changes to expr types and ops
  • Loading branch information
kollhof committed May 1, 2020
1 parent 77528af commit faa5b68
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/lang/arithmitic/index.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
add_arithmitic = fn ctx:
pipe ctx:
add:: 'arithm', any, transform_binary
add:: 'arithm_right', any, transform_binary
add:: 'arithm_prefix', any, transform_unary
add:: 'arithm:right', any, transform_binary
add:: 'arithm:prefix', any, transform_unary

10 changes: 5 additions & 5 deletions src/lang/conditionals/match.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ match_props = fn props, emit_result, ctx, cond:
[{id, prop}, ...rest] = props

value = match prop:
{key: {type: 'spread'}}:
prop.key
{left: {type: 'spread'}}:
prop.left
else:
prop.value
prop.right

emit = match props:
{length: 1}: emit_result
Expand All @@ -63,7 +63,7 @@ match_obj = fn value, obj, emit_result, ctx, cond:
... pipe id_props:
map {id, prop}:
match prop:
{key: {type: 'spread'}}:
{left: {type: 'spread'}}:
restElement:: id
else:
[computed, key] = get_key:: prop, ctx
Expand Down Expand Up @@ -184,7 +184,7 @@ match_all = fn value, matches, emit, ctx:
[condition, result] = split_condition:: expr

js_expr = match condition:
{value: 'else'}:
{type: 'literal', value: 'else'}:
js_expr = emit:: result
wrap_with_comment_loc:: js_expr, condition
else:
Expand Down
2 changes: 1 addition & 1 deletion src/lang/generic/unary.fnk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{unaryExpression} = import '@babel/types'


transform_unary= fn node, {transform}:
transform_unary = fn node, {transform}:
right = transform:: node.right
unaryExpression:: node.op, right
5 changes: 4 additions & 1 deletion src/lang/literals/index.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
{transform_regex} = import './regex'
{transform_array} = import './array'
{transform_object, transform_prop} = import './object'
{transform_keyword} = import './keywords'



add_literals = fn ctx:
Expand All @@ -14,4 +16,5 @@ add_literals = fn ctx:
add:: 'regex', any, transform_regex
add:: 'array', any, transform_array
add:: 'object', any, transform_object
add:: 'prop', any, transform_prop
add:: 'object:prop', any, transform_prop
add:: 'literal', any, transform_keyword
12 changes: 6 additions & 6 deletions src/lang/literals/object.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ str_key = fn {value, loc}:
{...str, loc}


get_key = fn {key}, ctx:
get_key = fn {left: key}, ctx:
match key:
{type: 'group'}:
[true, ctx.transform:: key]
Expand All @@ -25,16 +25,16 @@ get_key = fn {key}, ctx:

transform_prop = fn node, ctx:
match node:
{key: {type: 'spread'}}:
ctx.transform:: node.key
{left: {type: 'spread'}}:
ctx.transform:: node.left
else:
[computed, key] = get_key:: node, ctx
value = ctx.transform:: node.value
value = ctx.transform:: node.right

shorthand = node.key == node.value
shorthand = node.left == node.right

final_value = match node:
{value: {type: 'assign'}}:
{right: {type: 'assign'}}:
assignmentPattern:: value.left, value.right
else:
value
Expand Down
2 changes: 1 addition & 1 deletion src/lang/literals/regex.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@


transform_regex = fn node:
pattern = node.pattern.replace:: rx/(\#.*\n)|[\n\s]/gm, ''
pattern = node.value.replace:: rx/(\#.*\n)|[\n\s]/gm, ''

regExpLiteral:: pattern, node.flags
14 changes: 8 additions & 6 deletions src/lang/literals/string.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@


transform_string = fn node, {transform}:
[...quasies] = pipe node.parts.filter:: fn part, idx: idx % 2 == 0:
map part: templateElement::
{raw: part.value.replace(rx/\\([\s\S])|(`)/g, '\\$1$2')}
{exprs: parts, tag=null} = node

[...quasies] = pipe parts:
filter part: part.type == 'string:text'
map part:
templateElement:: {raw: part.value.replace(rx/\\([\s\S])|(`)/g, '\\$1$2')}

[...expressions] = pipe node.parts.filter:: fn part, idx: idx % 2 == 1:
map part:transform:: part
[...expressions] = pipe parts:
filter part: part.type != 'string:text'
map part: transform:: part

templ_str = templateLiteral:: quasies, expressions
{tag=null} = node

match tag:
null: templ_str
Expand Down

0 comments on commit faa5b68

Please sign in to comment.