<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/py/parse.c, branch v1.9.3</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=v1.9.3</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=v1.9.3'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2017-10-04T01:37:50+00:00</updated>
<entry>
<title>all: Remove inclusion of internal py header files.</title>
<updated>2017-10-04T01:37:50+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-10-04T01:37:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=a3dc1b1957d2c96d7c60c2c629c95077b03488a1'/>
<id>urn:sha1:a3dc1b1957d2c96d7c60c2c629c95077b03488a1</id>
<content type='text'>
Header files that are considered internal to the py core and should not
normally be included directly are:
    py/nlr.h - internal nlr configuration and declarations
    py/bc0.h - contains bytecode macro definitions
    py/runtime0.h - contains basic runtime enums

Instead, the top-level header files to include are one of:
    py/obj.h - includes runtime0.h and defines everything to use the
        mp_obj_t type
    py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
        and defines everything to use the general runtime support functions

Additional, specific headers (eg py/objlist.h) can be included if needed.
</content>
</entry>
<entry>
<title>all: Use the name MicroPython consistently in comments</title>
<updated>2017-07-31T08:35:40+00:00</updated>
<author>
<name>Alexander Steffen</name>
<email>devel.20.webmeister@spamgourmet.com</email>
</author>
<published>2017-06-30T07:22:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=55f33240f3d7051d4213629e92437a36f1fac50e'/>
<id>urn:sha1:55f33240f3d7051d4213629e92437a36f1fac50e</id>
<content type='text'>
There were several different spellings of MicroPython present in comments,
when there should be only one.
</content>
</entry>
<entry>
<title>py/parse: Simplify handling of errors by raising them directly.</title>
<updated>2017-02-24T03:56:37+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-02-24T03:56:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=f615d82d5b4a8877462ce7c4f511e24c94a7b740'/>
<id>urn:sha1:f615d82d5b4a8877462ce7c4f511e24c94a7b740</id>
<content type='text'>
The parser was originally written to work without raising any exceptions
and instead return an error value to the caller.  But it's now required
that a call to the parser be wrapped in an nlr handler, so we may as well
make use of that fact and simplify the parser so that it doesn't need to
keep track of any memory errors that it had.  The parser anyway explicitly
raises an exception at the end if there was an error.

This patch simplifies the parser by letting the underlying memory
allocation functions raise an exception if they fail to allocate any
memory.  And if there is an error parsing the "&lt;id&gt; = const(&lt;val&gt;)" pattern
then that also raises an exception right away instead of trying to recover
gracefully and then raise.
</content>
</entry>
<entry>
<title>py: Create str/bytes objects in the parser, not the compiler.</title>
<updated>2017-02-24T02:43:43+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-02-24T02:43:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=5255255fb9ea003db65935fe6cf2ac9d17410faa'/>
<id>urn:sha1:5255255fb9ea003db65935fe6cf2ac9d17410faa</id>
<content type='text'>
Previous to this patch any non-interned str/bytes objects would create a
special parse node that held a copy of the str/bytes data.  Then in the
compiler this data would be turned into a str/bytes object.  This actually
lead to 2 copies of the data, one in the parse node and one in the object.
The parse node's copy of the data would be freed at the end of the compile
stage but nevertheless it meant that the peak memory usage of the
parse/compile stage was higher than it needed to be (by an amount equal to
the number of bytes in all the non-interned str/bytes objects).

This patch changes the behaviour so that str/bytes objects are created
directly in the parser and the object stored in a const-object parse node
(which already exists for bignum, float and complex const objects).  This
reduces peak RAM usage of the parse/compile stage, simplifies the parser
and compiler, and reduces code size by about 170 bytes on Thumb2 archs,
and by about 300 bytes on Xtensa archs.
</content>
</entry>
<entry>
<title>py/parse: Allow parser/compiler consts to be bignums.</title>
<updated>2017-02-24T02:03:44+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-02-24T02:03:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=74f4d2c65945d727821503e768c71f4e6b37f471'/>
<id>urn:sha1:74f4d2c65945d727821503e768c71f4e6b37f471</id>
<content type='text'>
This patch allows uPy consts to be bignums, eg:

    X = const(1 &lt;&lt; 100)

The infrastructure for consts to be a bignum (rather than restricted to
small integers) has been in place for a while, ever since constant folding
was upgraded to allow bignums.  It just required a small change (in this
patch) to enable it.
</content>
</entry>
<entry>
<title>py/grammar: Group no-compile grammar rules together to shrink tables.</title>
<updated>2017-02-16T08:45:06+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-02-14T23:58:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=71019ae4f5ba8819af27152198afc0274085c8a9'/>
<id>urn:sha1:71019ae4f5ba8819af27152198afc0274085c8a9</id>
<content type='text'>
Grammar rules have 2 variants: ones that are attached to a specific
compile function which is called to compile that grammar node, and ones
that don't have a compile function and are instead just inspected to see
what form they take.

In the compiler there is a table of all grammar rules, with each entry
having a pointer to the associated compile function.  Those rules with no
compile function have a null pointer.  There are 120 such rules, so that's
120 words of essentially wasted code space.

By grouping together the compile vs no-compile rules we can put all the
no-compile rules at the end of the list of rules, and then we don't need
to store the null pointers.  We just have a truncated table and it's
guaranteed that when indexing this table we only index the first half,
the half with populated pointers.

This patch implements such a grouping by having a specific macro for the
compile vs no-compile grammar rules (DEF_RULE vs DEF_RULE_NC).  It saves
around 460 bytes of code on 32-bit archs.
</content>
</entry>
<entry>
<title>py/parse: Refactor code to remove assert(0)'s.</title>
<updated>2017-01-17T06:00:55+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-01-17T06:00:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=86e942309ad0c61c7f0cc9abca509bfbca404ed5'/>
<id>urn:sha1:86e942309ad0c61c7f0cc9abca509bfbca404ed5</id>
<content type='text'>
This helps to improve code coverage.  Note that most of the changes in
this patch are just de-denting the cases of the switch statements.
</content>
</entry>
<entry>
<title>py/parse: Add code to fold logical constants in or/and/not operations.</title>
<updated>2016-11-15T05:48:49+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-11-13T04:36:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=9b525134d1bf5b3f05b39fe90ddaa4bd33ea3e0d'/>
<id>urn:sha1:9b525134d1bf5b3f05b39fe90ddaa4bd33ea3e0d</id>
<content type='text'>
Adds about 200 bytes to the code size when constant folding is enabled.
</content>
</entry>
<entry>
<title>py/parse: Make mp_parse_node_new_leaf an inline function.</title>
<updated>2016-11-15T05:48:48+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-11-13T04:35:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=ed9c93f0f13fe2b6b4b0fbc1155b1e38ee1be242'/>
<id>urn:sha1:ed9c93f0f13fe2b6b4b0fbc1155b1e38ee1be242</id>
<content type='text'>
It is split into 2 functions, one to make small ints and the other to make
a non-small-int leaf node.  This reduces code size by 32 bytes on
bare-arm, 64 bytes on unix (x64-64) and 144 bytes on stmhal.
</content>
</entry>
<entry>
<title>py/parse: Move function to check for const parse node to parse.[ch].</title>
<updated>2016-11-15T05:48:48+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-11-13T04:32:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=b0cbfb0492028192a28f0514fba71ec954330108'/>
<id>urn:sha1:b0cbfb0492028192a28f0514fba71ec954330108</id>
<content type='text'>
</content>
</entry>
</feed>
