From 73b930753f096a844b6e74ab20d7e9ea93e2c4dd Mon Sep 17 00:00:00 2001 From: DaRubyMiner360 <55484201+DaRubyMiner360@users.noreply.github.com> Date: Thu, 16 Dec 2021 17:21:34 +0000 Subject: [PATCH] Push for changing PCs. --- CHANGELOG.md | 12 +- ParaCode.py | 5 +- doc/70_console.md | 2 +- error.py | 12 +- examples/exceptions.para | 35 +- .../__pycache__/basic_object.cpython-38.pyc | Bin 0 -> 3304 bytes .../__pycache__/basic_value.cpython-38.pyc | Bin 0 -> 2351 bytes .../__pycache__/function.cpython-38.pyc | Bin 0 -> 1864 bytes .../__pycache__/interpreter.cpython-38.pyc | Bin 0 -> 23530 bytes interpreter/__pycache__/scope.cpython-38.pyc | Bin 0 -> 2198 bytes interpreter/__pycache__/stack.cpython-38.pyc | Bin 0 -> 810 bytes .../__pycache__/variable.cpython-38.pyc | Bin 0 -> 758 bytes .../env/__pycache__/builtins.cpython-38.pyc | Bin 0 -> 79296 bytes .../env/__pycache__/globals.cpython-38.pyc | Bin 0 -> 24845 bytes .../builtin/__pycache__/arith.cpython-38.pyc | Bin 0 -> 3500 bytes .../builtin/__pycache__/time.cpython-38.pyc | Bin 0 -> 673 bytes interpreter/env/builtins.py | 618 +++++++++++++----- interpreter/env/globals.py | 25 +- interpreter/interpreter.py | 270 +++++--- .../__pycache__/basic_type.cpython-38.pyc | Bin 0 -> 2003 bytes parse/__pycache__/node.cpython-38.pyc | Bin 0 -> 10143 bytes parse/__pycache__/parser.cpython-38.pyc | Bin 0 -> 17305 bytes .../source_location.cpython-38.pyc | Bin 0 -> 654 bytes parse/parser.py | 22 +- repl/__pycache__/repl.cpython-38.pyc | Bin 0 -> 6664 bytes std/cryptography/fernet.para | 2 +- std/io.para | 20 +- std/io/console.para | 36 +- std/math.para | 15 +- std/math/random.para | 55 +- std/numpara.para | 2 +- std/os.para | 214 ++---- std/regex.para | 319 +++------ std/requests.para | 85 +-- std/scipara.para | 2 +- std/types/exceptions/exception.para | 35 +- std/types/str.para | 81 +-- std/types/timedelta.para | 9 - std/types/tk.para | 102 +-- util.py | 17 + 40 files changed, 1024 insertions(+), 971 deletions(-) create mode 100644 interpreter/__pycache__/basic_object.cpython-38.pyc create mode 100644 interpreter/__pycache__/basic_value.cpython-38.pyc create mode 100644 interpreter/__pycache__/function.cpython-38.pyc create mode 100644 interpreter/__pycache__/interpreter.cpython-38.pyc create mode 100644 interpreter/__pycache__/scope.cpython-38.pyc create mode 100644 interpreter/__pycache__/stack.cpython-38.pyc create mode 100644 interpreter/__pycache__/variable.cpython-38.pyc create mode 100644 interpreter/env/__pycache__/builtins.cpython-38.pyc create mode 100644 interpreter/env/__pycache__/globals.cpython-38.pyc create mode 100644 interpreter/env/builtin/__pycache__/arith.cpython-38.pyc create mode 100644 interpreter/env/builtin/__pycache__/time.cpython-38.pyc create mode 100644 interpreter/typing/__pycache__/basic_type.cpython-38.pyc create mode 100644 parse/__pycache__/node.cpython-38.pyc create mode 100644 parse/__pycache__/parser.cpython-38.pyc create mode 100644 parse/__pycache__/source_location.cpython-38.pyc create mode 100644 repl/__pycache__/repl.cpython-38.pyc diff --git a/CHANGELOG.md b/CHANGELOG.md index 29bd24c..b152eb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - Support for variables in the `catch` statement +- More errors - Complete requests HTTP library -- Complete regex support - Better interfacing with python code from ParaCode +- The ability to use keyword arguments when calling a function +- **kwargs (Keyword Arguments) + +## [2.1.0] - CURRENTLY UNRELEASED +### Added - Easy use of default parameters in functions +- *args (Non-Keyword Arguments) +- Complete regex support ## [2.0.1] - 2021-10-18 ### Fixed @@ -41,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security - PCPM package uploading doesn't require a login -[Unreleased]: https://github.com/DaRubyMiner360/ParaCode/compare/2.0.1...HEAD +[Unreleased]: https://github.com/DaRubyMiner360/ParaCode/compare/2.1.0...HEAD +[2.1.0]: https://github.com/DaRubyMiner360/ParaCode/compare/2.0.1...2.1.0 [2.0.1]: https://github.com/DaRubyMiner360/ParaCode/compare/2.0.0...2.0.1 [2.0.0]: https://github.com/DaRubyMiner360/ParaCode/releases/tag/2.0.0 diff --git a/ParaCode.py b/ParaCode.py index 62e3258..d6ef94b 100644 --- a/ParaCode.py +++ b/ParaCode.py @@ -16,8 +16,8 @@ class ParaCode(): initialized = False # Language Info - version = "2.0.1" - release_stage = "stable" + version = "2.1.0" + release_stage = "development" def __init__(self): ParaCode.instance = self @@ -59,7 +59,6 @@ def eval(self, data=None, filename=None, interpret=True, default_imports=['std/_ return_code = None if interpret: - # init interpreter and visit nodes self.interpreter = Interpreter(source_loc) diff --git a/doc/70_console.md b/doc/70_console.md index 6001a24..f91e73b 100644 --- a/doc/70_console.md +++ b/doc/70_console.md @@ -6,7 +6,7 @@ extended from the `Console` object. The `io` module is included by default as it is imported from within the -standard __core__ module, so you don't have to +standard \_\_core\_\_ module, so you don't have to import any modules manually in order to start using it. diff --git a/error.py b/error.py index cb123d8..6abc35f 100644 --- a/error.py +++ b/error.py @@ -2,7 +2,7 @@ from util import LogColor class InterpreterError(Exception): - def __init__(self, m, node=None, type=None, message=None, cont=False, name=None, classnames=None): + def __init__(self, m, node=None, type=None, message=None, cont=False, name=None, classnames=None, object=None): super().__init__(m) self.node = node self.type = type @@ -10,6 +10,7 @@ def __init__(self, m, node=None, type=None, message=None, cont=False, name=None, self.cont = cont self.name = name self.classnames = classnames + self.object = object class ErrorType(Enum): Exception = auto() @@ -21,7 +22,7 @@ class ErrorType(Enum): MacroExpansionError = auto() class Error(): - def __init__(self, type, location, message, filename, name=None): + def __init__(self, type, location, message, filename, name="Exception"): self.type = type self.filename = filename self.message = message @@ -50,9 +51,10 @@ def location_col(self): return self.location[0] def __repr__(self): - nstr = f"{self.location_filename}:{self.location_row}:{self.location_col}: {LogColor.Error}{self.type.name} error:{LogColor.Default}" - if self.type == ErrorType.Exception: - nstr = f"{self.location_filename}:{self.location_row}:{self.location_col}: {LogColor.Error}{self.name}:{LogColor.Default}" + nstr = f"{self.location_filename}:{self.location_row}:{self.location_col}: {LogColor.Error}{self.name}:{LogColor.Default}" + # nstr = f"{self.location_filename}:{self.location_row}:{self.location_col}: {LogColor.Error}{self.type.name} error:{LogColor.Default}" + # if self.type == ErrorType.Exception: + # nstr = f"{self.location_filename}:{self.location_row}:{self.location_col}: {LogColor.Error}{self.name}:{LogColor.Default}" return f"{LogColor.Bold}{nstr}{LogColor.Default} {self.message}" __str__ = __repr__ diff --git a/examples/exceptions.para b/examples/exceptions.para index 9d1a22a..bc3a5d2 100644 --- a/examples/exceptions.para +++ b/examples/exceptions.para @@ -1,23 +1,24 @@ try { // Comment below line, change the exception to MultipleDefinitionError, TypeError, ArgumentError, MacroExpansionError, or Exception - ArgumentError.new("A").raise(); + MultipleDefinitionError.new("AIEVN").raise(); print("TRY"); } -catch MultipleDefinitionError { +catch MultipleDefinitionError e { print("CATCH MultipleDefinitionError"); + print(e.type()); } -catch [TypeError, ArgumentError] { - print("CATCH ArgumentError/TypeError"); -} -catch MacroExpansionError { - print("CATCH MacroExpansionError"); -} -catch { - print("CATCH Any Exception"); -} -else { - print("ELSE"); -} -finally { - print("FINALLY"); -} +//catch [TypeError, ArgumentError] { +// print("CATCH ArgumentError/TypeError"); +//} +//catch MacroExpansionError { +// print("CATCH MacroExpansionError"); +//} +//catch { +// print("CATCH Any Exception"); +//} +//else { +// print("ELSE"); +//} +//finally { +// print("FINALLY"); +//} diff --git a/interpreter/__pycache__/basic_object.cpython-38.pyc b/interpreter/__pycache__/basic_object.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..924b6937fe2a803b901fd3e8a65c8f7d28c0d8c9 GIT binary patch literal 3304 zcmb7G&u`R56rLH|yNW=J@tDtyTqGtsihgu*l%XueD8Zdp0?W&!?W_&UiY6CV}H`5 z{`i>OL(`AYNhW!p4S2#ijYVG!yu`C(ukR0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ZWwO;cK82&(50P9xlL?@FDEv-r+jk(~9z6(uHAFHv>3PpNZ~ zhA90YA^G;=Upr^5{K^Ay;G9T6aMTrc#Ptn=g2olL7Biiuwfb8-&?5J zaqOAK)<_MyrSVn1qnz7+ER~?VBY`x1NebG6;!L&S1Y#;s*Eiw?MU+z?;ib)5H)nZIz$Dn2xu1|Y&CP@ a4|YU4neeVFg1;k*X{yRwDA8J?6Z{7WO1FXl literal 0 HcmV?d00001 diff --git a/interpreter/__pycache__/basic_value.cpython-38.pyc b/interpreter/__pycache__/basic_value.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..290e207684cdc14add7be4578a3c653b5ddd4db4 GIT binary patch literal 2351 zcmb7GJ#QmL7@pY=d%a%g!;V5YKyq;iS%RcN0-+N+a$FDv1`(iGoitkSjB}f;cg^e= zlHhCb(NR!Q#}du`2Yv?Cv{Xp^0xI5j)=t*Rxwy6F>zR-DnfGh_ZL8%I_Ox1IN>xUBO20?6R%(x&(4pir!foz6C)}A?q08N4(yRRgdq~gH zyZxMtqe&L4B+nk7kEJLI=;;RHUqrFYdsJ^8PLfn5*>YWso2#D%gNIOxZ=ez+q@08n zr`&o@Lc0_mI^5+o7`wdAJ!osZ!F_1!yvYM-J>KFQ&^Guc--6cX+q?~JlXrmdj`k0u zB8k6?(us&s-txmfs^SrpVgsrvxgt|Kr>KNu@`Co^20;YZI?31%xc!BtokFBT?Uq9# zo3QP_4-cN^BXJ-nStjJcSCNb!fezmLTKp&zB@U8I2?_dv`e1-m%ER`@7usVi$r8nw ziyRC&dfB<*yT6=YPkd`Zd=AvF$ef&6$3)fu1oAC$u4ELeQee-L4ZyXVtEWO5>SYxm z+KThhIFh1V3vP4GXRpF%Wzii{cmbnL^uH;c5@s~Hpd%5Lc=9dTvJMz(a;bsWDiW*u zk0~r#e%QY@-+dTN$tj3CYsjtw(WgXNGfQ@{cV*APpi?L%6~|D~eo`b^p`t7n5)Gi+ zOMMN{Or?#fQQB?BZCH*jQ=p~^-KD;D`BsJX-GkP1e-lnn$etR;yVzSYKBYIDw_#nW zLnJFvyzF3ws=KkInb-kn!7V^;RU0n3nftBS5Y_2GF*e)*1!E*)a(D)bL0Le|R*(wh zee7Mi7%Rt1yf(9n2a7dzSaSsK=yAKUq5EBGehe;K^7f^Px-ufcu9kqx+y_ZyX#L7QgvHV>}aQ!=MB`ZHuF z$SAG8MBjt>Y8s1wIXD%u(hep$?V8jV+Q&+U_UD-j-J>**p!r0~=puAJO=1-~hk2fc zPJfc7m#@e9B<0;KSKSk#y6R#qy2D&{e|pyI=)Fqr*f&neawAQmf#s@4=w_PdXOl6* zGbF~ML}TjCFv&QCwM?Qxx`=Oyrq&Lw)OMkywn371hsaesX;MJVfvR=}Kvg#$pT}a1 znO@g`+$d5#yG$m*NtzF$lofFfLJg~1?zjh%?m;Qug^JL?3TQz0s1LPIH`Wy6w7Zpn zs$A_(B(0>KGLmN3abua#F5~7U(W2cr%`@>n5?tipt%_JP`KkinfWy`ctTP4*XY7ND z$aY2KV)_+@YDbE(TrU+~8eG8GM-{QFFHJe$?*;fQWzk45rhUdnIiG;rFdZ=V{Ul1u z8QH>1;^Skox5R{4rX;kt#C$B@#_AocZd}6j@WC-=LH{gpt4BTC{Aym!yN5k9-|yA5 s53f=o_A_`=OQ$xjyHkyf;o@(I@%Pf+FOjId2jyKp#_%mr_7=F~|2*mgqW}N^ literal 0 HcmV?d00001 diff --git a/interpreter/__pycache__/function.cpython-38.pyc b/interpreter/__pycache__/function.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2db0dddc92419a4c58a1dd4ea138e0dc7ecdb1d3 GIT binary patch literal 1864 zcmZ`)NpBM|6t-tcCP_ng#IAD8fd(OQ15~JhTZE{%1R-lWcImXqOt3xBhH#<%A?>lh zfq&vF|AG_mc{0;<(mL`RKQC|j-jYx4c9Xz3{S$`k9wC2`nH{i4wqUAfK;9EhI6Z}V z;`EVoxC@*s$cfvhzTt3{E@-dg8ZQZl!nCB& znM{~I9tqe=x#)PtQ(~|uT@WBqr1XJY5Lt)MzvtckbSSzqOA;ZwA3_;!!=oo3#Sa;4 z(Tx)=kowGlur58W2Kj@Eb1|o@^F3B8sQefoq)BB{YUp0Kn-< z+_V;5P>JH~Iwt|Js8EWLWDE}#Y9&{d<)=LalQG1CG1FvhnDT6Z>jlQXW#J${kqvk+ zTR=>mF{MH7j6wuPqE>4aT4p^AXy65o-Mcy9YjAr$;NYWY?!3w3fsT^`q1W;OJa2_!70|J4QN0m@;77q z6i(-{&5Mcqyaq+(^EwaUTNAZ@oi_mYrdh0*JXd3wQZ^y)!9tTWs4@T@YU|viEMu*_CO}2$OyFo839CXR4$e22>H~ERh%dt zCXui)F^#uJkr-izlIU5-vHltlWmViX9%{pOHSG&c8qo1tMVmEg&dW0KF*`5{ht4#~ zt&&2mpXz-ft9si}Ivj;kuoiy|FAoKrq~bFM*^SYsMr2NmwY^jhL!Eb7OzDbsw%I(IvFV!77cDHfwtnuSQ1r@*l8aY$T=p#NKv>=it*|}I l4_xS5xDS66dHQ0Z*_|0POA#h`k+;oPw)bJS-fAq>{{s>gaVY=* literal 0 HcmV?d00001 diff --git a/interpreter/__pycache__/interpreter.cpython-38.pyc b/interpreter/__pycache__/interpreter.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..658361d86fc1750f0ea503118160d22a1eeaa4cb GIT binary patch literal 23530 zcmb_^3y@pac^>Wqz{PX1%jI&pd_1Ts0G#_dFI#?v}(>ZqxwP14qFGj68ScAQ&Jrgd63?zpa- zc+yl&oqpecE`SRxNLill4$eLIydVGj{O7(umrKX+_n!BEwDRdM#bSTJm*}61m!tS~ zzK=k~l+}net&(LiZa3_vQ*xSa$!*32zSh4rS)RZc`6jO!j zZ5vMMAl|3d4Blrp?9%OO$LZMO>~}He*sE5Mc&eg1RlVp0$zvUVsjaGk$MDRR)oL)q z*r~PFvR`Yrp04_9y0vHp`P1z+yAE-3en3;S}qkXp0V5RH_D!NuV z+mKPB$Czzg_P5y4E^}La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cu!(`P!{F9887AS_0nDeu>xC= zewG&R(Eo*<687;qKT$Av8B24Yb({fFBG_rN#=az?$)ZZr5sCV+k&s4{_)%5)z-nnW zTC^|bXcAfB0;PS?d|bwbH}GLYsO4sEmfg)q%b3hifG5KVc5Tl#Ru^)o(nxN#b?LDA z&}YYd#C2qN1Cs*j)M&4)7z)%K!^22SgLs4AQ#O|v1=Wc$=D2_xYM9?VWA`u+VUxQ( m2@C@7i1{+|!$iGK5dmdJT#BU%1-lP#9-Ds}=;!T%^Zx)lA1M<6 literal 0 HcmV?d00001 diff --git a/interpreter/__pycache__/scope.cpython-38.pyc b/interpreter/__pycache__/scope.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0196696ca09c8c6ca14e118a5bbd230ed4672f03 GIT binary patch literal 2198 zcmbVN&2HO95Z)h3qG(BR{MWijTO(+T@(>Hiu`mjw23+(a1Qpr>x)3yX-BOV#bx9?# zs+{ZxagKh5z6q~A^%Z*RH%pTi75CD$XS72Ocfa{&cJ`-k*JBtre}>^N4aWW=V|_R< zP9fVcJ%G||#1$I}EKOVSkyIQDHF9rwHNBWken>87gNP88gXRKq z21!4GTJaSN*h)b2OswQJ*;26~yW<1j$y;wilY~>9yGlos>}swJeV=#V5WL{63FmkO zM<>;jO9O_OX_7<3I@~cs^!@X)|J!V;`(}|O+Vo$ACOn%d{o+Uc*2J0a$4REm+-T^2 z8qMbVcz%_;K@cZ#76b%3r9~NU;%~Y85Z!U<0krnNy1r;zj&RK@?(ihrAAB-EyN)KELBtvqC=sdm+t z>R{GVd#bB?n7QhS+P-0a?i6vXyPVg8sFD4Wf~+)Z z(J#?F#Gy@}6X^)bHD6I6WFasF`;Y?5zD+-MjJqNQhQQ~INj#0S4djO04k4-Sd)(um z=y69ZKQ2Ij$k7MLDFwDnD0>C{AX|(pRKjjzxi!>;HX!7?^-V18luCOt8DAbg2E}^) zZ!FYa9>sD{$5M8|FW2BadkjwL7;$)(gXUFn()m*y#fhv@#(XhY?%Sn~l*X=c7SEFO zo1;J8;b=Eei_=%AZVNgY8^e>HlJJ=QX2QP_s^6fSfiY>#re=eP~G>9sxSNmm+r8$oJ= z+S(~3rGl*5DOUn*Q7Q>ioVgJ<{*23YxtwJd+qpwF7={?*ekSXj>L)~|20(A!nu1= STw>o+;n)t+5xr*bi+=&4D5?Me literal 0 HcmV?d00001 diff --git a/interpreter/__pycache__/stack.cpython-38.pyc b/interpreter/__pycache__/stack.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..348876237b77df1c73b9a0defcdc5278d983a63d GIT binary patch literal 810 zcmZuv!EV$r5FOjeHoLG0AwFO^fXIPH>VXp=qzZ9cAy!;+v8>pop}UE39B7yHLif%u zw8wq}f08Soz>O0#4qIBpL^GKg&-lHu{cbv)0LtdOQr{TB4+^e}z~Cina}UjH(4g4{ z^^E7B`2tc=VE%?&bv(kfft+c`xn`PgAQxKb2>+2z^hob)SRU&bcNzEb!mHw_Knhnv zK1bb0ZHVQ2=s+Tc1zfUu%KEsW9(1C{EDtWh#aQ%fFFUMPCUb378JE3LPVLv)Jb7zA zyV9Gith{m78MImG-?b-wB4t^XUP{7i$N*d436yrXOGQZ25(@b=XyA4ioen<0IqTR3 zV}YTgij+Gl>PO02Q)vt%3gb^|*_yz1FeA!Fwrvh+f-U}Jz^C;51~~0Wg#r92Is^Cx zobnD&`$)LGj(OhkGe*7_nw>{Oj07?Jm34G?e7=4dFlK?!<1eS_?7{PyIku+oM*q#G z@i2$5we2H+Vog7ObzB(h%ev}E2en%%pNe6+>9${nLVJ1?Rju14`M0I~*sA5Q;&!m#(c1`nUc;gDadfVZo)Kw7QNj|D Xh>*h<6#oBf>XT;!;0x;fi3+~~>+-3! literal 0 HcmV?d00001 diff --git a/interpreter/__pycache__/variable.cpython-38.pyc b/interpreter/__pycache__/variable.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ca3a318753b6a1cf0f658ff9dd5589957c8ca1c6 GIT binary patch literal 758 zcmYjP&5qPC3{K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`!nXM|{AWaCOo6BP1a1&ld);K@+{5=k#4(5af+Uayx{yWMPE(Lnto;(+L^UW zH@m53LZNyw9M$xFRH&cVtd~Blk{>GsA9OUo8+ClFSIfH!+tD+lsap4X!QHBLZefdh z#jqZWnhz1zYf-cGchuta_d)_aCF^HK}2-$fn)}uogqa^4iouto-fF>lM*4 zDhPlrg$P#iEQx_&zS%`q^&x<@?8kbLa{NQ%=IAB&N{NqfesNrRxK*&^ANB0-4srzi-DZBEX4lw0tAXx5t$6e{vVZp-|K zl>7>}RQv@hW_$r11+(%SkG^=^>NpAreaiX7Kijf>biwbsx!S-I6d<<*VZmQ$+~VR>F%V|Qb!!F- Quld>fj9^#psZ3?bZzissdjJ3c literal 0 HcmV?d00001 diff --git a/interpreter/env/builtins.py b/interpreter/env/builtins.py index ec87a9e..027710f 100644 --- a/interpreter/env/builtins.py +++ b/interpreter/env/builtins.py @@ -12,9 +12,9 @@ from interpreter.function import BuiltinFunction from interpreter.env.builtin.arith import * from interpreter.env.builtin.time import * -from parse.node import NodeFunctionExpression, NodeCall, NodeArgumentList, NodeMemberExpression, NodeNone +from parse.node import NodeFunctionExpression, NodeCall, NodeArgumentList, NodeMemberExpression, NodeNone, NodeSplatArgument from error import ErrorType -from util import LogColor +from util import LogColor, fixiter def obj_to_string(interpreter, node, obj): obj_str = str(obj) @@ -73,12 +73,7 @@ def builtin_console_write(arguments): interpreter = arguments.interpreter node = arguments.node - if len(arguments.arguments) > 1: - _print_object(interpreter, node, arguments.arguments[0].extract_value(), end=arguments.arguments[1].extract_value()) - elif len(arguments.arguments) > 0: - _print_object(interpreter, node, arguments.arguments[0].extract_value(), end='') - else: - _print_object(interpreter, node, "", end='') + _print_object(interpreter, node, arguments.arguments[0].extract_value(), end=arguments.arguments[1].extract_value()) return BasicValue(None) @@ -86,12 +81,7 @@ def builtin_printn(arguments): interpreter = arguments.interpreter node = arguments.node - if len(arguments.arguments) > 1: - _print_object(interpreter, node, arguments.arguments[0].extract_value(), end=arguments.arguments[1].extract_value()) - elif len(arguments.arguments) > 0: - _print_object(interpreter, node, arguments.arguments[0].extract_value()) - else: - _print_object(interpreter, node, "") + _print_object(interpreter, node, arguments.arguments[0].extract_value(), end=arguments.arguments[1].extract_value()) return BasicValue(None) @@ -107,20 +97,16 @@ def builtin_print_color(arguments): print(f"{LogColor.Info}", end="") elif color == 4: print(f"{LogColor.Bold}", end="") - return BasicValue(0) + return BasicValue(None) def builtin_exit(arguments): interpreter = arguments.interpreter node = arguments.node - if len(arguments.arguments) > 0: - return_code = arguments.arguments[0].extract_value() - exit(return_code) - else: - exit() + exit(arguments.arguments[0].extract_value()) - return BasicValue(0) + return BasicValue(None) def builtin_type_compare(arguments): interpreter = arguments.interpreter @@ -170,7 +156,7 @@ def builtin_to_float(arguments): return BasicValue(float(arguments.arguments[0].extract_value())) def builtin_str_len(arguments): - return BasicValue(len(str(arguments.arguments[0].extract_value()))) + return BasicValue(len(arguments.arguments[0].extract_value())) def builtin_array_len(arguments): return BasicValue(len(arguments.arguments[0].extract_value())) @@ -273,7 +259,7 @@ def builtin_str_replace(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() toReplace = str(arguments.arguments[1].extract_value()) replaceWith = str(arguments.arguments[2].extract_value()) @@ -291,7 +277,7 @@ def builtin_str_tolower(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = value.lower() return BasicValue(result) @@ -300,7 +286,7 @@ def builtin_str_toupper(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = value.upper() return BasicValue(result) @@ -309,86 +295,365 @@ def builtin_str_totitle(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = value.title() return BasicValue(result) +def builtin_regex_compile(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + pattern = arguments.arguments[0].extract_value() + flags = arguments.arguments[1].extract_value() + x = re.compile(pattern, flags) + + return BasicValue([[list(x.groupindex.keys()), list(x.groupindex.values())], x.groups, x.flags, x.pattern]) + def builtin_regex_search(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - regex = arguments.arguments[0].extract_value() - inputstr = arguments.arguments[1].extract_value() - x = re.search(regex, inputstr) + pattern = arguments.arguments[0].extract_value() + string = arguments.arguments[1].extract_value() + flags = arguments.arguments[2].extract_value() + x = re.search(pattern, string, flags) - return BasicValue([x.pos, x.endpos, [[list(x.re.groupindex.keys()), list(x.re.groupindex.values())], x.re.groups, x.re.flags, x.re.pattern], x.string, x.lastgroup, x.lastindex]) + regs = list(x.regs) + for i in range(len(regs)): + regs[i] = list(regs[i]) + return BasicValue([x.pos, x.endpos, [[list(x.re.groupindex.keys()), list(x.re.groupindex.values())], x.re.groups, x.re.flags, x.re.pattern], x.string, x.lastgroup, regs, x.lastindex]) -def builtin_regex_match_end(arguments): +def builtin_regex_match(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + pattern = arguments.arguments[0].extract_value() + string = arguments.arguments[1].extract_value() + flags = arguments.arguments[2].extract_value() + x = re.match(pattern, string, flags) + + regs = list(x.regs) + for i in range(len(regs)): + regs[i] = list(regs[i]) + return BasicValue([x.pos, x.endpos, [[list(x.re.groupindex.keys()), list(x.re.groupindex.values())], x.re.groups, x.re.flags, x.re.pattern], x.string, x.lastgroup, regs, x.lastindex]) + +def builtin_regex_fullmatch(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + pattern = arguments.arguments[0].extract_value() + string = arguments.arguments[1].extract_value() + flags = arguments.arguments[2].extract_value() + x = re.fullmatch(pattern, string, flags) + + regs = list(x.regs) + for i in range(len(regs)): + regs[i] = list(regs[i]) + return BasicValue([x.pos, x.endpos, [[list(x.re.groupindex.keys()), list(x.re.groupindex.values())], x.re.groups, x.re.flags, x.re.pattern], x.string, x.lastgroup, regs, x.lastindex]) + +def builtin_regex_split(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + pattern = arguments.arguments[0].extract_value() + string = arguments.arguments[1].extract_value() + maxsplit = arguments.arguments[2].extract_value() + flags = arguments.arguments[3].extract_value() + x = re.split(pattern, string, maxsplit, flags) + + return fixiter(x) + +def builtin_regex_findall(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + pattern = arguments.arguments[0].extract_value() + string = arguments.arguments[1].extract_value() + flags = arguments.arguments[2].extract_value() + x = re.findall(pattern, string, flags) + + return fixiter(x) + +def builtin_regex_finditer(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - regex = arguments.arguments[0].extract_value() - inputstr = arguments.arguments[1].extract_value() - x = re.search(regex, inputstr) + pattern = arguments.arguments[0].extract_value() + string = arguments.arguments[1].extract_value() + flags = arguments.arguments[2].extract_value() + x = re.finditer(pattern, string, flags) + + for i in range(len(x)): + regs = list(x[i].regs) + for j in range(len(regs)): + regs[j] = list(regs[j]) + x[i] = [x[i].pos, x[i].endpos, [[list(x[i].re.groupindex.keys()), list(x[i].re.groupindex.values())], x[i].re.groups, x[i].re.flags, x[i].re.pattern], x[i].string, x[i].lastgroup, regs, x[i].lastindex] + return fixiter(x) + +def builtin_regex_sub(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + pattern = arguments.arguments[0].extract_value() + repl = arguments.arguments[1].extract_value() + string = arguments.arguments[2].extract_value() + count = arguments.arguments[3].extract_value() + flags = arguments.arguments[4].extract_value() + x = re.sub(pattern, repl, string, count, flags) + + if type(x) != str: + regs = list(x.regs) + for i in range(len(regs)): + regs[i] = list(regs[i]) + return BasicValue([x.pos, x.endpos, [[list(x.re.groupindex.keys()), list(x.re.groupindex.values())], x.re.groups, x.re.flags, x.re.pattern], x.string, x.lastgroup, regs, x.lastindex]) + else: + return BasicValue(x) + +def builtin_regex_subn(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + pattern = arguments.arguments[0].extract_value() + repl = arguments.arguments[1].extract_value() + string = arguments.arguments[2].extract_value() + count = arguments.arguments[3].extract_value() + flags = arguments.arguments[4].extract_value() + x = re.subn(pattern, repl, string, count, flags) + + return fixiter(x) + +def builtin_regex_escape(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + pattern = arguments.arguments[0].extract_value() + x = re.escape(pattern) + + return BasicValue(x) + +def builtin_regex_purge(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + re.purge() + return BasicValue(None) + +def builtin_regex_match_end(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x = re.search(pattern, string, flags) + + if arguments.arguments[1].extract_value() is not None: + return BasicValue(x.end(arguments.arguments[1].extract_value())) return BasicValue(x.end()) def builtin_regex_match_group(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - regex = arguments.arguments[0].extract_value() - inputstr = arguments.arguments[1].extract_value() - x = re.search(regex, inputstr) - + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x = re.search(pattern, string, flags) + + if arguments.arguments[1].extract_value() is not None and arguments.arguments[1].extract_value() != []: + return BasicValue(x.group(*tuple(arguments.arguments[1].extract_value()))) return BasicValue(x.group()) def builtin_regex_match_groupdict(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - regex = arguments.arguments[0].extract_value() - inputstr = arguments.arguments[1].extract_value() - x = re.search(regex, inputstr) - + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x = re.search(pattern, string, flags) + + if arguments.arguments[1].extract_value() is not None: + [list(x.groupdict(arguments.arguments[1].extract_value()).keys()), list(x.groupdict(arguments.arguments[1].extract_value()).values())] return BasicValue([list(x.groupdict().keys()), list(x.groupdict().values())]) def builtin_regex_match_span(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - regex = arguments.arguments[0].extract_value() - inputstr = arguments.arguments[1].extract_value() - x = re.search(regex, inputstr) - + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x = re.search(pattern, string, flags) + + if arguments.arguments[1].extract_value() is not None: + return BasicValue(list(x.span(arguments.arguments[1].extract_value()))) return BasicValue(list(x.span())) def builtin_regex_match_groups(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - regex = arguments.arguments[0].extract_value() - inputstr = arguments.arguments[1].extract_value() - x = re.search(regex, inputstr) + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x = re.search(pattern, string, flags) + if arguments.arguments[1].extract_value() is not None: + return BasicValue(x.groups(arguments.arguments[1].extract_value())) return BasicValue(list(x.groups())) def builtin_regex_match_start(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - regex = arguments.arguments[0].extract_value() - inputstr = arguments.arguments[1].extract_value() - x = re.search(regex, inputstr) - + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x = re.search(pattern, string, flags) + + if arguments.arguments[1].extract_value() is not None: + return BasicValue(x.start(arguments.arguments[1].extract_value())) return BasicValue(x.start()) +def builtin_regex_match_expand(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x = re.search(pattern, string, flags) + + return BasicValue(x.expand(arguments.arguments[1].extract_value())) + +def builtin_regex_pattern_search(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x1 = re.compile(pattern, flags) + + x = x1.re.search(arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value(), arguments.arguments[3].extract_value()) + regs = list(x.regs) + for i in range(len(regs)): + regs[i] = list(regs[i]) + return BasicValue([x.pos, x.endpos, [[list(x.re.groupindex.keys()), list(x.re.groupindex.values())], x.re.groups, x.re.flags, x.re.pattern], x.string, x.lastgroup, regs, x.lastindex]) + +def builtin_regex_pattern_match(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x1 = re.compile(pattern, flags) + + x = x1.re.match(arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value(), arguments.arguments[3].extract_value()) + regs = list(x.regs) + for i in range(len(regs)): + regs[i] = list(regs[i]) + return BasicValue([x.pos, x.endpos, [[list(x.re.groupindex.keys()), list(x.re.groupindex.values())], x.re.groups, x.re.flags, x.re.pattern], x.string, x.lastgroup, regs, x.lastindex]) + +def builtin_regex_pattern_fullmatch(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x1 = re.compile(pattern, flags) + + x = x1.re.fullmatch(arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value(), arguments.arguments[3].extract_value()) + regs = list(x.regs) + for i in range(len(regs)): + regs[i] = list(regs[i]) + return BasicValue([x.pos, x.endpos, [[list(x.re.groupindex.keys()), list(x.re.groupindex.values())], x.re.groups, x.re.flags, x.re.pattern], x.string, x.lastgroup, regs, x.lastindex]) + +def builtin_regex_pattern_split(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x1 = re.compile(pattern, flags) + + x = x1.re.split(arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value()) + regs = list(x.regs) + for i in range(len(regs)): + regs[i] = list(regs[i]) + return BasicValue([x.pos, x.endpos, [[list(x.re.groupindex.keys()), list(x.re.groupindex.values())], x.re.groups, x.re.flags, x.re.pattern], x.string, x.lastgroup, regs, x.lastindex]) + +def builtin_regex_pattern_findall(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x1 = re.compile(pattern, flags) + + x = x1.re.findall(arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value(), arguments.arguments[3].extract_value()) + regs = list(x.regs) + for i in range(len(regs)): + regs[i] = list(regs[i]) + return BasicValue([x.pos, x.endpos, [[list(x.re.groupindex.keys()), list(x.re.groupindex.values())], x.re.groups, x.re.flags, x.re.pattern], x.string, x.lastgroup, regs, x.lastindex]) + +def builtin_regex_pattern_finditer(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x1 = re.compile(pattern, flags) + + x = x1.re.finditer(arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value(), arguments.arguments[3].extract_value()) + regs = list(x.regs) + for i in range(len(regs)): + regs[i] = list(regs[i]) + return BasicValue([x.pos, x.endpos, [[list(x.re.groupindex.keys()), list(x.re.groupindex.values())], x.re.groups, x.re.flags, x.re.pattern], x.string, x.lastgroup, regs, x.lastindex]) + +def builtin_regex_pattern_sub(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x1 = re.compile(pattern, flags) + + x = x1.re.sub(arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value(), arguments.arguments[3].extract_value()) + regs = list(x.regs) + for i in range(len(regs)): + regs[i] = list(regs[i]) + return BasicValue([x.pos, x.endpos, [[list(x.re.groupindex.keys()), list(x.re.groupindex.values())], x.re.groups, x.re.flags, x.re.pattern], x.string, x.lastgroup, regs, x.lastindex]) + +def builtin_regex_pattern_subn(arguments): + interpreter = arguments.interpreter + this_object = arguments.this_object + + args = arguments.arguments[0].extract_value() + pattern = args[0].extract_value() + flags = args[1].extract_value() + x1 = re.compile(pattern, flags) + + x = x1.re.subn(arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value(), arguments.arguments[3].extract_value()) + regs = list(x.regs) + for i in range(len(regs)): + regs[i] = list(regs[i]) + return BasicValue([x.pos, x.endpos, [[list(x.re.groupindex.keys()), list(x.re.groupindex.values())], x.re.groups, x.re.flags, x.re.pattern], x.string, x.lastgroup, regs, x.lastindex]) + def builtin_base64_b64encode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.b64encode(value) return BasicValue(result) @@ -397,7 +662,7 @@ def builtin_base64_b64decode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.b64decode(value) return BasicValue(result) @@ -406,7 +671,7 @@ def builtin_base64_standard_b64encode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.standard_b64encode(value) return BasicValue(result) @@ -415,7 +680,7 @@ def builtin_base64_standard_b64decode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.standard_b64decode(value) return BasicValue(result) @@ -424,7 +689,7 @@ def builtin_base64_urlsafe_b64encode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.urlsafe_b64encode(value) return BasicValue(result) @@ -433,7 +698,7 @@ def builtin_base64_urlsafe_b64decode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.urlsafe_b64decode(value) return BasicValue(result) @@ -442,7 +707,7 @@ def builtin_base64_b32encode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.b32encode(value) return BasicValue(result) @@ -451,7 +716,7 @@ def builtin_base64_b32decode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.b32decode(value) return BasicValue(result) @@ -460,7 +725,7 @@ def builtin_base64_b16encode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.b16encode(value) return BasicValue(result) @@ -469,7 +734,7 @@ def builtin_base64_b16decode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.b16decode(value) return BasicValue(result) @@ -478,7 +743,7 @@ def builtin_base64_a85encode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.a85encode(value) return BasicValue(result) @@ -487,7 +752,7 @@ def builtin_base64_a85decode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.a85decode(value) return BasicValue(result) @@ -496,7 +761,7 @@ def builtin_base64_b85encode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.b85encode(value) return BasicValue(result) @@ -505,7 +770,7 @@ def builtin_base64_b85decode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.b85decode(value) return BasicValue(result) @@ -514,7 +779,7 @@ def builtin_base64_a64encode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.a64encode(value) return BasicValue(result) @@ -523,7 +788,7 @@ def builtin_base64_a64decode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.a64decode(value) return BasicValue(result) @@ -532,7 +797,7 @@ def builtin_base64_a32encode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.a32encode(value) return BasicValue(result) @@ -541,7 +806,7 @@ def builtin_base64_a32decode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.a32decode(value) return BasicValue(result) @@ -550,7 +815,7 @@ def builtin_base64_a16encode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.a16encode(value) return BasicValue(result) @@ -559,7 +824,7 @@ def builtin_base64_a16decode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.a16decode(value) return BasicValue(result) @@ -568,7 +833,7 @@ def builtin_base64_encodebytes(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.encodebytes(value) return BasicValue(result) @@ -577,7 +842,7 @@ def builtin_base64_decodebytes(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() result = base64.decodebytes(value) return BasicValue(result) @@ -586,7 +851,7 @@ def builtin_str_base64_encode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() encoding = str(arguments.arguments[1].extract_value()) result = value.encode(encoding) @@ -596,7 +861,7 @@ def builtin_str_base64_decode(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - value = str(arguments.arguments[0].extract_value()) + value = arguments.arguments[0].extract_value() encoding = str(arguments.arguments[1].extract_value()) result = value.decode(encoding) @@ -615,7 +880,7 @@ def builtin_cryptography_fernet_encrypt(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - inputStr = bytes(str(arguments.arguments[0].extract_value()), encoding='utf8') + inputStr = bytes(arguments.arguments[0].extract_value(), encoding='utf8') key = bytes(str(arguments.arguments[1].extract_value()), encoding='utf8') from cryptography.fernet import Fernet @@ -629,7 +894,7 @@ def builtin_cryptography_fernet_decrypt(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - token = bytes(str(arguments.arguments[0].extract_value()), encoding='utf8') + token = bytes(arguments.arguments[0].extract_value(), encoding='utf8') key = bytes(str(arguments.arguments[1].extract_value()), encoding='utf8') from cryptography.fernet import Fernet @@ -669,10 +934,8 @@ def builtin_requests_get(arguments): return BasicValue(response_to_list(requests.get(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value(), [arguments.arguments[3].extract_value()[0], arguments.arguments[3].extract_value()[1]]))) elif len(arguments.arguments) > 2: return BasicValue(response_to_list(requests.get(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value()))) - elif len(arguments.arguments) > 1: + else: return BasicValue(response_to_list(requests.get(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value()))) - elif len(arguments.arguments) > 0: - return BasicValue(response_to_list(requests.get(arguments.arguments[0].extract_value()))) return BasicValue(None) @@ -700,12 +963,8 @@ def builtin_requests_post(arguments): return BasicValue(response_to_list(requests.post(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value(), [arguments.arguments[3].extract_value()[0], arguments.arguments[3].extract_value()[1]], arguments.arguments[4].extract_value()))) elif len(arguments.arguments) > 3: return BasicValue(response_to_list(requests.post(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value(), [arguments.arguments[3].extract_value()[0], arguments.arguments[3].extract_value()[1]]))) - elif len(arguments.arguments) > 2: + else: return BasicValue(response_to_list(requests.post(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value()))) - elif len(arguments.arguments) > 1: - return BasicValue(response_to_list(requests.post(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value()))) - elif len(arguments.arguments) > 0: - return BasicValue(response_to_list(requests.post(arguments.arguments[0].extract_value()))) return BasicValue(None) @@ -735,10 +994,8 @@ def builtin_requests_put(arguments): return BasicValue(response_to_list(requests.put(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value(), [arguments.arguments[3].extract_value()[0], arguments.arguments[3].extract_value()[1]]))) elif len(arguments.arguments) > 2: return BasicValue(response_to_list(requests.put(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value()))) - elif len(arguments.arguments) > 1: + else: return BasicValue(response_to_list(requests.put(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value()))) - elif len(arguments.arguments) > 0: - return BasicValue(response_to_list(requests.put(arguments.arguments[0].extract_value()))) return BasicValue(None) @@ -822,10 +1079,8 @@ def builtin_requests_patch(arguments): return BasicValue(response_to_list(requests.patch(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value(), [arguments.arguments[3].extract_value()[0], arguments.arguments[3].extract_value()[1]]))) elif len(arguments.arguments) > 2: return BasicValue(response_to_list(requests.patch(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value()))) - elif len(arguments.arguments) > 1: + else: return BasicValue(response_to_list(requests.patch(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value()))) - elif len(arguments.arguments) > 0: - return BasicValue(response_to_list(requests.patch(arguments.arguments[0].extract_value()))) return BasicValue(None) @@ -855,18 +1110,16 @@ def builtin_requests_request(arguments): return BasicValue(response_to_list(requests.request(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value(), [arguments.arguments[3].extract_value()[0], arguments.arguments[3].extract_value()[1]]))) elif len(arguments.arguments) > 2: return BasicValue(response_to_list(requests.request(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value()))) - elif len(arguments.arguments) > 1: + else: return BasicValue(response_to_list(requests.request(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value()))) - elif len(arguments.arguments) > 0: - return BasicValue(response_to_list(requests.request(arguments.arguments[0].extract_value()))) return BasicValue(None) -def builtin_eval(arguments): +def builtin_pyeval(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - code = str(arguments.arguments[0].extract_value()) + code = arguments.arguments[0].extract_value() codeGlobals = globals() codeLocals = locals() if len(arguments.arguments) > 1 and dict(arguments.arguments[1]) != []: @@ -902,9 +1155,66 @@ def builtin_object_new(arguments): elif isinstance(constructor_method, NodeFunctionExpression): # push this object + any arguments passed here to the function passed_args = [new_instance, *arguments.arguments] - - for i in range(0, len(constructor_method.argument_list.arguments)): - if i >= len(passed_args): + + expected_arg_count = len(constructor_method.argument_list.arguments) + given_arg_count = len(passed_args) + original_given_arg_count = given_arg_count + + if isinstance(constructor_method.argument_list.arguments[-1], NodeSplatArgument): + if given_arg_count > 0: + new_passed_args = [] + for i in range(0, given_arg_count): + if i < expected_arg_count - 1: + new_passed_args.append(passed_args[i]) + elif i == expected_arg_count - 1: + new_passed_args.append([]) + try: + value = BasicValue(eval(passed_args[i])) + except: + value = BasicValue(eval(str(BasicType(passed_args[i])))) + new_passed_args[expected_arg_count - 1].append(value) + elif i > expected_arg_count - 1: + try: + value = BasicValue(eval(passed_args[i])) + except: + value = BasicValue(eval(str(BasicType(passed_args[i])))) + new_passed_args[expected_arg_count - 1].append(value) + amount = len(new_passed_args) + for i in range(0, expected_arg_count): + if i > amount - 1: + new_passed_args.append([]) + passed_args = new_passed_args + if not isinstance(passed_args[-1], BasicObject) and not isinstance(passed_args[-1], BasicValue) and not isinstance(passed_args[-1], BasicType): + try: + value = BasicValue(eval(passed_args[-1])) + except: + value = BasicValue(eval(str(BasicType(passed_args[-1])))) + else: + value = passed_args[-1] + passed_args[-1] = value + given_arg_count = len(passed_args) + else: + passed_args.append(BasicValue([])) + given_arg_count = len(passed_args) + elif expected_arg_count < given_arg_count: + interpreter.error(node, ErrorType.ArgumentError, 'method expected {} arguments, {} given'.format(expected_arg_count, original_given_arg_count), False) + return None + for i in range(0, expected_arg_count): + if i >= given_arg_count: + if isinstance(constructor_method.argument_list.arguments[i], NodeSplatArgument): + arg = NodeDeclare(None, constructor_method.argument_list.arguments[i].token, NodeNone(constructor_method.argument_list.arguments[i].token)) + else: + arg = constructor_method.argument_list.arguments[i] + if not isinstance(arg.value, NodeNone): + try: + value = BasicValue(eval(constructor_method.argument_list.arguments[i].value.value.token.value)) + except: + value = BasicValue(eval(str(BasicType(constructor_method.argument_list.arguments[i].value.value.token.value)))) + passed_args.append(value) + given_arg_count += 1 + + for i in range(0, expected_arg_count): + if i >= given_arg_count: interpreter.stack.push(BasicValue(None)) else: interpreter.stack.push(passed_args[i]) @@ -1981,61 +2291,61 @@ def builtin_os_name(arguments): return BasicValue(os.name) def builtin_os_getenv(arguments): - if len(arguments.arguments) > 1: - return BasicValue(os.getenv(str(arguments.arguments[0]), str(arguments.arguments[1]))) - return BasicValue(os.getenv(str(arguments.arguments[0]))) + return BasicValue(os.getenv(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value())) def builtin_os_putenv(arguments): - os.putenv(str(arguments.arguments[0]), str(arguments.arguments[1])) + os.putenv(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value()) + return BasicValue(None) + +def builtin_os_unsetenv(arguments): + os.unsetenv(arguments.arguments[0].extract_value()) return BasicValue(None) def builtin_os_chdir(arguments): - os.chdir(str(arguments.arguments[0])) + os.chdir(arguments.arguments[0].extract_value()) return BasicValue(None) def builtin_os_getcwd(arguments): return BasicValue(os.getcwd()) def builtin_os_listdir(arguments): - if len(arguments.arguments) > 0: - return BasicValue(os.listdir(str(arguments.arguments[0]))) - return BasicValue(os.listdir()) + return BasicValue(os.listdir(arguments.arguments[0].extract_value())) def builtin_os_mkdir(arguments): - os.mkdir(str(arguments.arguments[0])) + os.mkdir(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value()) return BasicValue(None) def builtin_os_makedirs(arguments): - os.makedirs(str(arguments.arguments[0])) + os.makedirs(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value(), arguments.arguments[2].extract_value()) return BasicValue(None) def builtin_os_remove(arguments): - os.remove(str(arguments.arguments[0])) + os.remove(arguments.arguments[0].extract_value()) return BasicValue(None) def builtin_os_removedirs(arguments): - os.removedirs(str(arguments.arguments[0])) + os.removedirs(arguments.arguments[0].extract_value()) return BasicValue(None) def builtin_os_rename(arguments): - os.rename(str(arguments.arguments[0]), str(arguments.arguments[1])) + os.rename(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value()) return BasicValue(None) def builtin_os_renames(arguments): - os.renames(str(arguments.arguments[0]), str(arguments.arguments[1])) + os.renames(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value()) return BasicValue(None) def builtin_os_replace(arguments): - os.replace(str(arguments.arguments[0]), str(arguments.arguments[1])) + os.replace(arguments.arguments[0].extract_value(), arguments.arguments[1].extract_value()) return BasicValue(None) def builtin_os_rmdir(arguments): - os.rmdir(str(arguments.arguments[0])) + os.rmdir(arguments.arguments[0].extract_value()) return BasicValue(None) def builtin_os_scandir(arguments): if len(arguments.arguments) > 0: - return BasicValue(os.scandir(str(arguments.arguments[0]))) + return BasicValue(os.scandir(arguments.arguments[0].extract_value())) return BasicValue(os.scandir()) def builtin_clear(arguments): @@ -2050,16 +2360,13 @@ def builtin_clear(arguments): return BasicValue(None) def builtin_quit(arguments): - if len(arguments.arguments) > 0: - quit(int(str(arguments.arguments[0]))) - else: - quit() + quit(arguments.arguments[0].extract_value()) return BasicValue(None) def builtin_sysexit(arguments): if len(arguments.arguments) > 0: - sys.exit(str(arguments.arguments[0])) + sys.exit(arguments.arguments[0].extract_value()) else: sys.exit() @@ -2133,72 +2440,70 @@ def builtin_math_min(arguments): return BasicValue(min_value) def builtin_math_degrees(arguments): - return BasicValue(math.degrees(float(str(arguments.arguments[0])))) + return BasicValue(math.degrees(float(arguments.arguments[0].extract_value()))) def builtin_math_dist(arguments): - return BasicValue(math.dist(float(str(arguments.arguments[0])), float(str(arguments.arguments[1])))) + return BasicValue(math.dist(float(arguments.arguments[0].extract_value()), float(arguments.arguments[1].extract_value()))) def builtin_math_erf(arguments): - return BasicValue(math.erf(float(str(arguments.arguments[0])))) + return BasicValue(math.erf(float(arguments.arguments[0].extract_value()))) def builtin_math_erfc(arguments): - return BasicValue(math.erfc(float(str(arguments.arguments[0])))) + return BasicValue(math.erfc(float(arguments.arguments[0].extract_value()))) def builtin_math_exp(arguments): - return BasicValue(math.exp(float(str(arguments.arguments[0])))) + return BasicValue(math.exp(float(arguments.arguments[0].extract_value()))) def builtin_math_factorial(arguments): - return BasicValue(math.factorial(float(str(arguments.arguments[0])))) + return BasicValue(math.factorial(float(arguments.arguments[0].extract_value()))) def builtin_math_floor(arguments): - return BasicValue(math.floor(float(str(arguments.arguments[0])))) + return BasicValue(math.floor(float(arguments.arguments[0].extract_value()))) def builtin_math_fmod(arguments): - return BasicValue(math.fmod(float(str(arguments.arguments[0])), float(str(arguments.arguments[1])))) + return BasicValue(math.fmod(float(arguments.arguments[0].extract_value()), float(arguments.arguments[1].extract_value()))) def builtin_math_frexp(arguments): - return BasicValue(math.frexp(float(str(arguments.arguments[0])))) + return BasicValue(math.frexp(float(arguments.arguments[0].extract_value()))) def builtin_math_fsum(arguments): return BasicValue(math.fsum(list(arguments.arguments[0]))) def builtin_math_gamma(arguments): - return BasicValue(math.gamma(float(str(arguments.arguments[0])))) + return BasicValue(math.gamma(float(arguments.arguments[0].extract_value()))) def builtin_math_gcd(arguments): - return BasicValue(math.gcd(float(str(arguments.arguments[0])), float(str(arguments.arguments[1])))) + return BasicValue(math.gcd(float(arguments.arguments[0].extract_value()), float(arguments.arguments[1].extract_value()))) def builtin_math_hypot(arguments): - return BasicValue(math.hypot(float(str(arguments.arguments[0])), float(str(arguments.arguments[1])))) + return BasicValue(math.hypot(float(arguments.arguments[0].extract_value()), float(arguments.arguments[1].extract_value()))) def builtin_math_isclose(arguments): - return BasicValue(math.isclose(float(str(arguments.arguments[0])), float(str(arguments.arguments[1])))) + return BasicValue(math.isclose(float(arguments.arguments[0].extract_value()), float(arguments.arguments[1].extract_value()))) def builtin_math_isfinite(arguments): - return BasicValue(math.isfinite(float(str(arguments.arguments[0])))) + return BasicValue(math.isfinite(float(arguments.arguments[0].extract_value()))) def builtin_math_isinf(arguments): - return BasicValue(math.isinf(float(str(arguments.arguments[0])))) + return BasicValue(math.isinf(float(arguments.arguments[0].extract_value()))) def builtin_math_isnan(arguments): - return BasicValue(math.isnan(float(str(arguments.arguments[0])))) + return BasicValue(math.isnan(float(arguments.arguments[0].extract_value()))) def builtin_math_isqrt(arguments): - return BasicValue(math.isqrt(float(str(arguments.arguments[0])))) + return BasicValue(math.isqrt(float(arguments.arguments[0].extract_value()))) def builtin_math_ldexp(arguments): - return BasicValue(math.ldexp(float(str(arguments.arguments[0])))) + return BasicValue(math.ldexp(float(arguments.arguments[0].extract_value()))) def builtin_math_lgamma(arguments): - return BasicValue(math.lgamma(float(str(arguments.arguments[0])))) + return BasicValue(math.lgamma(float(arguments.arguments[0].extract_value()))) def builtin_math_log(arguments): - if len(arguments.arguments) > 1: - return BasicValue(math.log(float(str(arguments.arguments[0])), float(str(arguments.arguments[1])))) - return BasicValue(math.log(float(str(arguments.arguments[0])))) + return BasicValue(math.log(float(arguments.arguments[0].extract_value()), float(arguments.arguments[1].extract_value()))) def builtin_math_pow(arguments): - return BasicValue(math.pow(float(str(arguments.arguments[0])), float(str(arguments.arguments[0])))) + return BasicValue(math.pow(float(arguments.arguments[0].extract_value()), float(arguments.arguments[0].extract_value()))) def builtin_math_prod(arguments): interpreter = arguments.interpreter @@ -2213,25 +2518,25 @@ def builtin_math_prod(arguments): return BasicValue(math.prod(values)) def builtin_math_radians(arguments): - return BasicValue(math.radians(float(str(arguments.arguments[0])))) + return BasicValue(math.radians(float(arguments.arguments[0].extract_value()))) def builtin_math_remainder(arguments): - return BasicValue(math.remainder(float(str(arguments.arguments[0])), float(str(arguments.arguments[1])))) + return BasicValue(math.remainder(float(arguments.arguments[0].extract_value()), float(arguments.arguments[1].extract_value()))) def builtin_math_sin(arguments): - return BasicValue(math.sin(float(str(arguments.arguments[0])))) + return BasicValue(math.sin(float(arguments.arguments[0].extract_value()))) def builtin_math_sinh(arguments): - return BasicValue(math.sinh(float(str(arguments.arguments[0])))) + return BasicValue(math.sinh(float(arguments.arguments[0].extract_value()))) def builtin_math_tan(arguments): - return BasicValue(math.tan(float(str(arguments.arguments[0])))) + return BasicValue(math.tan(float(arguments.arguments[0].extract_value()))) def builtin_math_tanh(arguments): - return BasicValue(math.tanh(float(str(arguments.arguments[0])))) + return BasicValue(math.tanh(float(arguments.arguments[0].extract_value()))) def builtin_math_trunc(arguments): - return BasicValue(math.trunc(float(str(arguments.arguments[0])))) + return BasicValue(math.trunc(float(arguments.arguments[0].extract_value()))) def builtin_exception_raise(arguments): from lexer import Lexer @@ -2239,11 +2544,14 @@ def builtin_exception_raise(arguments): interpreter = arguments.interpreter this_object = arguments.this_object - name = str(arguments.arguments[0].extract_value()) + name = arguments.arguments[0].extract_value() message = arguments.arguments[1].extract_value() classnames = list(arguments.arguments[2].extract_value()) + exception = arguments.arguments[3].extract_value() + + # print(exception.members) - interpreter.error(arguments.node, ErrorType.Exception, message, False, name, classnames) + interpreter.error(arguments.node, ErrorType.Exception, message, False, name, classnames, exception) return BasicValue(None) diff --git a/interpreter/env/globals.py b/interpreter/env/globals.py index cd90ef0..6ae9e14 100644 --- a/interpreter/env/globals.py +++ b/interpreter/env/globals.py @@ -102,13 +102,35 @@ def __init__(self): ('__intern_str_toupper__', VariableType.Function, BuiltinFunction("__intern_str_toupper__", None, builtin_str_toupper)), ('__intern_str_totitle__', VariableType.Function, BuiltinFunction("__intern_str_totitle__", None, builtin_str_totitle)), + ('__intern_regex_compile__', VariableType.Function, BuiltinFunction("__intern_regex_compile__", None, builtin_regex_compile)), ('__intern_regex_search__', VariableType.Function, BuiltinFunction("__intern_regex_search__", None, builtin_regex_search)), + ('__intern_regex_match__', VariableType.Function, BuiltinFunction("__intern_regex_match__", None, builtin_regex_match)), + ('__intern_regex_fullmatch__', VariableType.Function, BuiltinFunction("__intern_regex_fullmatch__", None, builtin_regex_fullmatch)), + ('__intern_regex_split__', VariableType.Function, BuiltinFunction("__intern_regex_split__", None, builtin_regex_split)), + ('__intern_regex_findall__', VariableType.Function, BuiltinFunction("__intern_regex_findall__", None, builtin_regex_findall)), + ('__intern_regex_finditer__', VariableType.Function, BuiltinFunction("__intern_regex_finditer__", None, builtin_regex_finditer)), + ('__intern_regex_sub__', VariableType.Function, BuiltinFunction("__intern_regex_sub__", None, builtin_regex_sub)), + ('__intern_regex_subn__', VariableType.Function, BuiltinFunction("__intern_regex_subn__", None, builtin_regex_subn)), + ('__intern_regex_escape__', VariableType.Function, BuiltinFunction("__intern_regex_escape__", None, builtin_regex_escape)), + ('__intern_regex_purge__', VariableType.Function, BuiltinFunction("__intern_regex_purge__", None, builtin_regex_purge)), ('__intern_regex_match_end__', VariableType.Function, BuiltinFunction("__intern_regex_match_end__", None, builtin_regex_match_end)), ('__intern_regex_match_group__', VariableType.Function, BuiltinFunction("__intern_regex_match_group__", None, builtin_regex_match_group)), ('__intern_regex_match_groupdict__', VariableType.Function, BuiltinFunction("__intern_regex_match_groupdict__", None, builtin_regex_match_groupdict)), ('__intern_regex_match_start__', VariableType.Function, BuiltinFunction("__intern_regex_match_start__", None, builtin_regex_match_start)), ('__intern_regex_match_groupdict__', VariableType.Function, BuiltinFunction("__intern_regex_match_groupdict__", None, builtin_regex_match_groups)), + ('__intern_regex_match_span__', VariableType.Function, BuiltinFunction("__intern_regex_match_span__", None, builtin_regex_match_span)), + ('__intern_regex_match_groups__', VariableType.Function, BuiltinFunction("__intern_regex_match_groups__", None, builtin_regex_match_groups)), + ('__intern_regex_match_expand__', VariableType.Function, BuiltinFunction("__intern_regex_match_expand__", None, builtin_regex_match_expand)), + + ('__intern_regex_pattern_search__', VariableType.Function, BuiltinFunction("__intern_regex_pattern_search__", None, builtin_regex_pattern_search)), + ('__intern_regex_pattern_match__', VariableType.Function, BuiltinFunction("__intern_regex_pattern_match__", None, builtin_regex_pattern_match)), + ('__intern_regex_pattern_fullmatch__', VariableType.Function, BuiltinFunction("__intern_regex_pattern_fullmatch__", None, builtin_regex_pattern_fullmatch)), + ('__intern_regex_pattern_split__', VariableType.Function, BuiltinFunction("__intern_regex_pattern_split__", None, builtin_regex_pattern_split)), + ('__intern_regex_pattern_findall__', VariableType.Function, BuiltinFunction("__intern_regex_pattern_findall__", None, builtin_regex_pattern_findall)), + ('__intern_regex_pattern_finditer__', VariableType.Function, BuiltinFunction("__intern_regex_pattern_finditer__", None, builtin_regex_pattern_finditer)), + ('__intern_regex_pattern_sub__', VariableType.Function, BuiltinFunction("__intern_regex_pattern_sub__", None, builtin_regex_pattern_sub)), + ('__intern_regex_pattern_subn__', VariableType.Function, BuiltinFunction("__intern_regex_pattern_subn__", None, builtin_regex_pattern_subn)), ('__intern_base64_b64encode__', VariableType.Function, BuiltinFunction("__intern_base64_b64encode__", None, builtin_base64_b64encode)), ('__intern_base64_b64decode__', VariableType.Function, BuiltinFunction("__intern_base64_b64decode__", None, builtin_base64_b64decode)), @@ -147,7 +169,7 @@ def __init__(self): ('__intern_requests_patch__', VariableType.Function, BuiltinFunction("__intern_requests_patch__", None, builtin_requests_patch)), ('__intern_requests_request__', VariableType.Function, BuiltinFunction("__intern_requests_request__", None, builtin_requests_request)), - ('__intern_eval__', VariableType.Function, BuiltinFunction("__intern_eval__", None, builtin_eval)), + ('__intern_pyeval__', VariableType.Function, BuiltinFunction("__intern_pyeval__", None, builtin_pyeval)), ('__intern_array_len__', VariableType.Function, BuiltinFunction("__intern_array_len__", None, builtin_array_len)), ('__intern_array_at__', VariableType.Function, BuiltinFunction("__intern_array_at__", None, builtin_array_at)), @@ -307,6 +329,7 @@ def __init__(self): ('__intern_os_name__', VariableType.Function, BuiltinFunction("__intern_os_name__", None, builtin_os_name)), ('__intern_os_getenv__', VariableType.Function, BuiltinFunction("__intern_os_getenv__", None, builtin_os_getenv)), ('__intern_os_putenv__', VariableType.Function, BuiltinFunction("__intern_os_putenv__", None, builtin_os_putenv)), + ('__intern_os_unsetenv__', VariableType.Function, BuiltinFunction("__intern_os_unsetenv__", None, builtin_os_unsetenv)), ('__intern_os_chdir__', VariableType.Function, BuiltinFunction("__intern_os_chdir__", None, builtin_os_chdir)), ('__intern_os_getcwd__', VariableType.Function, BuiltinFunction("__intern_os_getcwd__", None, builtin_os_getcwd)), ('__intern_os_listdir__', VariableType.Function, BuiltinFunction("__intern_os_listdir__", None, builtin_os_listdir)), diff --git a/interpreter/interpreter.py b/interpreter/interpreter.py index 199bba3..103d876 100644 --- a/interpreter/interpreter.py +++ b/interpreter/interpreter.py @@ -50,41 +50,44 @@ def close_scope(self): return self.current_scope - def error(self, node, type, message, cont=False, name=None, classnames=None): - if type == ErrorType.Syntax: - name = "Syntax Error" - classnames = ["Exception", "SyntaxError"] - elif type == ErrorType.DoesNotExist: - name = "DoesNotExist Error" - classnames = ["Exception", "DoesNotExistError"] - elif type == ErrorType.TypeError: - name = "Type Error" - classnames = ["Exception", "TypeError"] - elif type == ErrorType.MultipleDefinition: - name = "MultipleDefinition Error" - classnames = ["Exception", "MultipleDefinitionError"] - elif type == ErrorType.ArgumentError: - name = "Argument Error" - classnames = ["Exception", "Argument Error"] - elif type == ErrorType.MacroExpansionError: - name = "Macro Expansion Error" - classnames = ["Exception", "MacroExpansionError"] + def error(self, node, type, message, cont=False, name=None, classnames=None, object=None): + if name is None and classnames is None: + if type == ErrorType.Syntax: + name = "Syntax Error" + classnames = ["Exception", "SyntaxError"] + elif type == ErrorType.DoesNotExist: + name = "DoesNotExist Error" + classnames = ["Exception", "DoesNotExistError"] + elif type == ErrorType.TypeError: + name = "Type Error" + classnames = ["Exception", "TypeError"] + elif type == ErrorType.MultipleDefinition: + name = "Multiple Definition Error" + classnames = ["Exception", "MultipleDefinitionError"] + elif type == ErrorType.ArgumentError: + name = "Argument Error" + classnames = ["Exception", "Argument Error"] + elif type == ErrorType.MacroExpansionError: + name = "Macro Expansion Error" + classnames = ["Exception", "MacroExpansionError"] + else: + name = "Exception" + classnames = ["Exception"] - location = None if node is not None: location = node.location if not cont and self.in_try: - raise InterpreterError('Interpreter error', node, type, message, cont, name, classnames) + raise InterpreterError('Interpreter error', node, type, message, cont, name, classnames, object) err = Error(type, location, message, self.source_location.filename, name) self.error_list.push_error(err) self.error_list.print_errors() if cont or not self.in_try: - raise InterpreterError('Interpreter error', node, type, message, cont, name, classnames) + raise InterpreterError('Interpreter error', node, type, message, cont, name, classnames, object) def visit(self, node): if isinstance(node, BasicValue): @@ -137,7 +140,6 @@ def visit_BinOp(self, node): if node.token.type == TokenType.Plus: funstr = '__add__' - # return BasicValue(left.value + right.value) elif node.token.type == TokenType.Minus: funstr = '__sub__' elif node.token.type == TokenType.Multiply: @@ -196,11 +198,13 @@ def visit_Type(self, node): def visit_Declare(self, node): type_node_value = None + if isinstance(node, NodeSplatArgument): + node = NodeDeclare(None, node.token, NodeNone(node.token)) if node.type_node is not None: type_node_value = self.visit(node.type_node) if self.current_scope.find_variable_info(node.name.value, limit=True) != None: - self.error(node, ErrorType.MultipleDefinition, "multiple definition of '{}'".format(node.name.value), False) + self.error(node, ErrorType.MultipleDefinition, "multiple definition of '{}'".format(node.name.value)) self.current_scope.declare_variable(node.name.value, type_node_value) val = self.visit(node.value) @@ -243,10 +247,10 @@ def visit_Block(self, node, create_scope=True): def assignment_typecheck(self, node, type_object, assignment_value): if type_object is None: - self.error(node, ErrorType.TypeError, 'Set with decltype but decltype resolved to None', False) + self.error(node, ErrorType.TypeError, 'Set with decltype but decltype resolved to None') return False elif not isinstance(type_object, BasicType): - self.error(node, ErrorType.TypeError, '{} is not a valid type object and cannot be used as a declaration type'.format(type_object), False) + self.error(node, ErrorType.TypeError, '{} is not a valid type object and cannot be used as a declaration type'.format(type_object)) return False else: assignment_type = BasicValue(assignment_value).lookup_type(self.global_scope) @@ -255,17 +259,17 @@ def assignment_typecheck(self, node, type_object, assignment_value): assignment_type = assignment_value.parent if assignment_type is None: - self.error(node, ErrorType.TypeError, 'Assignment requires type {} but could not resolve a runtime type of assignment value'.format(type_object), False) + self.error(node, ErrorType.TypeError, 'Assignment requires type {} but could not resolve a runtime type of assignment value'.format(type_object)) return None if isinstance(assignment_type, BasicValue): assignment_type = assignment_type.extract_value() if not isinstance(assignment_type, BasicType): - self.error(node, ErrorType.TypeError, '{} is not a valid runtime type object'.format(assignment_type), False) + self.error(node, ErrorType.TypeError, '{} is not a valid runtime type object'.format(assignment_type)) return False if not type_object.compare_type(assignment_type): - self.error(node, ErrorType.TypeError, 'Attempted to assign <{}> to a value of type <{}>'.format(type_object.friendly_typename, assignment_type.friendly_typename), False) + self.error(node, ErrorType.TypeError, 'Attempted to assign <{}> to a value of type <{}>'.format(type_object.friendly_typename, assignment_type.friendly_typename)) return False return True @@ -290,7 +294,7 @@ def visit_Assign(self, node): (target, member) = self.walk_member_expression(node.lhs) if not isinstance(target, BasicObject): - self.error(node, ErrorType.TypeError, 'member expression not assignable', False) + self.error(node, ErrorType.TypeError, 'member expression not assignable') return None target_type = target.parent @@ -315,23 +319,20 @@ def visit_Assign(self, node): return self.visit(member_access_call_node) else: - self.error(node, ErrorType.TypeError, 'cannot assign {}'.format(node.lhs), False) + self.error(node, ErrorType.TypeError, 'cannot assign {}'.format(node.lhs)) return None def collect_args(self, node): collected_args = [] for arg in node.argument_list.arguments: - arg_visited = self.visit(arg) - - #if arg.type == NodeType.SplatArgument: - # print("encountered splat: {}".format(arg_visited)) + arg_visited = self.visit(arg) - if type(arg_visited) == list: - for arg in arg_visited: - collected_args.append(arg) - else: - collected_args.append(arg_visited) + if type(arg_visited) == list: + for arg in arg_visited: + collected_args.append(arg) + else: + collected_args.append(arg_visited) return collected_args @@ -394,9 +395,8 @@ def visit_Call(self, node): else: target = self.visit(node.lhs) return_value = 0 - + if target is not None: - if isinstance(target, BuiltinFunction): collected_args = self.collect_args(node) @@ -417,21 +417,77 @@ def visit_Call(self, node): expected_arg_count = len(target.argument_list.arguments) given_arg_count = len(collected_args) - - if expected_arg_count != given_arg_count: - self.error(node, ErrorType.ArgumentError, 'method expected {} arguments, {} given'.format(expected_arg_count, given_arg_count), False) + original_given_arg_count = given_arg_count + + if isinstance(target.argument_list.arguments[-1], NodeSplatArgument): + if given_arg_count > 0: + new_collected_args = [] + for i in range(0, given_arg_count): + if i < expected_arg_count - 1: + new_collected_args.append(collected_args[i]) + elif i == expected_arg_count - 1: + new_collected_args.append([]) + try: + value = BasicValue(eval(collected_args[i])) + except: + value = BasicValue(eval(str(BasicType(collected_args[i])))) + new_collected_args[expected_arg_count - 1].append(value) + elif i > expected_arg_count - 1: + try: + value = BasicValue(eval(collected_args[i])) + except: + value = BasicValue(eval(str(BasicType(collected_args[i])))) + new_collected_args[expected_arg_count - 1].append(value) + amount = len(new_collected_args) + for i in range(0, expected_arg_count): + if i > amount - 1: + new_collected_args.append([]) + collected_args = new_collected_args + if not isinstance(collected_args[-1], BasicObject) and not isinstance(collected_args[-1], BasicValue) and not isinstance(collected_args[-1], BasicType): + try: + value = BasicValue(eval(collected_args[-1])) + except: + value = BasicValue(eval(str(BasicType(collected_args[-1])))) + else: + value = collected_args[-1] + collected_args[-1] = value + given_arg_count = len(collected_args) + else: + collected_args.append(BasicValue([])) + given_arg_count = len(collected_args) + elif expected_arg_count < given_arg_count: + self.error(node, ErrorType.ArgumentError, 'method expected {} arguments, {} given'.format(expected_arg_count, original_given_arg_count)) + return None + for i in range(0, expected_arg_count): + if i >= given_arg_count: + if isinstance(target.argument_list.arguments[i], NodeSplatArgument): + arg = NodeDeclare(None, target.argument_list.arguments[i].token, NodeNone(target.argument_list.arguments[i].token)) + else: + arg = target.argument_list.arguments[i] + if not isinstance(arg.value, NodeNone): + try: + value = BasicValue(eval(target.argument_list.arguments[i].value.value.token.value)) + except: + value = BasicValue(eval(str(BasicType(target.argument_list.arguments[i].value.value.token.value)))) + collected_args.append(value) + given_arg_count += 1 + if expected_arg_count > given_arg_count: + self.error(node, ErrorType.ArgumentError, 'method expected {} arguments, {} given'.format(expected_arg_count, given_arg_count)) return None # typecheck args for i in range(0, expected_arg_count): - target_arg = target.argument_list.arguments[i] + if isinstance(target.argument_list.arguments[i], NodeSplatArgument): + target_arg = NodeDeclare(None, target.argument_list.arguments[i].token, NodeNone(target.argument_list.arguments[i].token)) + else: + target_arg = target.argument_list.arguments[i] call_arg = collected_args[i] type_node = target_arg.type_node if type_node is not None: decltype = self.visit(type_node) - + self.assignment_typecheck(target_arg, decltype, call_arg) # push arguments to stack @@ -445,7 +501,7 @@ def visit_Call(self, node): result = self.stack.pop() if not isinstance(result, BasicValue): - self.error(node, ErrorType.TypeError, 'expected method to return an instance of BasicValue, got {}'.format(result), False) + self.error(node, ErrorType.TypeError, 'expected method to return an instance of BasicValue, got {}'.format(result)) return None return result @@ -471,12 +527,12 @@ def visit_Call(self, node): ) return self.visit(member_access_call_node) - self.error(node, ErrorType.TypeError, 'invalid call: {} is not callable'.format(target), False) + self.error(node, ErrorType.TypeError, 'invalid call: {} is not callable'.format(target)) def walk_variable(self, node): var = self.current_scope.find_variable_info(node.value) if var is None: - self.error(node, ErrorType.DoesNotExist, "Referencing undefined variable '{}'".format(node.value), False) + self.error(node, ErrorType.DoesNotExist, "Referencing undefined variable '{}'".format(node.value)) return None return var @@ -505,13 +561,13 @@ def check_object_truthy(self, node): result = self.visit(member_access_call_node) if result is None: - self.error(node, ErrorType.TypeError, 'cannot check if object {} is truthy'.format(node), False) + self.error(node, ErrorType.TypeError, 'cannot check if object {} is truthy'.format(node)) return None int_result = result.extract_value() if type(int_result) != int: - self.error(node, ErrorType.TypeError, 'expected __bool__ call to return an int'.format(node), False) + self.error(node, ErrorType.TypeError, 'expected __bool__ call to return an int'.format(node)) return None return int_result != 0 @@ -529,10 +585,14 @@ def visit_IfStatement(self, node): def visit_Try(self, node): if node.catch_block is not None and node.catch_block != [] and node.else_block is None and node.finally_block is None: + print("AA") try: self.in_try = True return self.visit_Block(node.block) except InterpreterError as e: + if e.type == ErrorType.Syntax: + self.in_try = False + return self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) self.in_try = True found = False for i in range(len(node.catch_block)): @@ -554,7 +614,18 @@ def visit_Try(self, node): found = True self.visit_Block(node.catch_block[i]) elif type(node.expr[i].token.value) == str: + print("AAA") + # print(node.expr[i].token.value) + # print(e.object.members["message"]) + # print(node.expr[i + 1].token.value) if node.expr[i].token.value in e.classnames: + if node.variable[i] is not None: + node.variable[i].type_node.token.value = node.expr[i].token.value + # print(node.variable[i].value) + # node.variable[i].value.token.token.value = e.object + # print(node.variable[i].value) + self.visit_Declare(node.variable[i]) + if i == len(node.catch_block) - 1: self.in_try = True return self.visit_Block(node.catch_block[i]) @@ -562,14 +633,18 @@ def visit_Try(self, node): found = True self.visit_Block(node.catch_block[i]) elif i == len(node.catch_block) - 1 and not found: - self.error(e.node, e.type, e.message, True, e.name, e.classnames) + self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) elif i == len(node.catch_block) - 1 and not found: - self.error(e.node, e.type, e.message, True, e.name, e.classnames) + self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) elif node.catch_block is not None and node.catch_block != [] and node.else_block is None and node.finally_block is not None: + print("B") try: self.in_try = True self.visit_Block(node.block) except InterpreterError as e: + if e.type == ErrorType.Syntax: + self.in_try = False + return self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) self.in_try = True found = False for i in range(len(node.catch_block)): @@ -599,17 +674,21 @@ def visit_Try(self, node): found = True self.visit_Block(node.catch_block[i]) elif i == len(node.catch_block) - 1 and not found: - self.error(e.node, e.type, e.message, True, e.name, e.classnames) + self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) elif i == len(node.catch_block) - 1 and not found: - self.error(e.node, e.type, e.message, True, e.name, e.classnames) + self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) finally: self.in_try = True return self.visit_Block(node.finally_block) elif (node.catch_block is not None and node.catch_block != []) and node.else_block is not None and node.finally_block is None: + print("C") try: self.in_try = True self.visit_Block(node.block) except InterpreterError as e: + if e.type == ErrorType.Syntax: + self.in_try = False + return self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) self.in_try = True found = False for i in range(len(node.catch_block)): @@ -639,21 +718,26 @@ def visit_Try(self, node): found = True self.visit_Block(node.catch_block[i]) elif i == len(node.catch_block) - 1 and not found: - self.error(e.node, e.type, e.message, True, e.name, e.classnames) + self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) elif i == len(node.catch_block) - 1 and not found: - self.error(e.node, e.type, e.message, True, e.name, e.classnames) + self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) else: self.in_try = True return self.visit_Block(node.else_block) elif (node.catch_block is not None and node.catch_block != []) and node.else_block is not None and node.finally_block is not None: + # BasicObject(parent=None, members={'raise': AstNode[FunctionExpression, AstNode[Block, LexerToken[Type:TokenType.Keyword, Value:'return']]], 'message': 'A'}) try: self.in_try = True self.visit_Block(node.block) except InterpreterError as e: + if e.type == ErrorType.Syntax: + self.in_try = False + return self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) self.in_try = True found = False for i in range(len(node.catch_block)): if node.expr[i] is None: + print("AB") if i == len(node.catch_block) - 1: self.in_try = True return self.visit_Block(node.catch_block[i]) @@ -662,6 +746,7 @@ def visit_Try(self, node): self.visit_Block(node.catch_block[i]) else: if type(node.expr[i]) == list: + print("B") for value in node.expr[i]: if value.token.value in e.classnames: if i == len(node.catch_block) - 1: @@ -670,52 +755,55 @@ def visit_Try(self, node): else: found = True self.visit_Block(node.catch_block[i]) - - # type_node_value = None - - # if node.type_node is not None: - # type_node_value = self.visit(node.type_node) - - # if self.current_scope.find_variable_info(node.variable[i].name.value, limit=True) != None: - # self.error(node, ErrorType.MultipleDefinition, "multiple definition of '{}'".format(node.variable[i].name.value), False) - - # self.current_scope.declare_variable(node.variable[i].name.value, type_node_value) - # # AstNode[Assign, AstNode[String, LexerToken[Type:TokenType.String, Value:''TypeError'']]] - # self.visit(node.variable[i].value) elif type(node.expr[i].token.value) == str: + print("C") if node.expr[i].token.value in e.classnames: + print("CA") if i == len(node.catch_block) - 1: + print("CAA") self.in_try = True return self.visit_Block(node.catch_block[i]) else: + print("CAB") + # print(node) found = True self.visit_Block(node.catch_block[i]) elif i == len(node.catch_block) - 1 and not found: - self.error(e.node, e.type, e.message, True, e.name, e.classnames) + print("CB") + self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) elif i == len(node.catch_block) - 1 and not found: - self.error(e.node, e.type, e.message, True, e.name, e.classnames) + print("D") + self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) else: self.visit_Block(node.else_block) finally: self.in_try = True return self.visit_Block(node.finally_block) elif (node.catch_block is None or node.catch_block == []) and node.else_block is not None and node.finally_block is None: + print("E") try: self.in_try = True return self.visit_Block(node.block) except InterpreterError as e: + if e.type == ErrorType.Syntax: + self.in_try = False + return self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) self.in_try = True - self.error(e.node, e.type, e.message, True, e.name, e.classnames) + self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) else: self.in_try = True return self.visit_Block(node.else_block) elif (node.catch_block is None or node.catch_block == []) and node.else_block is None and node.finally_block is not None: + print("F") try: self.in_try = True return self.visit_Block(node.block) except InterpreterError as e: + if e.type == ErrorType.Syntax: + self.in_try = False + return self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) self.in_try = True - self.error(e.node, e.type, e.message, True, e.name, e.classnames) + self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) finally: self.in_try = True return self.visit_Block(node.else_block) @@ -724,8 +812,11 @@ def visit_Try(self, node): self.in_try = True return self.visit_Block(node.block) except InterpreterError as e: + if e.type == ErrorType.Syntax: + self.in_try = False + return self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) self.in_try = True - self.error(e.node, e.type, e.message, True, e.name, e.classnames) + self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) else: self.in_try = True return self.visit_Block(node.else_block) @@ -737,8 +828,11 @@ def visit_Try(self, node): self.in_try = True return self.visit_Block(node.block) except InterpreterError as e: + if e.type == ErrorType.Syntax: + self.in_try = False + return self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) self.in_try = True - self.error(e.node, e.type, e.message, True, e.name, e.classnames) + self.error(e.node, e.type, e.message, True, e.name, e.classnames, e.object) def visit_While(self, node): truthy_result = self.check_object_truthy(node.expr) @@ -780,17 +874,17 @@ def visit_SplatArgument(self, node): value = self.visit(node.expr) if value is None: - self.error(node, ErrorType.TypeError, 'cannot perform splat operation: value is null', False) + self.error(node, ErrorType.TypeError, 'cannot perform splat operation: value is null') return None if not isinstance(value, BasicValue): - self.error(node, ErrorType.TypeError, 'cannot perform splat operation: value is not a BasicValue', False) + self.error(node, ErrorType.TypeError, 'cannot perform splat operation: value is not a BasicValue') return None extracted_value = value.extract_value() if not isinstance(extracted_value, list): - self.error(node, ErrorType.TypeError, 'cannot perform splat operation: value must be an array', False) + self.error(node, ErrorType.TypeError, 'cannot perform splat operation: value must be an array') return None args = [] @@ -813,6 +907,8 @@ def visit_ArgumentList(self, node): if isinstance(value, AstNode): value = self.visit(value) + if isinstance(argument, NodeSplatArgument): + argument = NodeDeclare(None, argument.token, NodeNone(argument.token)) self.current_scope.set_variable(argument.name.value, value) def visit_FunctionExpression(self, node): @@ -829,7 +925,7 @@ def visit_Mixin(self, node): ast = parser.parse() if len(parser.error_list.errors) > 0: - self.error(node, ErrorType.MacroExpansionError, 'Macro expansion failed:\n{}'.format('\t'.join(map(lambda x: str(x), parser.error_list.errors))), False) + self.error(node, ErrorType.MacroExpansionError, 'Macro expansion failed:\n{}'.format('\t'.join(map(lambda x: str(x), parser.error_list.errors)))) return None last_value = None @@ -840,11 +936,10 @@ def visit_Mixin(self, node): return BasicValue(last_value).extract_basicvalue() def call_builtin_function(self, fun, this_object, arguments, node): - basic_value_result = fun.call(BuiltinFunctionArguments(interpreter=self, this_object=this_object, arguments=arguments, node=node)) if not isinstance(basic_value_result, BasicValue): - self.error(node, ErrorType.TypeError, 'expected method {} to return an instance of BasicValue, got {}'.format(fun, basic_value_result), False) + self.error(node, ErrorType.TypeError, 'expected method {} to return an instance of BasicValue, got {}'.format(fun, basic_value_result)) return None return basic_value_result @@ -862,13 +957,12 @@ def call_function_expression(self, node): last_child = None for child in node.block.children: last_child = child - if type(child) == NodeFunctionReturn: + if isinstance(child, NodeFunctionReturn): break # no return statement, push return code 0 to the stack if type(last_child) != NodeFunctionReturn: self.stack.push(BasicValue(0)) # should just be null or something - except ReturnJump: # exit all enclosed scopes until the current scope # is equal to the same one we opened at the start of the function @@ -912,7 +1006,7 @@ def basic_value_to_object(self, node, target): target_type_object = target.lookup_type(self.global_scope).extract_basicvalue() if target_type_object is None: - self.error(node, ErrorType.TypeError, 'invalid member access: target {} is not a BasicObject'.format(target), False) + self.error(node, ErrorType.TypeError, 'invalid member access: target {} is not a BasicObject'.format(target)) return None # for a string this would basically mean: @@ -926,7 +1020,7 @@ def walk_member_expression(self, node): target = self.visit(node.lhs) # if target is None: - # self.error(node, ErrorType.TypeError, 'invalid member access: {} has no member {}'.format(target, node.identifier), False) + # self.error(node, ErrorType.TypeError, 'invalid member access: {} has no member {}'.format(target, node.identifier)) # return None target = self.basic_value_to_object(node, target) @@ -934,7 +1028,7 @@ def walk_member_expression(self, node): member = target.lookup_member(node.identifier.value) if member is None: - self.error(node, ErrorType.TypeError, '{} has no direct or inherited member `{}`'.format(obj_to_string(self, node, target), node.identifier.value), False) + self.error(node, ErrorType.TypeError, '{} has no direct or inherited member `{}`'.format(obj_to_string(self, node, target), node.identifier.value)) return (target, member) @@ -958,4 +1052,4 @@ def visit_ArrayAccessExpression(self, node): def visit_Empty(self, node): pass - + \ No newline at end of file diff --git a/interpreter/typing/__pycache__/basic_type.cpython-38.pyc b/interpreter/typing/__pycache__/basic_type.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6d2e30de7e409ba27bc23b6da9ba2ccb1c27180f GIT binary patch literal 2003 zcmZuyOK;mo5Z+x-+X?P9JzGKpsjY}pQieFe>Q#KEo+xi>dW-c$+ zUIuv-zCJ!xp+?g&=1)O9RcNihoJO&Z(&01>b(Ezcy;L6-8ZS`tpK(&m=@^c&L_%i>denIjE+Kz$9$09K-ovhAK|3g6)#x93vrE6DXfC|Lb5}4!$+c-;dHr`+n)9SrVmzj@~QRF6~^!LVHUKG43U-Pq@R%TpQE8_^g1o^RuH10w;GgldntEuK9lG47eFPz= z!q`*`$M{LK8OMm1Mmk_FlpGCfUZQB3wDL}HHRn05->zqnCoX9)c7g>3VtR& zV0xVjvJ0z=#rOwit+X(6?a>hyQ?E)TKhCnV>160yWiQMUdRSova=q-%pAiqPZ8-Ft zOrIz)Kw$@WdF?QQa2f}&6cwPPe}a-zFc@!h8)IRMKJSVxG26L|M*W)MN)at0v4^Kn zBn;JkgWk$NzD3`LPpO#5xfBoDMbF+0?_AmK-ZM5*n`}5@^^am#8QFZy{j=q$2ZuD(k8tEH$EP+2u#b?a<{zw@Y17#Vaj*;6cAJzKr-mz)Cnfc6BegC7?Wz%x1 lHnd$|9p8TbfG9BM*Ss=Ln%3I>rV7M!>e4yoO_$?O{0AsRy)gg) literal 0 HcmV?d00001 diff --git a/parse/__pycache__/node.cpython-38.pyc b/parse/__pycache__/node.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fa716a48c1ce88bb8566caa08fde7273c248cf97 GIT binary patch literal 10143 zcmcIqOLrVc74GNEX!IJ(@>{kQ$8kJ~BRh%nGC3eeaY9I3pf}Suz>|EU;!K0zzR++VU@qY2EOlh_e^UZ@nkTq(^vIXbyeT` z>ej7W)pK=nGH>BJb@ik2g~OKhFM{;t0W9Kf{nNHAWhuL6)$J9#?yNXAu~T#F-ilZE zSA5%g-cqjeKDLw>csJdZ46v^YglfZk`Eby%0Dd2r-Kk$CR)4&JRLEwXe3&4leVc^4p z_W&PJbHH3H_cu!S|>yT(*i&f6CD>Iwt>8@P44LG;ahA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q;>%5F7TMOHpq4vmW;DJ?)X|KpzjN~uZNMM&jE#W2Xkn6fMqM`};uI6qa=YxN* zuTqB8jx$<_I?SH8q?GF^HL-eDu)U|$<18(fH^~2n3oEph!Ra&ZayhST3z!D-EUfJk dLeUGPXk$a7&GD`Lw!GyYo-JQJ=Zr5>_yLpuhb{mB literal 0 HcmV?d00001 diff --git a/parse/parser.py b/parse/parser.py index 3cf31d8..82ad522 100644 --- a/parse/parser.py +++ b/parse/parser.py @@ -77,7 +77,7 @@ def error(self, message): # if an error occurs location = self.current_token.location - self.error_list.push_error(Error(ErrorType.Syntax, location, message, self.filename)) + self.error_list.push_error(Error(ErrorType.Syntax, location, message, self.filename, "Syntax Error")) # read next token and error if token.type != passed in token type def eat(self, token_type=None): @@ -351,6 +351,8 @@ def parse_argument_list(self): has_vargs = False first_arg = True + any_default = False + while True: if has_vargs: self.error('Arguments provided after variadic arguments') @@ -383,10 +385,15 @@ def parse_argument_list(self): # parse declaration(vname:type) without let keyword argument = self.parse_variable_declaration(require_keyword=False) - if argument is None: self.error('invalid argument') break + if not isinstance(argument, NodeSplatArgument) and hasattr(argument.value, 'value'): + any_default = True + else: + if any_default: + self.error('non-default argument follows default argument') + break arguments.append(argument) @@ -503,7 +510,6 @@ def parse_block_statement(self): def parse_array_expression(self): members = [] - # eat left bracket if self.eat(TokenType.LBracket) is None: return None @@ -562,7 +568,7 @@ def parse_type(self): self.eat() return node - def parse_function_call(self, node): + def parse_function_call(self, node): self.eat(TokenType.LParen) argnames = [] @@ -779,13 +785,17 @@ def parse_try(self): expr.append(NodeString(LexerToken("Exception"))) elif self.current_token.type == TokenType.Identifier: expr.append(self.parse_expression()) - + if self.current_token.type == TokenType.Identifier: e = self.parse_expression() val_node = NodeAssign(NodeVariable(e.token), expr[-1]) - type_node = NodeVariable(LexerToken(e.token.value, TokenType.Identifier)) + type_node = NodeVariable(LexerToken("Exception", TokenType.Identifier)) + # type_node_token = self.current_token + # type_node = self.parse_factor() n = NodeDeclare(type_node, e.token, val_node) variable.append(n) + elif self.current_token.type == TokenType.LBrace: + variable.append(None) catch_block.append(self.parse_block_statement()) token = self.current_token diff --git a/repl/__pycache__/repl.cpython-38.pyc b/repl/__pycache__/repl.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..77905e0d373d5e300df11d2e37b462ff0834b306 GIT binary patch literal 6664 zcmai2O>7)TcJAuG>1hssMTw+kOKreYMSdsTlqJ?(1vHGba;l5?8&pVT<~GthV+N&XWuu5lJ=epxb~p{+-H zZ1_fO`etnT79*Mw*>T0MsJa`LmN_NmOcZhyPh?JOIOnn3N za)@(1-T5GmQsGxVX(c?}mrYvj;h&Di`$+O0vQQ(r`#NX7!F6tYsre>1xrNf=Hm{(x zxx=d{E8OK%D4kLwewEMgS+rd~$LCQ_@dbVYWsNWLlPIV8DM)LnFmHyPD7P;P6dO(Y z`uJy~GKEB1A%D*_?JI4d4Usokrnim0-eYZ(vprpST<_~iU9}Cg-{L0PXH?rl`+aVs zJ)_zcv^Tla*Ljt@11qx!m7&&lhHOwBYTszQ+EeomTsre54P%fW=UdWf1xt$m*A`Y( z%YRGzCLQY=OzRnZ=79B0KHD<~vqNpKBLBUt@!1tM=bk41>nqLF+BM8H$LGc~zNhJ! zE!jH8ZGO$L>KfOg`98ik88<&zc+SZedRBXWaAMSRVnySNLwx{w580A7)Q^7S6D@&d z(EpB>=$}HaG%G(fSl~;8li8`i(Y6_1<||)1UukW2pby!Qm8A z58sK4DIPuuqqGx;Nv0UyjeT2Y!B!Ni=G$?>-2C);`gu3Jz!OLxc&W#|&{Ms+?mZAt z77fa8?1WiYeke@%dGLd-bCW zs~=xjz2&3tlDE3$t@1a$)jJ**zxrwZ&~?4h?|PWMCOydBgE&MM@|P#1+o=b+io}ak z2r$@6yO}qZ`I{523<&6@3DP!%6Jps>l7w998`x8d`;8O$5CY|{BM|BJ71d@Ca z8D|5nrwtf~5z_teR4#|xK{v{Z>5*o@Phi1?-GphuE$OK&=5a<1G~!kgL=D->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gm6Vf;6%O*%T^$&@^M@B>Whfsj;A?XofipO%Si73^f{YrGj#E$IJ40x z+(si#c^9{fMp0`t?stQzq$pz+8(5{fx(d4Hi7S+;u=X6)E>lLJB*-=eZSK&9pYNJ3 zcBhaeWd#4uJC5nNNRD&LdEJ?F9Q8c0b{a1icsHO2qtgFAq$w537*r!$hHE4gp~wZV z{w30sZnRF|Dadt*3NfB68IPfm!mDEG(91{tP+dKk6w8Nt>S6MrzSV6-xcy5(=w4XL zLn;qYOc9PNXN^v}Bo$^iYenVbku4uVy<&RXDKC72UI^4)zfVwj$0`qFgCZjp5jjA) RMPU0J;rsY+Qrzws{|j98t-b&N literal 0 HcmV?d00001 diff --git a/std/cryptography/fernet.para b/std/cryptography/fernet.para index ac84da3..5c4ab4a 100644 --- a/std/cryptography/fernet.para +++ b/std/cryptography/fernet.para @@ -1,4 +1,4 @@ -io.evaluate("import os\ntry:\n from cryptography.fernet import Fernet\nexcept ImportError:\n os.system('pip install cryptography')"); +io.pyeval("import os\ntry:\n from cryptography.fernet import Fernet\nexcept ImportError:\n os.system('pip install cryptography')"); let Fernet: type = Type.extend({ instance = { diff --git a/std/io.para b/std/io.para index 1975e4d..ecb1bda 100644 --- a/std/io.para +++ b/std/io.para @@ -1,22 +1,10 @@ let io = Type.extend({ - evaluate = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_eval__(*args); - } - } - }).new() + func pyeval(self, *args) { + return __intern_pyeval__(*args); + } }); import "std/io/file.para"; import "std/io/console.para"; -let print = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_print__(*args); - } - } -}).new(); +let print = io.write; diff --git a/std/io/console.para b/std/io/console.para index 8a227f2..e06f77d 100644 --- a/std/io/console.para +++ b/std/io/console.para @@ -1,4 +1,4 @@ -let Console: type = Type.extend({ +let Console = Type.extend({ DEFAULT = 0 RED = 1 YELLOW = 2 @@ -8,40 +8,24 @@ let Console: type = Type.extend({ instance = { } - write + func write(_, message="", end="") { + __intern_console_write__(message, end); + } func color(_, num) { __intern_print_color__(num); } - func write_color(self, color, msg) { + func write_color(self, color, msg="") { self.color(color); self.write(msg); self.color(self.DEFAULT); } - read -}); - -Console.write = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - __intern_console_write__(*args); - } - } -}).new(); - -Console.read = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - for i in Range.new(0, args.len()) { - Console.write(args[i]); - } - return __intern_console_input__(); - } + func read(_, prompt="") { + Console.write(prompt); + return __intern_console_input__(); } -}).new(); +}); io.patch({ @@ -50,7 +34,7 @@ io.patch({ write = Console.write read = Console.read - func write_color(self, color, msg) { + func write_color(self, color, msg="") { return self.console.write_color(color, msg); } }); diff --git a/std/math.para b/std/math.para index d0df75a..9ddea38 100644 --- a/std/math.para +++ b/std/math.para @@ -37,11 +37,11 @@ let math = { return x2; } - func sqrt(self, x) { + func sqrt(_, x) { return math.sqrtf(x.to_float()); } - func abs(self, x: num) { + func abs(_, x: num) { let result = x; if result < 0 { result = -1 * result; @@ -129,14 +129,9 @@ let math = { return __intern_math_lgamma__(x); } - log = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_math_log__(*args); - } - } - }).new() + func log(_, x, base=math.e) { + return __intern_math_log__(x, base); + } func pow(_, x: num, y: num) { return __intern_math_pow__(x, y); diff --git a/std/math/random.para b/std/math/random.para index 99a924a..200b6bd 100644 --- a/std/math/random.para +++ b/std/math/random.para @@ -1,50 +1,23 @@ let Random = { index = 0 - random - range -}; - -let intern_random = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - let seed; - if args.len() > 0 { - seed = args[0]; - } - else { - seed = __intern_time_now__().to_int() + Random.index; - Random.index += 1; - } - let rand; - let v0:int = 12345+(seed*1103515245); - rand = v0.to_int() & 2147483647; - return rand; + func random(_, seed=null) { + if seed == null { + seed = __intern_time_now__().to_int() + Random.index; } + Random.index += 1; + let v0:int = 12345+(seed*1103515245); + let rand = v0.to_int() & 2147483647; + return rand; } -}); -Random.random = intern_random.new(); - -let intern_range = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - let high = args[0]; - let low = args[1]; - let seed; - if args.len() > 2 { - seed = args[2]; - } - else { - seed = __intern_time_now__().to_int() + Random.index; - Random.index += 1; - } - let rand = Random.random(seed); - return rand % (high-low+1)+low; + func range(_, high, low=0, seed=null) { + if seed == null { + seed = __intern_time_now__().to_int() + Random.index; } + Random.index += 1; + let rand = Random.random(seed); + return rand % (high-low+1)+low; } -}); -Random.range = intern_range.new(); +}; let random = Random; diff --git a/std/numpara.para b/std/numpara.para index 91e4e80..9acb659 100644 --- a/std/numpara.para +++ b/std/numpara.para @@ -1,4 +1,4 @@ -io.evaluate("import os\ntry:\n import numpy\nexcept ImportError:\n os.system('pip install numpy')"); +io.pyeval("import os\ntry:\n import numpy\nexcept ImportError:\n os.system('pip install numpy')"); let NumPara: type = Type.extend({ instance = { diff --git a/std/os.para b/std/os.para index 921730b..dd5300b 100644 --- a/std/os.para +++ b/std/os.para @@ -2,164 +2,58 @@ let os = Type.extend({ args = __intern_os_args__() name = __intern_os_name__() - clear = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_clear__(*args); - } - } - }).new() - - quit = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_quit__(*args); - } - } - }).new() - - exit = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_exit__(*args); - } - } - }).new() - - system = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_system__(*args); - } - } - }).new() - - getenv = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_getenv__(*args); - } - } - }).new() - - putenv = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_putenv__(*args); - } - } - }).new() - - chdir = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_chdir__(*args); - } - } - }).new() - - getcwd = Func.extend({ - instance = { - func __call__(self, _args) { - return __intern_os_getcwd__(); - } - } - }).new() - - listdir = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_listdir__(*args); - } - } - }).new() - - mkdir = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_mkdir__(*args); - } - } - }).new() - - makedirs = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_makedirs__(*args); - } - } - }).new() - - remove = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_remove__(*args); - } - } - }).new() - - removedirs = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_removedirs__(*args); - } - } - }).new() - - rename = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_rename__(*args); - } - } - }).new() - - renames = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_renames__(*args); - } - } - }).new() - - replace = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_replace__(*args); - } - } - }).new() - - rmdir = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_rmdir__(*args); - } - } - }).new() - - scandir = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return __intern_os_scandir__(*args); - } - } - }).new() + func clear(_) { + return __intern_clear__(); + } + func quit(_, exit_code=0) { + return __intern_quit__(exit_code); + } + func exit(_, exit_code=0) { + return __intern_exit__(exit_code); + } + func getenv(_, key, default=null) { + return __intern_os_getenv__(key, default); + } + func putenv(_, key, value) { + return __intern_os_putenv__(key, value); + } + func unsetenv(_, key) { + return __intern_os_unsetenv__(key); + } + func chdir(_, path) { + return __intern_os_chdir__(path); + } + func getcwd(_) { + return __intern_os_getcwd__(); + } + func listdir(_, path=".") { + return __intern_os_listdir__(path); + } + func mkdir(_, path, mode=511) { + return __intern_os_mkdir__(path, mode); + } + func makedirs(_, name, mode=511, exist_ok=false) { + return __intern_os_makedirs__(name, mode, exist_ok); + } + func remove(_, path) { + return __intern_os_remove__(path); + } + func removedirs(_, name) { + return __intern_os_removedirs__(name); + } + func rename(_, src, dst) { + return __intern_os_rename__(src, dst); + } + func renames(_, old, new) { + return __intern_os_renames__(old, new); + } + func replace(_, src, dst) { + return __intern_os_replace__(src, dst); + } + func rmdir(_, path) { + return __intern_os_rmdir__(path); + } + func scandir(_, path=".") { + return __intern_os_scandir__(path); + } }); diff --git a/std/regex.para b/std/regex.para index cb3138d..4029809 100644 --- a/std/regex.para +++ b/std/regex.para @@ -1,130 +1,42 @@ -let _end = Func.extend({ - instance = { - inst +let regex = Type.extend({ + name = 'Regex' - func __call__(self, _args) { - let args = _args.from(1); - return __intern_regex_match_end__(self.inst.re.pattern, self.inst.string, *args); - } + func compile(_, pattern, flags=0) { + let x = __intern_regex_compile__(pattern, flags); + return Pattern.new(x[0], x[1], x[2], x[3]); } - - func __construct__(self, _inst) { - self.inst = _inst; - - return self; + func search(_, pattern, string, flags=0) { + let x = __intern_regex_search__(pattern, string, flags); + return Match.new(x[0], x[1], Pattern.new(x[2][0], x[2][1], x[2][2], x[2][3], x[3]), x[3], x[4], x[5], x[6]); } -}); - -//////let _expand = Func.extend({ -////// instance = { -////// inst -////// -////// func __call__(self, _args) { -////// let args = _args.from(1); -////// return __intern_regex_match_expand__(self.inst.re.pattern, self.inst.string, *args); -////// } -////// } -////// -////// func __construct__(self, _inst) { -////// self.inst = _inst; -////// -////// return self; -////// } -//////}); - -let _group = Func.extend({ - instance = { - inst - - func __call__(self, _args) { - let args = _args.from(1); - return __intern_regex_match_group__(self.inst.re.pattern, self.inst.string, *args); - } + func match(_, pattern, string, flags=0) { + let x = __intern_regex_match__(pattern, string, flags); + return Match.new(x[0], x[1], Pattern.new(x[2][0], x[2][1], x[2][2], x[2][3], x[3]), x[3], x[4], x[5], x[6]); } - - func __construct__(self, _inst) { - self.inst = _inst; - - return self; + func fullmatch(_, pattern, string, flags=0) { + let x = __intern_regex_fullmatch__(pattern, string, flags); + return Match.new(x[0], x[1], Pattern.new(x[2][0], x[2][1], x[2][2], x[2][3], x[3]), x[3], x[4], x[5], x[6]); } -}); - -let _groupdict = Func.extend({ - instance = { - inst - - func __call__(self, _args) { - let args = _args.from(1); - return __intern_regex_match_groupdict__(self.inst.re.pattern, self.inst.string, *args); - } + func split(_, pattern, string, maxsplit=0, flags=0) { + return __intern_regex_split__(pattern, string, maxsplit, flags); } - - func __construct__(self, _inst) { - self.inst = _inst; - - return self; + func findall(_, pattern, string, flags=0) { + return __intern_regex_findall__(pattern, string, flags); } -}); - -let _span = Func.extend({ - instance = { - inst - - func __call__(self, _args) { - let args = _args.from(1); - return __intern_regex_match_span__(self.inst.re.pattern, self.inst.string, *args); - } + func finditer(_, pattern, string, flags=0) { + return __intern_regex_finditer__(pattern, string, flags); } - - func __construct__(self, _inst) { - self.inst = _inst; - - return self; + func sub(_, pattern, repl, string, count=0, flags=0) { + return __intern_regex_sub__(pattern, repl, string, count, flags); } -}); - -let _groups = Func.extend({ - instance = { - inst - - func __call__(self, _args) { - let args = _args.from(1); - return __intern_regex_match_groups__(self.inst.re.pattern, self.inst.string, *args); - } + func subn(_, pattern, repl, string, count=0, flags=0) { + return __intern_regex_subn__(pattern, repl, string, count, flags); } - - func __construct__(self, _inst) { - self.inst = _inst; - - return self; - } -}); - -let _start = Func.extend({ - instance = { - inst - - func __call__(self, _args) { - let args = _args.from(1); - return __intern_regex_match_start__(self.inst.re.pattern, self.inst.string, *args); - } + func escape(_, pattern) { + return __intern_regex_escape__(pattern); } - - func __construct__(self, _inst) { - self.inst = _inst; - - return self; - } -}); - - - -let regex = Type.extend({ - name = 'Regex' - - func search(_, re, input) { - let x = __intern_regex_search__(re, input); - return Match.new(x[0], x[1], x[2], x[3], x[4], x[5]); + func purge(_) { + return __intern_regex_purge__(); } }); @@ -137,86 +49,30 @@ let Pattern = Type.extend({ flags pattern - ////findall = Func.extend({ - //// instance = { - //// func __call__(self, _args) { - //// let args = _args.from(1); - //// return __intern_regex_pattern_findall__(*args); - //// } - //// } - ////}).new() - - ////////scanner = Func.extend({ - //////// instance = { - //////// func __call__(self, _args) { - //////// let args = _args.from(1); - //////// return __intern_regex_pattern_scanner__(*args); - //////// } - //////// } - ////////}).new() - - ////subn = Func.extend({ - //// instance = { - //// func __call__(self, _args) { - //// let args = _args.from(1); - //// return __intern_regex_pattern_subn__(*args); - //// } - //// } - ////}).new() - - ////////finditer = Func.extend({ - //////// instance = { - //////// func __call__(self, _args) { - //////// let args = _args.from(1); - //////// return __intern_regex_pattern_finditer__(*args); - //////// } - //////// } - ////////}).new() - - ////search = Func.extend({ - //// instance = { - //// func __call__(self, _args) { - //// let args = _args.from(1); - //// return __intern_regex_pattern_search__(*args); - //// } - //// } - ////}).new() - - ////match = Func.extend({ - //// instance = { - //// func __call__(self, _args) { - //// let args = _args.from(1); - //// return __intern_regex_pattern_match__(*args); - //// } - //// } - ////}).new() - - ////split = Func.extend({ - //// instance = { - //// func __call__(self, _args) { - //// let args = _args.from(1); - //// return __intern_regex_pattern_split__(*args); - //// } - //// } - ////}).new() - - ////fullmatch = Func.extend({ - //// instance = { - //// func __call__(self, _args) { - //// let args = _args.from(1); - //// return __intern_regex_pattern_fullmatch__(*args); - //// } - //// } - ////}).new() - - ////sub = Func.extend({ - //// instance = { - //// func __call__(self, _args) { - //// let args = _args.from(1); - //// return __intern_regex_pattern_sub__(*args); - //// } - //// } - ////}).new() + func search(self, string, pos=0, endpos=0) { + return __intern_regex_pattern_search__([self.pattern, self.flags], pattern, string, flags); + } + func match(self, string, pos=0, endpos=0) { + return __intern_regex_pattern_match__([self.pattern, self.flags], pattern, string, flags); + } + func fullmatch(self, string, pos=0, endpos=0) { + return __intern_regex_pattern_fullmatch__([self.pattern, self.flags], pattern, string, flags); + } + func split(self, string, maxsplit=0) { + return __intern_regex_pattern_split__([self.pattern, self.flags], string, maxsplit); + } + func findall(self, string, pos=0, endpos=0) { + return __intern_regex_pattern_findall__([self.pattern, self.flags], pattern, string, flags); + } + func finditer(self, string, pos=0, endpos=0) { + return __intern_regex_pattern_finditer__([self.pattern, self.flags], pattern, string, flags); + } + func sub(self, repl, string, count=0) { + return __intern_regex_pattern_sub__([self.pattern, self.flags], pattern, string, flags); + } + func subn(self, repl, string, count=0) { + return __intern_regex_pattern_subn__([self.pattern, self.flags], pattern, string, flags); + } func to_str(self) { return "Pattern(" + self.pattern + ")"; @@ -248,50 +104,69 @@ let Match = Type.extend({ re string lastgroup - //regs + regs lastindex - end - //expand - group - groupdict - span - groups - start + func end(self, group=null) { + return __intern_regex_match_end__([self.re.pattern, self.string, self.re.flags], group); + } + func expand(self, template) { + return __intern_regex_match_expand__([self.re.pattern, self.string, self.re.flags], template); + } + func group(self, *group1) { + return __intern_regex_match_group__([self.re.pattern, self.string, self.re.flags], group1); + } + func groupdict(self, default=null) { + return __intern_regex_match_groupdict__([self.re.pattern, self.string, self.re.flags], default); + } + func span(self, group=null) { + return __intern_regex_match_span__([self.re.pattern, self.string, self.re.flags], group); + } + func groups(self, default=null) { + return __intern_regex_match_groups__([self.re.pattern, self.string, self.re.flags], default); + } + func start(self, group=null) { + return __intern_regex_match_start__([self.re.pattern, self.string, self.re.flags], group); + } func to_str(self) { return "Match(span: " + self.span() + ", match: " + self.group() + ")"; } } - func __construct__(self, _pos, _endpos, _re, _string, _lastgroup, _lastindex) { + func __construct__(self, _pos, _endpos, _re, _string, _lastgroup, _regs, _lastindex) { self.pos = _pos; self.endpos = _endpos; - - if re.type() == Pattern { - self.re = _re; - } - else { - self.re = Pattern.new(_re[0], _re[1], _re[2], _re[3]); - } - + self.re = _re; self.string = _string; self.lastgroup = _lastgroup; - //self.regs = _regs; + self.regs = _regs; self.lastindex = _lastindex; - self.end = _end.new(self); - //self.expand = _expand.new(self); - self.group = _group.new(self); - self.groupdict = _groupdict.new(self); - self.span = _span.new(self); - self.groups = _groups.new(self); - self.start = _start.new(self); - return self; } }); +let RegexError = Exception.extend({ + name = 'RegexError' + + instance = { + pattern + pos + + func raise(self) { + return raise(self, "Regex Error"); + } + } + + func __construct__(self, _message, _pattern=null, _pos=null) { + self.message = _message; + self.pattern = _pattern; + self.pos = _pos; + } +}); + + //import "std/regex.para"; //let txt = "The rain in Spain"; //let x = regex.search("\\bS\\w+", txt); diff --git a/std/requests.para b/std/requests.para index 2ada645..7209737 100644 --- a/std/requests.para +++ b/std/requests.para @@ -1,68 +1,33 @@ let requests = Type.extend({ name = 'Requests' - get = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return intern_list_to_response(__intern_requests_get__(*args)); - } - } - }).new() - - post = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return intern_list_to_response(__intern_requests_post__(*args)); - } - } - }).new() - - put = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return intern_list_to_response(__intern_requests_put__(*args)); - } - } - }).new() - - head = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return intern_list_to_response(__intern_requests_head__(*args)); - } - } - }).new() + func get(_, url, params=null, *args) { + return intern_list_to_response(__intern_requests_get__(url, params, *args)); + } - delete = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return intern_list_to_response(__intern_requests_delete__(*args)); - } - } - }).new() - - patch = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return intern_list_to_response(__intern_requests_patch__(*args)); - } - } - }).new() + func post(_, url, data=null, json=null, *args) { + return intern_list_to_response(__intern_requests_post__(url, data, json, *args)); + } + + func put(_, url, data=null, *args) { + return intern_list_to_response(__intern_requests_put__(url, data, *args)); + } + + func head(_, url, *args) { + return intern_list_to_response(__intern_requests_head__(url, *args)); + } - request = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - return intern_list_to_response(__intern_requests_request__(*args)); - } - } - }).new() + func delete(_, url, *args) { + return intern_list_to_response(__intern_requests_delete__(url, *args)); + } + + func patch(_, url, *args) { + return intern_list_to_response(__intern_requests_patch__(url, *args)); + } + + func request(_, method, url, *args) { + return intern_list_to_response(__intern_requests_request__(method, url, *args)); + } }); let Response = Type.extend({ diff --git a/std/scipara.para b/std/scipara.para index 4919099..162ffbb 100644 --- a/std/scipara.para +++ b/std/scipara.para @@ -1,4 +1,4 @@ -io.evaluate("import os\ntry:\n import scipy\nexcept ImportError:\n os.system('pip install numpy scipy matplotlib ipython jupyter pandas sympy nose')"); +io.pyeval("import os\ntry:\n import scipy\nexcept ImportError:\n os.system('pip install numpy scipy matplotlib ipython jupyter pandas sympy nose')"); let SciPara: type = Type.extend({ instance = { diff --git a/std/types/exceptions/exception.para b/std/types/exceptions/exception.para index 2ec3e14..103e3f4 100644 --- a/std/types/exceptions/exception.para +++ b/std/types/exceptions/exception.para @@ -1,25 +1,18 @@ -let raise = Func.extend({ - instance = { - func __call__(self, _args) { - let args = _args.from(1); - - let classnames = []; - let current = args[0].type(); - while current != Exception { - classnames.append(current.to_str()); - current = current.type(); - } - classnames.append("Exception"); - if args.len() > 1 { - return __intern_exception_raise__(args[1], args[0].message, classnames); - } - else { - return __intern_exception_raise__(args[0].type().name, args[0].message, classnames); - } - } +func raise(exception, name="") { + let classnames = []; + let current = exception.type(); + while current != Exception { + classnames.append(current.to_str()); + current = current.type(); } -}).new(); - + classnames.append("Exception"); + if name != "" { + return __intern_exception_raise__(name, exception.message, classnames, exception); + } + else { + return __intern_exception_raise__(exception.type().name, exception.message, classnames, exception); + } +} let Exception = Type.extend({ name = 'Exception' diff --git a/std/types/str.para b/std/types/str.para index 19977c5..af3deef 100644 --- a/std/types/str.para +++ b/std/types/str.para @@ -22,7 +22,7 @@ let Str = Array.extend({ return 0; } - return __intern_default_compare__(self._value, other._value); + return __intern_default_compare__(self, other); } func to_str(self) { @@ -38,23 +38,24 @@ let Str = Array.extend({ return self.find(value) == self.len() - value.len(); } - replace + func replace(self, old, new, count=1) { + return __intern_str_replace__(self, old, new, count); + } func tolower(self) { - return __intern_str_tolower__(self._value); + return __intern_str_tolower__(self); } func toupper(self) { - return __intern_str_toupper__(self._value); + return __intern_str_toupper__(self); } func totitle(self) { - return __intern_str_totitle__(self._value); + return __intern_str_totitle__(self); } func __construct__(self, value) { self._value = value; - self.replace = intern_replace.new(self); return self; } @@ -64,7 +65,7 @@ let Str = Array.extend({ } func append(self, value) { - return __intern_str_append__(self._value, value.to_str()); + return __intern_str_append__(self, value.to_str()); } func to_int(self) { @@ -153,63 +154,31 @@ let Str = Array.extend({ let newstr = ""; let index = self.len(); while index { - newstr = newstr.append(self._value[index-1]); + newstr = newstr.append(self[index-1]); index -= 1; } return newstr; } - func to_str(self) { - return self.name; - } - - format = Func.extend({ - instance = { - func __call__(self, args) { - let str = args[0]; - - let newstr = ""; - let length = str.len(); - let index = 0; - let argidx = 1; - while index != length { - if str[index] == '%' { - newstr += (args[argidx]); - argidx += 1; - } - else { - newstr += str[index]; - } - index += 1; - } - return newstr; + func format(self, str, *args) { + let newstr = ""; + let length = str.len(); + let index = 0; + let argidx = 0; + while index != length { + if str[index] == '%' { + newstr += (args[argidx]); + argidx += 1; } - } - }).new() -}); - -let intern_replace = Func.extend({ - instance = { - value - - func __call__(self, _args) { - let args = _args.from(1); - let toReplace = args[0]; - let replaceWith = args[1]; - if args.len() > 2 { - let amount = args[2]; - return __intern_str_replace__(self.value._value, toReplace._value, replaceWith._value, amount); - } else { - return __intern_str_replace__(self.value._value, toReplace._value, replaceWith._value); + newstr += str[index]; } - return self.value; - } - } - - func __construct__(self, value) { - self.value = value; + index += 1; + } + return newstr; + } - return self; + func to_str(self) { + return self.name; } }); diff --git a/std/types/timedelta.para b/std/types/timedelta.para index 7457a02..108e583 100644 --- a/std/types/timedelta.para +++ b/std/types/timedelta.para @@ -6,15 +6,6 @@ let TimeDelta = Type.extend({ seconds = 0 microseconds = 0 - //min = Func.extend({ - // instance = { - // func __call__(self, _args) { - // let args = _args.from(1); - // return __intern_timedelta_min__(); - // } - // } - //}).new() - func to_str(self) { return "TimeDelta(" + self.days + ", " + self.seconds + ", " + self.microseconds + ")"; } diff --git a/std/types/tk.para b/std/types/tk.para index 8ed614d..77d0eb7 100644 --- a/std/types/tk.para +++ b/std/types/tk.para @@ -10,11 +10,11 @@ let tk = Type.extend({ func setWindowTitle(self, title) { self.windowTitle = title; - return io.evaluate(self.variableName + '.title("' + title + '")'); + return io.pyeval(self.variableName + '.title("' + title + '")'); } func mainloop(self) { - return io.evaluate(self.variableName + '.mainloop()'); + return io.pyeval(self.variableName + '.mainloop()'); } func bind(self, ev, fun) { @@ -39,7 +39,7 @@ let tk = Type.extend({ + ' paraCode.data = data\n' + self.variableName + '.bind("' + ev + '", run)'; print(code); - return io.evaluate(code); + return io.pyeval(code); } addLabel @@ -51,7 +51,7 @@ let tk = Type.extend({ func __construct__(self, name) { self.variableName = name; - io.evaluate('import tkinter as tk; ' + self.variableName + ' = tk.Tk()'); + io.pyeval('import tkinter as tk; ' + self.variableName + ' = tk.Tk()'); self.setWindowTitle(name); self.addLabel = label.new(self); @@ -87,12 +87,12 @@ let Frame = Type.extend({ func setWidth(self, width) { self.width = width; - return io.evaluate(self.variableName + '.config(width=' + width + ')'); + return io.pyeval(self.variableName + '.config(width=' + width + ')'); } func setHeight(self, height) { self.height = height; - return io.evaluate(self.variableName + '.config(height=' + height + ')'); + return io.pyeval(self.variableName + '.config(height=' + height + ')'); } func setSize(self, width, height) { @@ -101,7 +101,7 @@ let Frame = Type.extend({ } func bind(self, ev, fun) { - return io.evaluate('from ParaCode import ParaCode\n' + return io.pyeval('from ParaCode import ParaCode\n' + 'def run(event):\n' + ' paraCode = ParaCode()\n' + ' paraCode.eval_data(' + fun + '(event.char, event.type)' + ')\n' @@ -140,43 +140,7 @@ let frame = Func.extend({ func __call__(self, _args) { let args = _args.from(1); - let width; - let height; - let bgColor; - let fgColor; - let master = self.tk1.variableName; - let code = 'import tkinter as tk; ' + text + ' = tk.Frame('; - if args.len() > 0 { - master = args[0]; - code += ', master=' + master; - } - if args.len() > 1 { - width = args[1]; - code += ', width=' + width; - } - if args.len() > 2 { - height = args[2]; - code += ', height=' + height; - } - if args.len() > 3 { - bgColor = args[3]; - code += ', bg="' + bgColor + '"'; - } - if args.len() > 4 { - fgColor = args[4]; - code += ', fg="' + fgColor + '"'; - } - code += ')'; - let index = 1; - for frame in self.tk1.frames { - index += 1; - } - let fr = Frame.new('frame' + index.to_str()); - fr.tk1 = self.tk1; - fr.master = master; - self.tk1.frame[text] = fr; - io.evaluate(code); - return fr; + } } @@ -197,11 +161,11 @@ let Label = Type.extend({ func setText(self, text) { self.text = text; - return io.evaluate(self.variableName + '.config(text="' + text + '")'); + return io.pyeval(self.variableName + '.config(text="' + text + '")'); } func bind(self, ev, fun) { - return io.evaluate('from ParaCode import ParaCode; paraCode = ParaCode(); ' + self.variableName + '.bind("' + ev + '", lambda fun: paraCode.eval_data(' + fun + '(event.char, event.type)' + '))'); + return io.pyeval('from ParaCode import ParaCode; paraCode = ParaCode(); ' + self.variableName + '.bind("' + ev + '", lambda fun: paraCode.eval_data(' + fun + '(event.char, event.type)' + '))'); } pack @@ -252,7 +216,7 @@ let label = Func.extend({ lb.tk1 = self.tk1; lb.master = master; self.tk1.labels[text] = lb; - io.evaluate(code); + io.pyeval(code); return lb; } } @@ -276,17 +240,17 @@ let Button = Type.extend({ func setText(self, text) { self.text = text; - return io.evaluate(self.variableName + '.config(text="' + text + '")'); + return io.pyeval(self.variableName + '.config(text="' + text + '")'); } func setWidth(self, width) { self.width = width; - return io.evaluate(self.variableName + '.config(width=' + width + ')'); + return io.pyeval(self.variableName + '.config(width=' + width + ')'); } func setHeight(self, height) { self.height = height; - return io.evaluate(self.variableName + '.config(height=' + height + ')'); + return io.pyeval(self.variableName + '.config(height=' + height + ')'); } func setSize(self, width, height) { @@ -295,7 +259,7 @@ let Button = Type.extend({ } func bind(self, ev, fun) { - return io.evaluate('from ParaCode import ParaCode; paraCode = ParaCode(); ' + self.variableName + '.bind("' + ev + '", lambda fun: paraCode.eval_data(' + fun + '(event.char, event.type)' + '))'); + return io.pyeval('from ParaCode import ParaCode; paraCode = ParaCode(); ' + self.variableName + '.bind("' + ev + '", lambda fun: paraCode.eval_data(' + fun + '(event.char, event.type)' + '))'); } pack @@ -354,7 +318,7 @@ let button = Func.extend({ b.tk1 = self.tk1; b.master = master; self.tk1.buttons[text] = b; - io.evaluate(code); + io.pyeval(code); return b; } } @@ -378,17 +342,17 @@ let Entry = Type.extend({ func setText(self, text) { self.text = text; - return io.evaluate(self.variableName + '.config(text="' + text + '")'); + return io.pyeval(self.variableName + '.config(text="' + text + '")'); } func setWidth(self, width) { self.width = width; - return io.evaluate(self.variableName + '.config(width=' + width + ')'); + return io.pyeval(self.variableName + '.config(width=' + width + ')'); } func setHeight(self, height) { self.height = height; - return io.evaluate(self.variableName + '.config(height=' + height + ')'); + return io.pyeval(self.variableName + '.config(height=' + height + ')'); } func setSize(self, width, height) { @@ -397,7 +361,7 @@ let Entry = Type.extend({ } func bind(self, ev, fun) { - return io.evaluate('from ParaCode import ParaCode; paraCode = ParaCode(); ' + self.variableName + '.bind("' + ev + '", lambda fun: paraCode.eval_data(' + fun + '(event.char, event.type)' + '))'); + return io.pyeval('from ParaCode import ParaCode; paraCode = ParaCode(); ' + self.variableName + '.bind("' + ev + '", lambda fun: paraCode.eval_data(' + fun + '(event.char, event.type)' + '))'); } get @@ -462,7 +426,7 @@ let entry = Func.extend({ ent.tk1 = self.tk1; ent.master = master; self.tk1.entries = self.tk1.entries.append([text1, ent]); - io.evaluate(code); + io.pyeval(code); return ent; } } @@ -486,17 +450,17 @@ let Text = Type.extend({ func setText(self, text) { self.text = text; - return io.evaluate(self.variableName + '.config(text="' + text + '")'); + return io.pyeval(self.variableName + '.config(text="' + text + '")'); } func setWidth(self, width) { self.width = width; - return io.evaluate(self.variableName + '.config(width=' + width + ')'); + return io.pyeval(self.variableName + '.config(width=' + width + ')'); } func setHeight(self, height) { self.height = height; - return io.evaluate(self.variableName + '.config(height=' + height + ')'); + return io.pyeval(self.variableName + '.config(height=' + height + ')'); } func setSize(self, width, height) { @@ -505,7 +469,7 @@ let Text = Type.extend({ } func bind(self, ev, fun) { - return io.evaluate('from ParaCode import ParaCode; paraCode = ParaCode(); ' + self.variableName + '.bind("' + ev + '", lambda fun: paraCode.eval_data(' + fun + '(event.char, event.type)' + '))'); + return io.pyeval('from ParaCode import ParaCode; paraCode = ParaCode(); ' + self.variableName + '.bind("' + ev + '", lambda fun: paraCode.eval_data(' + fun + '(event.char, event.type)' + '))'); } get @@ -570,7 +534,7 @@ let text = Func.extend({ tex.tk1 = self.tk1; tex.master = master; self.tk1.texts = self.tk1.texts.append([text1, tex]); - io.evaluate(code); + io.pyeval(code); return tex; } } @@ -595,7 +559,7 @@ let doGet = Func.extend({ code += index.to_str(); } code += ')'; - return io.evaluate(code); + return io.pyeval(code); } } @@ -633,7 +597,7 @@ let doDelete = Func.extend({ } } code += ')'; - return io.evaluate(code); + return io.pyeval(code); } } @@ -663,7 +627,7 @@ let doInsert = Func.extend({ code += text; code += '"'; code += ')'; - return io.evaluate(code); + return io.pyeval(code); } } @@ -692,7 +656,7 @@ let doPack = Func.extend({ code += ', pady=' + padY; } code += ')'; - return io.evaluate(code); + return io.pyeval(code); } } @@ -730,7 +694,7 @@ let doPlace = Func.extend({ code += ', sticky="' + sticky + '"'; } code += ')'; - return io.evaluate(code); + return io.pyeval(code); } } @@ -753,7 +717,7 @@ let doGrid = Func.extend({ code += 'row="' + row + '"'; code += ', column="' + column + '"'; code += ')'; - return io.evaluate(code); + return io.pyeval(code); } } @@ -773,7 +737,7 @@ let doDestroy = Func.extend({ let row = args[0]; let column = args[1]; let code = 'import tkinter as tk; ' + self.tk1.variableName + '.destroy()'; - return io.evaluate(code); + return io.pyeval(code); } } diff --git a/util.py b/util.py index 6704a61..7cad7fe 100644 --- a/util.py +++ b/util.py @@ -4,3 +4,20 @@ class LogColor(): Warning = "\033[33m" Info = "\033[34m" Bold = "\033[1m" + +def fixiter(values, make_basic_value=True): + from interpreter.basic_value import BasicValue + + result = [] + for value in values: + if type(value) in [list, set, tuple]: + result.append(fixiter(value)) + else: + if make_basic_value: + result.append(BasicValue(value)) + else: + result.append(value) + if make_basic_value: + return BasicValue(result) + else: + return result