summaryrefslogtreecommitdiffstatshomepage
path: root/py/parse.c
Commit message (Collapse)AuthorAge
...
* py: Add blank and ident flags to grammar rules to simplify parser.Damien George2014-12-20
| | | | This saves around 100 bytes code space on stmhal, more on unix.
* py: Save a few code bytes in parser; make vars local where possible.Damien George2014-12-20
|
* py: Optimise lexer by exposing lexer type.Damien George2014-12-05
| | | | | | | | | mp_lexer_t type is exposed, mp_token_t type is removed, and simple lexer functions (like checking current token kind) are now inlined. This saves 784 bytes ROM on 32-bit unix, 348 bytes on stmhal, and 460 bytes on bare-arm. It also saves a tiny bit of RAM since mp_lexer_t is a bit smaller. Also will run a bit more efficiently.
* py: Properly free string parse-node; add assertion to gc_free.Damien George2014-10-23
|
* py: Free non-interned strings in the parser when not needed.Damien George2014-09-23
| | | | | | | | | | | mp_parse_node_free now frees the memory associated with non-interned strings. And the parser calls mp_parse_node_free when discarding a non-used node (such as a doc string). Also, the compiler now frees the parse tree explicitly just before it exits (as opposed to relying on the caller to do this). Addresses issue #708 as best we can.
* py: Allow viper to have type annotations.Damien George2014-08-15
| | | | | | | | | Viper functions can now be annotated with the type of their arguments and return value. Eg: @micropython.viper def f(x:int) -> int: return x + 1
* parser: Convert (u)int to mp_(u)int_t.Damien George2014-07-03
|
* Rename machine_(u)int_t to mp_(u)int_t.Damien George2014-07-03
| | | | See discussion in issue #50.
* py: Include mpconfig.h before all other includes.Paul Sokolovsky2014-06-21
| | | | | | It defines types used by all other headers. Fixes #691.
* py: Fix check of small-int overflow when parsing ints.Damien George2014-05-28
| | | | Also unifies use of SMALL_INT_FITS macro across parser and runtime.
* Change const byte* to const char* where sensible.Damien George2014-05-25
| | | | | This removes need for some casts (at least, more than it adds need for new casts!).
* py: Don't automatically intern strings in parser.Damien George2014-05-25
| | | | | | | | This completes non-automatic interning of strings in the parser, so that doc strings don't take up RAM. It complicates the parser and compiler, and bloats stmhal by about 300 bytes. It's complicated because now there are 2 kinds of parse-nodes that can be strings: interned leaves and non-interned structs.
* Merge branch 'keep-strings-uninterned' of github.com:pfalcon/micropython ↵Damien George2014-05-25
|\ | | | | | | | | | | | | into pfalcon-keep-strings-uninterned Conflicts: py/parse.c
| * Draft approach towards resolving ↵Paul Sokolovsky2014-05-08
| | | | | | | | https://github.com/micropython/micropython/issues/560#issuecomment-42213955
* | Tidy up some configuration options.Damien George2014-05-21
| | | | | | | | | | | | | | | | | | | | MP_ALLOC_* -> MICROPY_ALLOC_* MICROPY_PATH_MAX -> MICROPY_ALLOC_PATH_MAX MICROPY_ENABLE_REPL_HELPERS -> MICROPY_HELPER_REPL MICROPY_ENABLE_LEXER_UNIX -> MICROPY_HELPER_LEXER_UNIX MICROPY_EXTRA_* -> MICROPY_PORT_* See issue #35.
* | py: Improve handling of memory error in parser.Damien George2014-05-10
|/ | | | | | | | | | | Parser shouldn't raise exceptions, so needs to check when memory allocation fails. This patch does that for the initial set up of the parser state. Also, we now put the parser object on the stack. It's small enough to go there instead of on the heap. This partially addresses issue #558.
* py, parser: Add commented-out code to discard doc strings.Damien George2014-05-06
| | | | | | Doesn't help with RAM reduction because doc strings are interned as soon as they are encountered, which is too soon to do any optimisations on them.
* py: Turn down amount of RAM parser and compiler use.Damien George2014-05-05
| | | | | | | | | | | | | | | | | | | | | | | | There are 2 locations in parser, and 1 in compiler, where memory allocation is not precise. In the parser it's the rule stack and result stack, in the compiler it's the array for the identifiers in the current scope. All other mallocs are exact (ie they don't allocate more than is needed). This patch adds tuning options (MP_ALLOC_*) to mpconfig.h for these 3 inexact allocations. The inexact allocations in the parser should actually be close to logarithmic: you need an exponentially larger script (absent pathological cases) to use up more room on the rule and result stacks. As such, the default allocation policy for these is now to start with a modest sized stack, but grow only in small increments. For the identifier arrays in the compiler, these now start out quite small (4 entries, since most functions don't have that many ids), and grow incrementally by 6 (since if you have more ids than 4, you probably have quite a few more, but it wouldn't be exponentially more). Partially addresses issue #560.
* Add license header to (almost) all files.Damien George2014-05-03
| | | | | | | Blanket wide to all .c and .h files. Some files originating from ST are difficult to deal with (license wise) so it was left out of those. Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
* py: Check explicitly for memory allocation failure in parser.Damien George2014-04-10
| | | | | | Previously, a failed malloc/realloc would throw an exception, which was not caught. I think it's better to keep the parser free from NLR (exception throwing), hence this patch.
* py: Clean up includes.xbe2014-03-17
| | | | Remove unnecessary includes. Add includes that improve portability.
* py: Implement bit-shift and not operations for mpz.Damien George2014-03-01
| | | | | | Implement not, shl and shr in mpz library. Add function to create mpzs on the stack, used for memory efficiency when rhs is a small int. Factor out code to parse base-prefix of number into a dedicated function.
* parse: Refactor parse node encoding to support full range of small ints.Paul Sokolovsky2014-02-22
| | | | | Based on suggestion by @dpgeorge at https://github.com/micropython/micropython/pull/313
* parse: Note that fact that parser's small ints are different than VM small int.Paul Sokolovsky2014-02-21
| | | | | | Specifically, VM's small ints are 31 bit, while parser's only 28. There's already MP_OBJ_FITS_SMALL_INT(), so, for clarity, rename MP_FIT_SMALL_INT() to MP_PARSE_FITS_SMALL_INT().
* Implement proper exception type hierarchy.Damien George2014-02-15
| | | | | | | | | | | | | | Each built-in exception is now a type, with base type BaseException. C exceptions are created by passing a pointer to the exception type to make an instance of. When raising an exception from the VM, an instance is created automatically if an exception type is raised (as opposed to an exception instance). Exception matching (RT_BINARY_OP_EXCEPTION_MATCH) is now proper. Handling of parse error changed to match new exceptions. mp_const_type renamed to mp_type_type for consistency.
* Replace global "static" -> "STATIC", to allow "analysis builds". Part 2.Paul Sokolovsky2014-02-12
|
* py: Fix bug with LOAD_METHOD; fix int->machine_int_t for small int.Damien George2014-01-29
| | | | | | | | LOAD_METHOD bug was: emitbc did not correctly calculate the amount of stack usage for a LOAD_METHOD operation. small int bug was: int was being used to pass small ints, when it should have been machine_int_t.
* Implement mp_parse_node_free; print properly repr(string).Damien George2014-01-25
|
* Add parse_node_free_struct() and use it to free parse tree after compilation.Paul Sokolovsky2014-01-25
| | | | TODO: Check lexer/parse/compile error path for leaks too.
* py: Change macro var args in parser to be C99 compliant.Damien George2014-01-23
|
* Revamp qstrs: they now include length and hash.Damien George2014-01-21
| | | | | Can now have null bytes in strings. Can define ROM qstrs per port using qstrdefsport.h
* py: Add module/function/class name to exceptions.Damien George2014-01-19
| | | | | | | Exceptions know source file, line and block name. Also tidy up some debug printing functions and provide a global flag to enable/disable them.
* Add source file name and line number to error messages.Damien George2014-01-18
| | | | | Byte code has a map from byte-code offset to source-code line number, used to give better error messages.
* Implement eval.Damien George2014-01-15
|
* Convert parse errors to exceptions.Damien George2014-01-15
| | | | | Parser no longer prints an error, but instead returns an exception ID and message.
* Parse long Python ints properly.Paul Sokolovsky2014-01-12
| | | | | | Long int is something which doesn't fit into SMALL_INT partion of machine_int_t. But it's also something which doesn't fit into machine_int_t in the first place.
* py: Improve memory management for parser; add lexer error for bad line cont.Damien George2014-01-12
|
* Put unicode functions in unicode.c, and tidy their names.Damien George2013-12-30
|
* Change memory allocation API to require size for free and realloc.Damien2013-12-29
|
* Parse upper-case hex numbers correctly.Damien2013-12-29
|
* Change object representation from 1 big union to individual structs.Damien2013-12-21
| | | | | | | | | | A big change. Micro Python objects are allocated as individual structs with the first element being a pointer to the type information (which is itself an object). This scheme follows CPython. Much more flexible, not necessarily slower, uses same heap memory, and can allocate objects statically. Also change name prefix, from py_ to mp_ (mp for Micro Python).
* Add basic complex number support.Damien2013-11-02
|
* Make grammar rules const so the go in .text section.Damien2013-10-19
|
* Implement REPL.Damien2013-10-18
|
* Tidy up SMALL_INT optimisations and CPython compatibility.Damien2013-10-12
|
* Separate out mpy core and unix version.Damien2013-10-12
|
* Improve indent/dedent error checking and reporting.Damien2013-10-09
|
* Optimise typedargslist_name to not create a node if just an id.Damien2013-10-06
|
* Make range of small int 24 bits.Damien2013-10-06
|
* Add support for inline thumb assembly.Damien2013-10-05
|