Skip to content

Instantly share code, notes, and snippets.

@introom
Created June 21, 2013 11:41
Show Gist options
  • Save introom/5830674 to your computer and use it in GitHub Desktop.
Save introom/5830674 to your computer and use it in GitHub Desktop.
parsley reference problem
# 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