[libre-riscv-dev] GardenSnake.py

Luke Kenneth Casson Leighton lkcl at lkcl.net
Sun Mar 29 11:40:31 BST 2020


i love python-ply.  i love that it does embedded BNF in
comment-strings, and a lot more.

GardenSnake.py was an example of a python code-parser written *in*
python to parse a very small subset *of* python, using python-ply.
the problem is: ply is designed as a LALR parser (and yacc lexer),
where python is a *whitespace* language that completely fails to fit
standard LALR.

it therefore needed a special parser, which worked for a short
duration of time until some internal changes in ply caused it to
break.  i spent this morning getting it working, and the example
succeeds!  w00t!

however that's not why i'm writing (although it's cool) - it's because
these files:
    https://libre-riscv.org/openpower/isa/stringldst/

all need a *whitespace* (indentation) parser in order to be able to read them.

ah.

the actual "language" is even more basic than python, however if we're
to accelerate things - and stand a chance of getting them right
without laborious checking - we need to be able to parse these
pseudo-code fragments and get them into python (and later nmigen).

so i am currently attempting to add "else" support to GardenSnake.py,
then "while", and after that it should be pretty straightforward to
convert to the power pseudo-code.

l.



More information about the libre-riscv-dev mailing list