Read defs.txt file from package.
This commit is contained in:
parent
d96f0bbb99
commit
31cd926ab4
|
|
@ -1,3 +1,4 @@
|
||||||
include archive/*
|
include archive/*
|
||||||
include LICENSE
|
include LICENSE
|
||||||
|
include joy/defs.txt
|
||||||
recursive-include joy *.py
|
recursive-include joy *.py
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Thun. If not see <http://www.gnu.org/licenses/>.
|
# along with Thun. If not see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
import sys
|
import argparse, io, pkg_resources
|
||||||
from .library import initialize, inscribe
|
from .library import initialize, inscribe
|
||||||
from .joy import repl, interp
|
from .joy import repl, interp
|
||||||
from .utils.pretty_print import trace
|
from .utils.pretty_print import trace
|
||||||
|
|
@ -25,7 +25,38 @@ from .utils.pretty_print import trace
|
||||||
|
|
||||||
inscribe(trace)
|
inscribe(trace)
|
||||||
|
|
||||||
if '-q' in sys.argv:
|
|
||||||
|
argparser = argparse.ArgumentParser(
|
||||||
|
prog='thun',
|
||||||
|
description='Joy Interpreter',
|
||||||
|
)
|
||||||
|
argparser.add_argument(
|
||||||
|
'-d', '--defs',
|
||||||
|
action='append',
|
||||||
|
default=[
|
||||||
|
io.TextIOWrapper(
|
||||||
|
pkg_resources.resource_stream(__name__, 'defs.txt'),
|
||||||
|
encoding='UTF_8',
|
||||||
|
)
|
||||||
|
],
|
||||||
|
type=argparse.FileType('r', encoding='UTF_8'),
|
||||||
|
help=(
|
||||||
|
'Add additional definition files.'
|
||||||
|
' Can be used more than once.'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
argparser.add_argument(
|
||||||
|
'-q', '--quiet',
|
||||||
|
help='Don\'t show the prompt.',
|
||||||
|
default=False,
|
||||||
|
action='store_true',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
args = argparser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
if args.quiet:
|
||||||
j = interp
|
j = interp
|
||||||
else:
|
else:
|
||||||
j = repl
|
j = repl
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,115 @@
|
||||||
|
-- 1 -
|
||||||
|
? dup bool
|
||||||
|
&& nulco [nullary [false]] dip branch
|
||||||
|
++ 1 +
|
||||||
|
|| nulco [nullary] dip [true] branch
|
||||||
|
!- 0 >=
|
||||||
|
<{} [] swap
|
||||||
|
<<{} [] rolldown
|
||||||
|
abs dup 0 < [] [neg] branch
|
||||||
|
anamorphism [pop []] swap [dip swons] genrec
|
||||||
|
app1 grba infrst
|
||||||
|
app2 [grba swap grba swap] dip [infrst] cons ii
|
||||||
|
app3 3 appN
|
||||||
|
appN [grabN] codi map disenstacken
|
||||||
|
at drop first
|
||||||
|
average [sum] [size] cleave /
|
||||||
|
b [i] dip i
|
||||||
|
binary unary popd
|
||||||
|
ccccons ccons ccons
|
||||||
|
ccons cons cons
|
||||||
|
clear stack bool [pop stack bool] loop
|
||||||
|
cleave fork popdd
|
||||||
|
clop cleave popdd
|
||||||
|
codi cons dip
|
||||||
|
codireco codi reco
|
||||||
|
dinfrirst dip infrst
|
||||||
|
dipd [dip] codi
|
||||||
|
disenstacken ? [uncons ?] loop pop
|
||||||
|
down_to_zero [0 >] [dup --] while
|
||||||
|
drop [rest] times
|
||||||
|
dupd [dup] dip
|
||||||
|
dupdd [dup] dipd
|
||||||
|
dupdip dupd dip
|
||||||
|
dupdipd dup dipd
|
||||||
|
enstacken stack [clear] dip
|
||||||
|
flatten <{} [concat] step
|
||||||
|
fork [i] app2
|
||||||
|
fourth rest third
|
||||||
|
gcd true [tuck mod dup 0 >] loop pop
|
||||||
|
genrec [[genrec] ccccons] nullary swons concat ifte
|
||||||
|
grabN <{} [cons] times
|
||||||
|
grba [stack popd] dip
|
||||||
|
hypot [sqr] ii + sqrt
|
||||||
|
ifte [nullary] dipd swap branch
|
||||||
|
ii [dip] dupdip i
|
||||||
|
infra swons swaack [i] dip swaack
|
||||||
|
infrst infra first
|
||||||
|
make_generator [codireco] ccons
|
||||||
|
mod %
|
||||||
|
neg 0 swap -
|
||||||
|
not [true] [false] branch
|
||||||
|
nulco [nullary] cons
|
||||||
|
nullary [stack] dinfrirst
|
||||||
|
of swap at
|
||||||
|
pam [i] map
|
||||||
|
pm [+] [-] clop
|
||||||
|
popd [pop] dip
|
||||||
|
popdd [pop] dipd
|
||||||
|
popop pop pop
|
||||||
|
popopop pop popop
|
||||||
|
popopd [popop] dip
|
||||||
|
popopdd [popop] dipd
|
||||||
|
product 1 swap [*] step
|
||||||
|
quoted [unit] dip
|
||||||
|
range [0 <=] [1 - dup] anamorphism
|
||||||
|
range_to_zero unit [down_to_zero] infra
|
||||||
|
reco rest cons
|
||||||
|
rest [pop] infra
|
||||||
|
reverse <{} shunt
|
||||||
|
roll> swap swapd
|
||||||
|
roll< swapd swap
|
||||||
|
rollup roll>
|
||||||
|
rolldown roll<
|
||||||
|
rrest rest rest
|
||||||
|
run <{} infra
|
||||||
|
second rest first
|
||||||
|
shift uncons [swons] dip
|
||||||
|
shunt [swons] step
|
||||||
|
size [pop ++] step_zero
|
||||||
|
spiral_next [[[abs] ii <=] [[<>] [pop !-] ||] &&] [[!-] [[++]] [[--]] ifte dip] [[pop !-] [--] [++] ifte] ifte
|
||||||
|
split_at [drop] [take] clop
|
||||||
|
split_list [take reverse] [drop] clop
|
||||||
|
sqr dup *
|
||||||
|
stackd [stack] dip
|
||||||
|
step_zero 0 roll> step
|
||||||
|
sum [+] step_zero
|
||||||
|
swapd [swap] dip
|
||||||
|
swons swap cons
|
||||||
|
swoncat swap concat
|
||||||
|
tailrec [i] genrec
|
||||||
|
take [] roll> [shift] times pop
|
||||||
|
ternary binary popd
|
||||||
|
third rest second
|
||||||
|
tuck dup swapd
|
||||||
|
unary nullary popd
|
||||||
|
uncons [first] [rest] cleave
|
||||||
|
unit [] cons
|
||||||
|
unquoted [i] dip
|
||||||
|
unswons uncons swap
|
||||||
|
while swap nulco dupdipd concat loop
|
||||||
|
x dup i
|
||||||
|
step [_step0] x
|
||||||
|
_step0 _step1 [popopop] [_stept] branch
|
||||||
|
_step1 [?] dipd roll<
|
||||||
|
_stept [uncons] dipd [dupdipd] dip x
|
||||||
|
times [_times0] x
|
||||||
|
_times0 _times1 [popopop] [_timest] branch
|
||||||
|
_times1 [dup 0 >] dipd roll<
|
||||||
|
_timest [[--] dip dupdipd] dip x
|
||||||
|
map [_map0] cons [[] [_map?] [_mape]] dip tailrec
|
||||||
|
_map? pop bool not
|
||||||
|
_mape popd reverse
|
||||||
|
_map0 [_map1] dipd _map2
|
||||||
|
_map1 stackd shift
|
||||||
|
_map2 [infrst] cons dipd roll< swons
|
||||||
3
setup.py
3
setup.py
|
|
@ -37,6 +37,9 @@ setup(
|
||||||
url='https://joypy.osdn.io',
|
url='https://joypy.osdn.io',
|
||||||
license='GPLv3+',
|
license='GPLv3+',
|
||||||
packages=['joy', 'joy.utils'],
|
packages=['joy', 'joy.utils'],
|
||||||
|
package_data={
|
||||||
|
'joy': ['defs.txt'],
|
||||||
|
},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 4 - Beta',
|
'Development Status :: 4 - Beta',
|
||||||
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
|
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue