<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/py/parse.c, branch 4.0.0-beta.7</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=4.0.0-beta.7</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=4.0.0-beta.7'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2018-08-09T20:29:30+00:00</updated>
<entry>
<title>Two fixes and translate more strings.</title>
<updated>2018-08-09T20:29:30+00:00</updated>
<author>
<name>Scott Shawcroft</name>
<email>scott@tannewt.org</email>
</author>
<published>2018-08-09T01:24:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=96ebf5bc3fb455162286b9bc31e763f3c4f1c457'/>
<id>urn:sha1:96ebf5bc3fb455162286b9bc31e763f3c4f1c457</id>
<content type='text'>
* Fix finding translations with escaped characters.
* Add back \r to translations since its needed by screen.
</content>
</entry>
<entry>
<title>continued WIP: almost compiling</title>
<updated>2018-07-12T18:13:51+00:00</updated>
<author>
<name>Dan Halbert</name>
<email>halbert@halwitz.org</email>
</author>
<published>2018-07-12T18:13:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=0d27f4d9a66dcb47b545e715d1833094b0c7b484'/>
<id>urn:sha1:0d27f4d9a66dcb47b545e715d1833094b0c7b484</id>
<content type='text'>
</content>
</entry>
<entry>
<title>WIP: after merge; before testing</title>
<updated>2018-07-11T20:45:30+00:00</updated>
<author>
<name>Dan Halbert</name>
<email>halbert@halwitz.org</email>
</author>
<published>2018-07-11T20:45:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=7c219600a246d8956d0b23ea3f5d125a820e6b6a'/>
<id>urn:sha1:7c219600a246d8956d0b23ea3f5d125a820e6b6a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Make parsing more memory flexible.</title>
<updated>2018-01-25T02:22:20+00:00</updated>
<author>
<name>Scott Shawcroft</name>
<email>scott.shawcroft@gmail.com</email>
</author>
<published>2018-01-17T22:27:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=dff744558b32de05bbcf2e7a4804cb3c89e6658e'/>
<id>urn:sha1:dff744558b32de05bbcf2e7a4804cb3c89e6658e</id>
<content type='text'>
The parser attempts to allocate two large (~512 byte) chunks up
front. If it couldn't, then it would error out. This change will
cause it to try allocating half the previous attempt until its down
to two copies. This is ok upfront because later code checks bounds
and tries to extend the allocation if needed.
</content>
</entry>
<entry>
<title>py/parse: Fix macro evaluation by avoiding empty __VA_ARGS__.</title>
<updated>2017-12-29T02:44:26+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-12-28T13:53:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=c7cb1dfcb9f89eb0a2d2a90a5e496e919c8a0b94'/>
<id>urn:sha1:c7cb1dfcb9f89eb0a2d2a90a5e496e919c8a0b94</id>
<content type='text'>
Empty __VA_ARGS__ are not allowed in the C preprocessor so adjust the rule
arg offset calculation to not use them.  Also, some compilers (eg MSVC)
require an extra layer of macro expansion.
</content>
</entry>
<entry>
<title>py/parse: Update debugging code to compile on 64-bit arch.</title>
<updated>2017-12-28T13:13:36+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-12-26T02:39:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=d3fbfa491f46ec7e3f69d12e037cb3da7b3ae984'/>
<id>urn:sha1:d3fbfa491f46ec7e3f69d12e037cb3da7b3ae984</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py/parse: Compress rule pointer table to table of offsets.</title>
<updated>2017-12-28T13:13:36+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-12-26T02:39:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=0016a45368d8e7272d1c1f891994d6de4effcb40'/>
<id>urn:sha1:0016a45368d8e7272d1c1f891994d6de4effcb40</id>
<content type='text'>
This is the sixth and final patch in a series of patches to the parser that
aims to reduce code size by compressing the data corresponding to the rules
of the grammar.

Prior to this set of patches the rules were stored as rule_t structs with
rule_id, act and arg members.  And then there was a big table of pointers
which allowed to lookup the address of a rule_t struct given the id of that
rule.

The changes that have been made are:
- Breaking up of the rule_t struct into individual components, with each
  component in a separate array.
- Removal of the rule_id part of the struct because it's not needed.
- Put all the rule arg data in a big array.
- Change the table of pointers to rules to a table of offsets within the
  array of rule arg data.

The last point is what is done in this patch here and brings about the
biggest decreases in code size, because an array of pointers is now an
array of bytes.

Code size changes for the six patches combined is:

   bare-arm:  -644
minimal x86: -1856
   unix x64: -5408
unix nanbox: -2080
      stm32:  -720
    esp8266:  -812
     cc3200:  -712

For the change in parser performance: it was measured on pyboard that these
six patches combined gave an increase in script parse time of about 0.4%.
This is due to the slightly more complicated way of looking up the data for
a rule (since the 9th bit of the offset into the rule arg data table is
calculated with an if statement).  This is an acceptable increase in parse
time considering that parsing is only done once per script (if compiled on
the target).
</content>
</entry>
<entry>
<title>py/parse: Remove rule_t struct because it's no longer needed.</title>
<updated>2017-12-28T12:15:36+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-12-23T13:01:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=c2c92ceefc86d7e5cdc358c4ea3226844391ae44'/>
<id>urn:sha1:c2c92ceefc86d7e5cdc358c4ea3226844391ae44</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py/parse: Pass rule_id to push_result_token, instead of passing rule_t*.</title>
<updated>2017-12-28T12:12:10+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-12-23T12:53:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=66d8885d85bb591810b25e763c0921372ab74ef4'/>
<id>urn:sha1:66d8885d85bb591810b25e763c0921372ab74ef4</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py/parse: Pass rule_id to push_result_rule, instead of passing rule_t*.</title>
<updated>2017-12-28T12:11:43+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-12-23T12:49:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=815a8cd1ae3a0a451b0b0b687277093f3392cdab'/>
<id>urn:sha1:815a8cd1ae3a0a451b0b0b687277093f3392cdab</id>
<content type='text'>
Reduces code size by eliminating quite a few pointer dereferences.
</content>
</entry>
</feed>
