summaryrefslogtreecommitdiffstatshomepage
path: root/py/lexer.c
Commit message (Collapse)AuthorAge
* py: add async/await/async for/async with syntaxpohmelie2016-04-13
| | | | | | | | They are sugar for marking function as generator, "yield from" and pep492 python "semantically equivalents" respectively. @dpgeorge was the original author of this patch, but @pohmelie made changes to implement `async for` and `async with`.
* py: Add MICROPY_DYNAMIC_COMPILER option to config compiler at runtime.Damien George2016-02-25
| | | | | | | | | | | | | | This new compile-time option allows to make the bytecode compiler configurable at runtime by setting the fields in the mp_dynamic_compiler structure. By using this feature, the compiler can generate bytecode that targets any MicroPython runtime/VM, regardless of the host and target compile-time settings. Options so far that fall under this dynamic setting are: - maximum number of bits that a small int can hold; - whether caching of lookups is used in the bytecode; - whether to use unicode strings or not (lexer behaviour differs, and therefore generated string constants differ).
* py: Add MICROPY_ENABLE_COMPILER and MICROPY_PY_BUILTINS_EVAL_EXEC opts.Damien George2015-12-18
| | | | | | | | | | | | MICROPY_ENABLE_COMPILER can be used to enable/disable the entire compiler, which is useful when only loading of pre-compiled bytecode is supported. It is enabled by default. MICROPY_PY_BUILTINS_EVAL_EXEC controls support of eval and exec builtin functions. By default they are only included if MICROPY_ENABLE_COMPILER is enabled. Disabling both options saves about 40k of code size on 32-bit x86.
* py/lexer: Properly classify floats that look like hex numbers.Damien George2015-09-07
| | | | Eg 0e0 almost looks like a hex number but in fact is a float.
* py/lexer: Raise SyntaxError when unicode char point out of range.Damien George2015-09-07
|
* py/lexer: Raise NotImplError for unicode name escape, instead of assert.Damien George2015-09-07
|
* py/lexer: Raise SyntaxError when str hex escape sequence is malformed.Damien George2015-07-23
| | | | Addresses issue #1390.
* py: Cast argument for printf to int, to be compatible with more ports.Damien George2015-06-22
| | | | This allows stmhal to be compiled with MICROPY_DEBUG_PRINTERS.
* py: Support unicode (utf-8 encoded) identifiers in Python source.Damien George2015-06-09
| | | | Enabled simply by making the identifier lexing code 8-bit clean.
* extmod: Add ubinascii.unhexlifyDave Hylands2015-05-20
| | | | This also pulls out hex_digit from py/lexer.c and makes unichar_hex_digit
* py: Allow to compile with extra warnings (sign-compare, unused-param).Damien George2015-03-19
|
* py: Parse big-int/float/imag constants directly in parser.Damien George2015-02-08
| | | | | | | | | Previous to this patch, a big-int, float or imag constant was interned (made into a qstr) and then parsed at runtime to create an object each time it was needed. This is wasteful in RAM and not efficient. Now, these constants are parsed straight away in the parser and turned into objects. This allows constants with large numbers of digits (so addresses issue #1103) and takes us a step closer to #722.
* py: Convert CR to LF and CR LF to LF in lexer.Damien George2015-01-30
| | | | | Only noticeable difference is how newlines are encoded in triple-quoted strings. The behaviour now matches CPython3.
* py: Be more precise about unicode type and disabled unicode behaviour.Damien George2015-01-28
|
* py, unix: Allow to compile with -Wsign-compare.Damien George2015-01-16
| | | | See issue #699.
* py: Put all global state together in state structures.Damien George2015-01-07
| | | | | | This patch consolidates all global variables in py/ core into one place, in a global structure. Root pointers are all located together to make GC tracing easier and more efficient.
* py: Move to guarded includes, everywhere in py/ core.Damien George2015-01-01
| | | | Addresses issue #1022.
* py: Fix printing of size_t entity; fix qemu-arm for changes to lexer.Damien George2014-12-05
|
* 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: Add further checks for failed malloc in lexer init functions.Damien George2014-10-09
|
* py: Change lexer stream API to return bytes not chars.Damien George2014-07-30
| | | | Lexer is now 8-bit clean inside strings.
* lexer: Convert type (u)int to mp_(u)int_t.Damien George2014-07-03
|
* lexer, vstr: Add unicode support.Chris Angelico2014-06-27
|
* py: Include mpconfig.h before all other includes.Paul Sokolovsky2014-06-21
| | | | | | It defines types used by all other headers. Fixes #691.
* Prefix ARRAY_SIZE with micropython prefix MP_Emmanuel Blot2014-06-19
|
* unicode: String API is const byte*.Paul Sokolovsky2014-06-14
| | | | | We still have that char vs byte dichotomy, but majority of string operations now use byte.
* py: Instead of having "debug on" var, have "optimization level" var.Paul Sokolovsky2014-06-03
| | | | | This allows to have multiple "optimization" levels (CPython has two (-OO removes docstrings), we can have more).
* lexer: Add another comment for somewhat obscure way __debug__ is handled.Paul Sokolovsky2014-06-02
|
* 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: Add support for __debug__ constant.Damien George2014-05-12
| | | | | | | | | __debug__ now resolves to True or False. Its value needs to be set by mp_set_debug(). TODO: call mp_set_debug in unix/ port. TODO: optimise away "if False:" statements in compiler.
* py, lexer: Add allocation policy config; return NULL if can't allocate.Damien George2014-05-10
|
* 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: Fix lexer so it doesn't allow ! and ..Damien George2014-04-10
|
* py, lexer: Fix parsing of raw strings (allow escaping of quote).Damien George2014-04-10
|
* py: Clean up includes.xbe2014-03-17
| | | | Remove unnecessary includes. Add includes that improve portability.
* Add vstr_ins and vstr_cut_out; improve stmhal readline.Damien George2014-03-15
|
* 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
|
* Implement mp_parse_node_free; print properly repr(string).Damien George2014-01-25
|
* mp_lexer_free(): Free lex->indent_level array.Paul Sokolovsky2014-01-23
|
* Fix 1 warning and 1 bug.Damien George2014-01-22
|
* Implement octal and hex escapes in strings.Paul Sokolovsky2014-01-22
|
* 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
* 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.
* Convert parse errors to exceptions.Damien George2014-01-15
| | | | | Parser no longer prints an error, but instead returns an exception ID and message.
* Add "buffer management" and "shrink" API calls to vstr.Paul Sokolovsky2014-01-13
| | | | | | | | | | | | | vstr is initially intended to deal with arbitrary-length strings. By providing a bit lower-level API calls, it will be also useful to deal with arbitrary-length I/O buffers (the difference from strings is that buffers are filled from "outside", via I/O). Another issue, especially aggravated by I/O buffer use, is alloc size vs actual size length. If allocated 1Mb for buffer, but actually read 1 byte, we don't want to keep rest of 1Mb be locked by this I/O result, but rather return it to heap ASAP ("shrink" buffer before passing it to qstr_from_str_take()).
* py: Improve memory management for parser; add lexer error for bad line cont.Damien George2014-01-12
|
* Add ellipsis object.Damien George2014-01-04
|
* 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
|