Created
June 22, 2013 06:01
-
-
Save introom/5836043 to your computer and use it in GitHub Desktop.
parsley obj.attr obj[index]
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
from parsley import makeGrammar | |
data = b'\x01\x013' | |
grammarSource = r""" | |
byte = anything:b1 anything:b2 -> ord(b1), ord(b2) | |
start = byte:b anything{b[0]} | |
""" | |
parser = makeGrammar(grammarSource, {}) | |
ret = parser(data).start() | |
print(ret) |
from parsley import makeGrammar
data = b'\x01\x013'
grammarSource = r"""
byte = anything:b1 anything:b2 -> ord(b1), ord(b2)
start = byte:b (->b[0]):b0 anything{b0}
"""
parser = makeGrammar(grammarSource, {})
ret = parser(data).start()
print(ret)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
b[0] fails