Commit Graph

76 Commits

Author SHA1 Message Date
K Lange
ff8ed02ebd Make print() a function before it's too late 2021-01-04 23:34:10 +09:00
K. Lange
873ffb3428 Eat empty line in block? 2021-01-04 19:56:13 +09:00
K. Lange
bfae38538d Need to turn off whitespace eating _before_ the close paren 2021-01-04 19:07:19 +09:00
K. Lange
61a38f3a5f That dup isn't necessary 2021-01-04 18:15:17 +09:00
K. Lange
b93429d6a6 Oops, fix strings; simplify bytecode around getters/setters; use this approach for slicing 2021-01-04 18:10:55 +09:00
K. Lange
cfecb2e4f6 Accept BIG_STRING as __doc__ 2021-01-04 16:20:01 +09:00
K. Lange
583df9141c 'not in' comparison 2021-01-04 14:03:08 +09:00
K. Lange
b8c89c0550 add ValueError to builtin exceptions 2021-01-04 11:27:33 +09:00
K. Lange
90a4dd678d Ignore line feeds and indentation in some contexts 2021-01-04 09:49:56 +09:00
K. Lange
132542c6ab allow 'elif' for Python compatibility 2021-01-04 09:13:39 +09:00
K. Lange
3415fd4e73 from foo import bar as baz 2021-01-04 07:48:56 +09:00
K. Lange
8ef070bf94 Support 'from foo import bar, baz' 2021-01-04 07:47:05 +09:00
K. Lange
d1d6a7a3fe 'let' should support multiple comma-separated declarations 2021-01-04 07:40:29 +09:00
K. Lange
aa1c0c8e93 Support 'import foo as bar' 2021-01-04 07:39:00 +09:00
K. Lange
2ee154ecf7 Add argument expansions... 2021-01-03 18:13:17 +09:00
K. Lange
36716e3508 Support * and ** in function signatures for collections of additional arguments and keyword args 2021-01-03 16:02:50 +09:00
K. Lange
3f848dba19 merge string constants like Python does 2021-01-03 14:20:55 +09:00
K. Lange
8ad29f7891 Ditch character literals and add single, triple strings 2021-01-03 14:09:45 +09:00
K. Lange
76e70b79d0 Add default argument values.
Unlike in Python, I'm taking the approach of evaluating these at function
call time rather than definition time. Assigning things like empty lists/dicts
to default arguments has always been a ridiculous thing in Python, and I don't
want to make that mistake. I'm pretty sure Python only continues to do that
because it was something they didn't want to break for backwards compatibility
reasons even in Python 3.
2021-01-03 12:32:04 +09:00
K. Lange
e46d753999 Basic support for keyword arguments when calling functions. 2021-01-03 12:09:41 +09:00
K. Lange
93af369b8c Quietly pretend we didn't just do that different from Python for no reason 2021-01-03 09:29:09 +09:00
K. Lange
31751745cd How did I not catch that earlier... need to _check_, not match, EOL on return statement 2021-01-03 09:15:50 +09:00
K. Lange
b676df69da Add method decorators
This required a new approach for handling function arguments.

Methods remain the same: the callee object is on the stack and positioned
to be "argument 0". Non-methods have changed so that "argument 0" is the
first argument, with the function still remaining before that. When a
non-method is called, we track this fact so that we can continue to restore
the stack to the correct height to get rid of the function. This allows
a method decorator to be defined exactly like it would be in Python

def methodDecorator(func):
    def wrappedMethod(instance, someOtherArg):
        print "Do something with the arg:", someOtherArg
        func(instance)

class Foo():
    @methodDecorator
    def func():
        print "I only take an implicit self:", self

let f = Foo()
f.func("but that other arg is needed")
2021-01-03 08:43:32 +09:00
K. Lange
1de1fbc150 Basic non-method decorator support? 2021-01-02 21:58:24 +09:00
K. Lange
542e219192 Redefine list comprehension and add infix in 2021-01-02 19:46:21 +09:00
K. Lange
b1b747b234 Some improvements to debug output before I move on to a marshalling format 2021-01-02 13:42:07 +09:00
K. Lange
7b506e6190 actually use OP_CALL_LONG 2021-01-02 12:52:12 +09:00
K. Lange
6164c3ebf4 General code cleanup. 2021-01-02 12:21:11 +09:00
K. Lange
9211b04fc1 Add 'else if'; don't do Python's elif thing, I don't like that. 2021-01-02 12:13:01 +09:00
K. Lange
b42844f842 Fully internalize list+dict core methods and implement invokes for getters/setters 2021-01-01 20:52:18 +09:00
K. Lange
1242f2f10f try to namespace everything 2021-01-01 16:58:13 +09:00
K. Lange
1dca833d6f add assignment shortcut operators (probably not worth using until optimizations are in place) 2021-01-01 10:42:16 +09:00
K. Lange
58132eedf8 Add binary operators 2021-01-01 08:55:39 +09:00
K. Lange
2b3a5cec60 String slicing, and general syntax support 2020-12-31 18:32:37 +09:00
K. Lange
9a370f00e1 Add continue/break statements 2020-12-31 16:59:51 +09:00
K. Lange
0031048ff7 Fix missing nil terminator in _builtins_src[] 2020-12-31 13:50:17 +09:00
K. Lange
0b2c9df58f shove list comprehensions into their own fake call frames because everything is terrible 2020-12-30 22:30:09 +09:00
K. Lange
33f7561076 List comprehensions, and several gc+scoping fixes along the way 2020-12-30 21:57:13 +09:00
K. Lange
f7e1c0da0d Add docstrings, __doc__, and help() 2020-12-30 16:59:21 +09:00
K Lange
9fd9d81afe eliminate arbitrary size restrictions where possible 2020-12-29 06:33:16 +09:00
K. Lange
f7e3a28408 int/float casts for strings 2020-12-30 11:26:07 +09:00
K. Lange
1ae9828570 export should be able to take multiple arguments; fix resolution bug when export statement does not follow object to be exported 2020-12-30 10:19:52 +09:00
K. Lange
b19fc3a477 Add syntax for list/dict expressions 2020-12-30 09:01:52 +09:00
K. Lange
428c368a75 Support optional arguments by tracking separate arities 2020-12-30 08:00:48 +09:00
K. Lange
5ff31e7d96 fix parse error line output for error tokens from scanner 2020-12-29 22:16:35 +09:00
K. Lange
267c7b5650 rudimentary character literal, specifically for bim syntax [sorry if you like single-quote strings in python] 2020-12-29 21:29:15 +09:00
K. Lange
4c651592f8 fix up some compiler eof stuff to make embedding more reasonable 2020-12-29 18:50:39 +09:00
K. Lange
2c18402d40 escape sequences in strings 2020-12-29 16:26:00 +09:00
K. Lange
c6e5c8c120 once again, completely redo the parsing for indentation so that we can have pretty syntax errors 2020-12-29 15:26:45 +09:00
K. Lange
105e92f846 gobble more line feeds and handle eof condition on if/try without matching else/except 2020-12-29 12:40:19 +09:00