message: Struct extension parser changes
diff: @@ -17,7 +17,10 @@ __version__ = '0.0.1'
  # Text format parser.
  GRAMMAR = """
  -start: func*
  +start: (struct | func)*
  +
  +struct: STRUCT IDENT "=" "{" mbr* "}"
  +mbr: IDENT ":" type ";"
  func: FUNC ["(" arg_list? ")"] [tyann] "{" instr* "}"
  arg_list: | arg ("," arg)*
  @@ -36,16 +39,19 @@ op: IDENT (FUNC | LABEL | IDENT)*
  lit: SIGNED_INT -> int
  | BOOL -> bool
  | DECIMAL -> float
  + | "nullptr" -> nullptr
  type: IDENT "<" type ">" -> paramtype
  | IDENT -> primtype
  BOOL: "true" | "false"
  +STRUCT: "struct"
  IDENT: ("_"|"%"|LETTER) ("_"|"%"|"."|LETTER|DIGIT)*
  FUNC: "@" IDENT
  LABEL: "." IDENT
  COMMENT: /#.*/
  +
  %import common.SIGNED_INT
  %import common.DECIMAL
  %import common.WS
  @@ -58,7 +64,12 @@ COMMENT: /#.*/
  class JSONTransformer(lark.Transformer):
  def start(self, items):
  - return {'functions': items}
  + structs = [i for i in items if 'mbrs' in i]
  + funcs = [i for i in items if 'mbrs' not in i]
  + return {
  + 'structs' : structs,
  + 'functions': funcs,
  + }
  def func(self, items):
  name, args, typ = items[:3]
  @@ -81,6 +92,22 @@ class JSONTransformer(lark.Transformer):
  'type': typ,
  }
  + def struct(self, items):
  + name = items[1]
  + mbrs = items[2:]
  + return {
  + 'name': name,
  + 'mbrs': mbrs,
  + }
  +
  + def mbr(self, items):
  + name = items.pop(0)
  + typ = items.pop(0)
  + return {
  + 'name' : name,
  + 'type' : typ,
  + }
  +
  def arg_list(self, items):
  return items
  @@ -154,6 +181,9 @@ class JSONTransformer(lark.Transformer):
  def float(self, items):
  return float(items[0])
  + def nullptr(self, items):
  + return 0
  +
  def parse_bril(txt):
  parser = lark.Lark(GRAMMAR, maybe_placeholders=True)
  