<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/py/grammar.h, branch 2.x</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=2.x</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=2.x'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2017-07-31T08:35:40+00:00</updated>
<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/compile: Combine arith and bit-shift ops into 1 compile routine.</title>
<updated>2017-07-05T05:49:00+00:00</updated>
<author>
<name>Krzysztof Blazewicz</name>
<email>blazewicz.krzysztof@gmail.com</email>
</author>
<published>2017-04-27T19:32:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=a040fb89e7b8507aa775b0620de1770642b0f5ee'/>
<id>urn:sha1:a040fb89e7b8507aa775b0620de1770642b0f5ee</id>
<content type='text'>
This refactoring saves code space.
</content>
</entry>
<entry>
<title>py/compile: Refactor handling of special super() call.</title>
<updated>2017-04-22T11:46:32+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-04-18T12:52:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=5335942b599d85263d3c18eb99ff5ebd04a8bc98'/>
<id>urn:sha1:5335942b599d85263d3c18eb99ff5ebd04a8bc98</id>
<content type='text'>
This patch refactors the handling of the special super() call within the
compiler.  It removes the need for a global (to the compiler) state variable
which keeps track of whether the subject of an expression is super.  The
handling of super() is now done entirely within one function, which makes
the compiler a bit cleaner and allows to easily add more optimisations to
super calls.

Changes to the code size are:

   bare-arm: +12
    minimal:  +0
   unix x64: +48
unix nanbox: -16
     stmhal:  +4
     cc3200:  +0
    esp8266: -56
</content>
</entry>
<entry>
<title>py/grammar: Remove unused rule.</title>
<updated>2017-02-17T01:48:45+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-02-17T01:48:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=bdebfaa4bf422ef164fa78257b59415e5dffc6cb'/>
<id>urn:sha1:bdebfaa4bf422ef164fa78257b59415e5dffc6cb</id>
<content type='text'>
Since the recent changes to string/bytes literal concatenation, this rule
is no longer used.
</content>
</entry>
<entry>
<title>py: Do adjacent str/bytes literal concatenation in lexer, not compiler.</title>
<updated>2017-02-17T01:12:40+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-02-17T01:12:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=534b7c368dc2af7720f3aaed0c936ef46d773957'/>
<id>urn:sha1:534b7c368dc2af7720f3aaed0c936ef46d773957</id>
<content type='text'>
It's much more efficient in RAM and code size to do implicit literal string
concatenation in the lexer, as opposed to the compiler.

RAM usage is reduced because the concatenation can be done right away in the
tokeniser by just accumulating the string/bytes literals into the lexer's
vstr.  Prior to this patch adjacent strings/bytes would create a parse tree
(one node per string/bytes) and then in the compiler a whole new chunk of
memory was allocated to store the concatenated string, which used more than
double the memory compared to just accumulating in the lexer.

This patch also significantly reduces code size:

bare-arm: -204
minimal:  -204
unix x64: -328
stmhal:   -208
esp8266:  -284
cc3200:   -224
</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: Simplify "and" action within parser by making ident-rules explicit.</title>
<updated>2016-04-14T12:49:23+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-04-14T12:23:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=0c1de1cdeea98e55710d27f7926da717086ac0fc'/>
<id>urn:sha1:0c1de1cdeea98e55710d27f7926da717086ac0fc</id>
<content type='text'>
Most grammar rules can optimise to the identity if they only have a single
argument, saving a lot of RAM building the parse tree.  Previous to this
patch, whether a given grammar rule could be optimised was defined (mostly
implicitly) by a complicated set of logic rules.  With this patch the
definition is always specified explicitly by using "and_ident" in the rule
definition in the grammar.  This simplifies the logic of the parser,
making it a bit smaller and faster.  RAM usage in unaffected.
</content>
</entry>
<entry>
<title>py: add async/await/async for/async with syntax</title>
<updated>2016-04-13T14:26:38+00:00</updated>
<author>
<name>pohmelie</name>
<email>multisosnooley@gmail.com</email>
</author>
<published>2016-01-27T20:23:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=81ebba7e0236163b7594938201bf3a6b802ebfaa'/>
<id>urn:sha1:81ebba7e0236163b7594938201bf3a6b802ebfaa</id>
<content type='text'>
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`.
</content>
</entry>
<entry>
<title>py: Don't allocate an extra parse node for power exponent.</title>
<updated>2016-03-16T13:04:51+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-03-16T13:04:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=3acaa28b52587bace3a4e8382fbf06ed6f6e4aaf'/>
<id>urn:sha1:3acaa28b52587bace3a4e8382fbf06ed6f6e4aaf</id>
<content type='text'>
Previous to this patch, the "**b" in "a**b" had its own parse node with
just one item (the "b").  Now, the "b" is just the last element of the
power parse-node.  This saves (a tiny bit of) RAM when compiling.
</content>
</entry>
<entry>
<title>py/compile: Do proper checking of * and ** in function definition.</title>
<updated>2015-11-23T16:50:42+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2015-11-23T16:50:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=9a56912ad16065c8fc3670c8d493f922bc54e5b1'/>
<id>urn:sha1:9a56912ad16065c8fc3670c8d493f922bc54e5b1</id>
<content type='text'>
This patch checks that there is only one *, and that ** is last in the
arg list.
</content>
</entry>
</feed>
