micropython/py
Damien George 1831034be1 py: Allow lexer to raise exceptions during construction.
This patch refactors the error handling in the lexer, to simplify it (ie
reduce code size).

A long time ago, when the lexer/parser/compiler were first written, the
lexer and parser were designed so they didn't use exceptions (ie nlr) to
report errors but rather returned an error code.  Over time that has
gradually changed, the parser in particular has more and more ways of
raising exceptions.  Also, the lexer never really handled all errors without
raising, eg there were some memory errors which could raise an exception
(and in these rare cases one would get a fatal nlr-not-handled fault).

This patch accepts the fact that the lexer can raise exceptions in some
cases and allows it to raise exceptions to handle all its errors, which are
for the most part just out-of-memory errors during construction of the
lexer.  This makes the lexer a bit simpler, and also the persistent code
stuff is simplified.

What this means for users of the lexer is that calls to it must be wrapped
in a nlr handler.  But all uses of the lexer already have such an nlr
handler for the parser (and compiler) so that doesn't put any extra burden
on the callers.
2017-03-14 11:52:05 +11:00
..
argcheck.c
asmarm.c
asmarm.h
asmbase.c
asmbase.h
asmthumb.c
asmthumb.h
asmx64.c
asmx64.h
asmx86.c
asmx86.h
asmxtensa.c
asmxtensa.h
bc.c
bc.h
bc0.h py: Allow bytecode/native to put iter_buf on stack for simple for loops. 2017-02-16 18:38:06 +11:00
binary.c
binary.h
builtin.h
builtinevex.c py: Allow lexer to raise exceptions during construction. 2017-03-14 11:52:05 +11:00
builtinhelp.c
builtinimport.c py: Allow lexer to raise exceptions during construction. 2017-03-14 11:52:05 +11:00
compile.c py: Create str/bytes objects in the parser, not the compiler. 2017-02-24 13:43:43 +11:00
compile.h
emit.h py: Remove unused "use_stack" argument from for_iter_end emit function. 2017-02-16 18:38:06 +11:00
emitbc.c py: Remove unused "use_stack" argument from for_iter_end emit function. 2017-02-16 18:38:06 +11:00
emitcommon.c
emitglue.c
emitglue.h
emitinlinethumb.c py: Create str/bytes objects in the parser, not the compiler. 2017-02-24 13:43:43 +11:00
emitinlinextensa.c
emitnative.c py: Remove unused "use_stack" argument from for_iter_end emit function. 2017-02-16 18:38:06 +11:00
formatfloat.c
formatfloat.h
frozenmod.c
frozenmod.h
gc.c
gc.h
grammar.h py/grammar: Remove unused rule. 2017-02-17 12:48:45 +11:00
lexer.c py: Allow lexer to raise exceptions during construction. 2017-03-14 11:52:05 +11:00
lexer.h py/lexer: Convert mp_uint_t to size_t where appropriate. 2017-02-17 12:44:24 +11:00
makeqstrdata.py
makeqstrdefs.py
makeversionhdr.py
malloc.c
map.c py/map: Fix bugs with deletion of elements from OrderedDict. 2017-03-03 11:21:19 +11:00
misc.h
mkenv.mk
mkrules.mk
modarray.c
modbuiltins.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
modcmath.c
modcollections.c
modgc.c
modio.c
modmath.c
modmicropython.c
modstruct.c
modsys.c py/modsys: Use MP_SMALL_INT_MAX for sys.maxsize in case of LONGINT_IMPL_NONE. 2017-03-06 12:15:25 +01:00
modthread.c py: Move locals/globals dicts to the thread-specific state. 2017-03-06 17:01:56 +11:00
moduerrno.c py/moduerrno: Make list of errno codes configurable. 2017-02-22 12:58:11 +11:00
mpconfig.h py/moduerrno: Make uerrno.errorcode dict configurable. 2017-02-22 12:58:11 +11:00
mperrno.h
mphal.h
mpprint.c
mpprint.h
mpstate.c
mpstate.h py: Move locals/globals dicts to the thread-specific state. 2017-03-06 17:01:56 +11:00
mpthread.h
mpz.c py/mpz: Change type of "base" args from mp_uint_t to unsigned int. 2017-02-16 16:51:16 +11:00
mpz.h py/mpz: Change type of "base" args from mp_uint_t to unsigned int. 2017-02-16 16:51:16 +11:00
nativeglue.c py: Optimise storage of iterator so it takes only 4 slots on Py stack. 2017-02-16 18:38:06 +11:00
nlr.h py/nlr.h: Mark nlr_jump_fail as NORETURN. 2017-03-06 17:13:16 +11:00
nlrsetjmp.c
nlrthumb.c
nlrx64.c py/nlrx64: Fixes to support Mac OS. 2017-03-08 22:36:02 +11:00
nlrx86.c py/nlrx86: Add workaround for Zephyr. 2017-03-07 16:48:09 +01:00
nlrxtensa.c py/nlrxtensa: Convert from assembler to C file with inline asm. 2017-03-06 17:13:16 +11:00
obj.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
obj.h py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
objarray.c py/objarray: Disallow slice-assignment to read-only memoryview. 2017-02-27 16:09:57 +11:00
objarray.h py/objarray: Convert mp_uint_t to size_t where appropriate. 2017-02-16 16:51:16 +11:00
objattrtuple.c py/objtuple: Convert mp_uint_t to size_t where appropriate. 2017-02-16 16:51:16 +11:00
objbool.c
objboundmeth.c
objcell.c
objclosure.c py/objclosure: Convert mp_uint_t to size_t where appropriate. 2017-02-16 16:51:17 +11:00
objcomplex.c
objdict.c py: De-optimise some uses of mp_getiter, so they don't use the C stack. 2017-02-16 19:11:34 +11:00
objenumerate.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
objexcept.c py/objexcept: Convert mp_uint_t to size_t where appropriate. 2017-02-16 16:51:17 +11:00
objexcept.h py/objexcept: Convert mp_uint_t to size_t where appropriate. 2017-02-16 16:51:17 +11:00
objfilter.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
objfloat.c
objfun.c py: Use mp_obj_get_array where sequence may be a tuple or a list. 2017-03-07 16:48:16 +11:00
objfun.h
objgenerator.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
objgenerator.h
objgetitemiter.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
objint.c py/objint: Convert mp_uint_t to size_t where appropriate. 2017-02-16 16:51:17 +11:00
objint.h
objint_longlong.c py/objint_longlong: Implement mp_obj_int_from_bytes_impl(). 2017-03-10 00:22:53 +01:00
objint_mpz.c py/objint: Convert mp_uint_t to size_t where appropriate. 2017-02-16 16:51:17 +11:00
objlist.c py/objlist: For list slice assignment, allow RHS to be a tuple or list. 2017-02-20 15:09:59 +11:00
objlist.h py/objlist: Convert mp_uint_t to size_t where appropriate. 2017-02-16 16:51:16 +11:00
objmap.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
objmodule.c
objmodule.h
objnamedtuple.c
objnone.c
objobject.c
objpolyiter.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
objproperty.c
objrange.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
objreversed.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
objset.c py: De-optimise some uses of mp_getiter, so they don't use the C stack. 2017-02-16 19:11:34 +11:00
objsingleton.c
objslice.c
objstr.c py: Use mp_obj_get_array where sequence may be a tuple or a list. 2017-03-07 16:48:16 +11:00
objstr.h py/objstr: Convert mp_uint_t to size_t (and use int) where appropriate. 2017-02-16 16:51:16 +11:00
objstringio.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
objstringio.h
objstrunicode.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
objtuple.c py: De-optimise some uses of mp_getiter, so they don't use the C stack. 2017-02-16 19:11:34 +11:00
objtuple.h py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
objtype.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
objtype.h
objzip.c py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
opmethods.c
parse.c py/parse: Simplify handling of errors by raising them directly. 2017-02-24 14:56:37 +11:00
parse.h
parsenum.c
parsenum.h
parsenumbase.c
parsenumbase.h
persistentcode.c py: Allow lexer to raise exceptions during construction. 2017-03-14 11:52:05 +11:00
persistentcode.h
py.mk py/py.mk: Force nlr files to be compiled with -Os. 2017-03-06 17:13:43 +11:00
qstr.c
qstr.h
qstrdefs.h
reader.c py: Allow lexer to raise exceptions during construction. 2017-03-14 11:52:05 +11:00
reader.h py: Allow lexer to raise exceptions during construction. 2017-03-14 11:52:05 +11:00
repl.c
repl.h
ringbuf.h
runtime.c py: Use mp_obj_get_array where sequence may be a tuple or a list. 2017-03-07 16:48:16 +11:00
runtime.h py: Add iter_buf to getiter type method. 2017-02-16 18:38:06 +11:00
runtime0.h py: Optimise storage of iterator so it takes only 4 slots on Py stack. 2017-02-16 18:38:06 +11:00
runtime_utils.c
scope.c
scope.h
sequence.c
showbc.c py: Allow bytecode/native to put iter_buf on stack for simple for loops. 2017-02-16 18:38:06 +11:00
smallint.c
smallint.h
stackctrl.c
stackctrl.h
stream.c
stream.h
unicode.c
unicode.h
vm.c py: Optimise storage of iterator so it takes only 4 slots on Py stack. 2017-02-16 18:38:06 +11:00
vmentrytable.h py: Allow bytecode/native to put iter_buf on stack for simple for loops. 2017-02-16 18:38:06 +11:00
vstr.c
warning.c