Commit 2a4bc948 authored by Ole Voldsæter's avatar Ole Voldsæter
Browse files

transformations for numlists and ranges

parent ca2f00c2
......@@ -259,7 +259,28 @@
}))
:filelist (fn [& args] args)
:varlist (fn [& args] args)
:numlist (fn [& args] args)
:numlist (fn [& args]
{"$type" "NumberListExpression"
:values args}
)
:simple_range (fn [& [from to]]
{"$type" "NumberRangeExpression"
:from from
:to to
:step 1}
)
:step_range (fn [& [from step to]]
{"$type" "NumberRangeExpression"
:from from
:to to
:step step}
)
:diff_step_range (fn [& [from second to]]
{"$type" "NumberRangeExpression"
:from from
:to to
:step (- second from)}
)
:varRange (fn [& args] {:first (first args) :last (second args)})
:rules (fn [& args] args)
:simple_rules (fn [& args] args)
......
......@@ -234,6 +234,28 @@
)
"Should return a collapse object. Variable 'e' must be first in :mod-varlist"
)
(is
(=
(parse-and-transform "append using a, test_option(1 2/4 5 (2) 9 10 13 : 19) ")
'{:command "append"
:files ("a")
:mod-varlist ()
:options {:test_option ({"$type" "NumberListExpression"
:values (1
{"$type" "NumberRangeExpression"
:from 2
:step 1
:to 4}
{"$type" "NumberRangeExpression"
:from 5
:step 2
:to 9}
{"$type" "NumberRangeExpression"
:from 10
:step 3
:to 19})})}}
)
)
)
(deftest expand-macros-test
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment