Created
December 20, 2018 04:57
-
-
Save saulfield/adee4e358bd413a2e3458695fc994dde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
optimize_grammar = r""" | |
inc_chain = ['INC':op anything:n]+:xs -> (op, sum([x[1] for x in xs])) | |
dec_chain = ['DEC':op anything:n]+:xs -> (op, sum([x[1] for x in xs])) | |
add_chain = ['ADD':op anything:n]+:xs -> (op, sum([x[1] for x in xs])) | |
sub_chain = ['SUB':op anything:n]+:xs -> (op, sum([x[1] for x in xs])) | |
slice = inc_chain | dec_chain | add_chain | sub_chain | [anything:op anything:arg] | |
bytecode = slice* | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment