[Oil-dev] Example commit: Properly Implement break/continue/return
Andy Chu
andychup at gmail.com
Thu Mar 16 23:33:46 PDT 2017
Last time I sent out a description of implementing brace expansion:
http://lists.oilshell.org/pipermail/oil-dev-oilshell.org/2017-March/000035.html
Here is another example. Unfortunately these examples have been longer
than I would like, but I expect them to get shorter as the architecture
settles, which I think it's doing rapidly.
-----
First, test stats:
Last time: 517 test cases, with OSH passing on 295 and failing on 168 (not
run on the rest).
Now:
http://www.oilshell.org/git-branch/master/1c0437db/andy-home/spec/RESULTS.html
528 test cases, with OSH passing on 305 and failing on 165. Progress!!!
-----
I put a detailed description in the commit, which has much of the meat:
https://github.com/oilshell/oil/commit/4da19bf6e83a6fb59c2195f7e442b2f26481d9b1
This commit is unusual, but instructive, because it has a front end
change. I decided to parse break/continue/return STATICALLY, like a "real"
programming language. I don't think this will break many real programs,
but that can be tested, and it's not too hard to go back to dynamic parsing
if so.
So following the "Thinner Waist of the interpreter" (
http://www.oilshell.org/blog/2017/01/26.html) there are TINY representation
changes in id_kind.py and osh.asdl (3 new IDs and a new node).
And then this new representation is used by the lexer, word parser, command
parser, and command executor -- in that order. These are all in their own
file so I think the architecture is very clean, although there is still
some superficial code messiness.
-----
Remember I said last time I added this file called gold-test.sh. Now you
can run ./gold-test.sh count, and it will run 4 of our own functions with
OSH and bash, and they pass now that we've implemented "return":
https://github.com/oilshell/oil/commit/1c0437dbf37b11a064a9159ea691066ec6131395
'./gold-test.sh version-text' still has the glob issue I mentioned last
time, I will be working on that soon. That is also a fairly big
architectural change... but I hope it will be one of the last big ones
before we can release Oil 0.1 (I'll talk about this later.)
Let me know if there any questions! As mentioned, the commits should get
smaller if this too much to swallow. Overall I think the spec tests have
turned out to be very helpful.
Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.oilshell.org/pipermail/oil-dev-oilshell.org/attachments/20170316/e2ce119b/attachment.htm>
More information about the Oil-dev
mailing list