def main(): if len(sys.argv) < 2: print('Usage: %s <input ASDL>' % sys.argv[0]) return 1 with open(sys.argv[1]) as asdl_file: ast = asdl_parser.ASDLParser().parse(asdl_file.read()) if asdl_ast.check(ast): emit_ast(sys.stdout, ast) else: return 1
self._advance() return value else: raise ASDLSyntaxError('Unmatched %s (found %s)' % ( kind, self.cur_token.kind), self.cur_token.lineno) def _at_keyword(self, keyword): return (self.cur_token.kind == TokenKind.TypeId and self.cur_token.value == keyword) if __name__ == '__main__': buf = ''' stm = Compound(stm, stm) | Assign(identifier, exp) -- comment -- another comment (, foo | attributes (int kwa, foo bar) --kowo ''' import sys with open(sys.argv[1]) as f: buf = f.read() p = ASDLParser() ast = p.parse(buf) from asdl_ast import check check(ast) print(ast) #for t in tokenize_asdl(buf): #print(t)
return value else: raise ASDLSyntaxError( 'Unmatched %s (found %s)' % (kind, self.cur_token.kind), self.cur_token.lineno) def _at_keyword(self, keyword): return (self.cur_token.kind == TokenKind.TypeId and self.cur_token.value == keyword) if __name__ == '__main__': buf = ''' stm = Compound(stm, stm) | Assign(identifier, exp) -- comment -- another comment (, foo | attributes (int kwa, foo bar) --kowo ''' import sys with open(sys.argv[1]) as f: buf = f.read() p = ASDLParser() ast = p.parse(buf) from asdl_ast import check check(ast) print(ast) #for t in tokenize_asdl(buf): #print(t)