Created
June 21, 2013 11:41
-
-
Save introom/5830674 to your computer and use it in GitHub Desktop.
parsley reference problem
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
# this one works, I can repeat the expr in query {times} | |
byte = anything:b -> ord(b) | |
query = byte:times expr{times} | |
# however, if the byte CANNOT return ord(b), how can I refer to the value of 'ord(anything:b)' when I am in query? | |
# one workaround is to store it in a temporary place. | |
# for example | |
byte = anything:b -> temp.update(b) | |
query = byte expr{temp.b} | |
class Temp(): | |
def update(self, b): | |
self.b = ord(b) | |
bindings = {"temp", Temp()} | |
makeGrammar(grammarSource, bindings)("b'\x02\x32\x33').query() | |
# however, I cannot reference temp[b] inside query. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment