Skip to content

Instantly share code, notes, and snippets.

@davesque
Last active March 23, 2018 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davesque/11e40763e44336bc75919474cee1cfd3 to your computer and use it in GitHub Desktop.
Save davesque/11e40763e44336bc75919474cee1cfd3 to your computer and use it in GitHub Desktop.
import parsimonious
parser = parsimonious.Grammar(r"""
type = tuple_type / basic_type
tuple_type = "(" type ("," type)* ")"
basic_type = base sub? arrlist?
base = alphas
sub = (digits "x" digits) / digits
arrlist = (const_arr / dynam_arr)+
const_arr = "[" digits "]"
dynam_arr = "[]"
alphas = ~"[a-z]+"
digits = ~"[0-9]+"
""")
uint = parser.parse('uint')
uint256 = parser.parse('uint256')
fixed128x19 = parser.parse('fixed128x19')
tup = parser.parse('(uint,bool,fixed128x19)')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment