Back to index

python3.2  3.2.2
Classes | Functions | Variables
asdl Namespace Reference

Classes

class  Token
class  Id
class  String
class  ASDLSyntaxError
class  ASDLScanner
class  ASDLParser
class  AST
class  Module
class  Type
class  Constructor
class  Field
class  Sum
class  Product
class  VisitorBase
class  Check

Functions

def output
def check
def parse

Variables

tuple builtin_types = ("identifier", "string", "int", "bool", "object")
list files = sys.argv[1:]
string testdir = "tests"
tuple mod = parse(file)

Detailed Description

An implementation of the Zephyr Abstract Syntax Definition Language.

See http://asdl.sourceforge.net/ and
http://www.cs.princeton.edu/research/techreps/TR-554-97

Only supports top level module decl, not view.  I'm guessing that view
is intended to support the browser and I'm not interested in the
browser.

Changes for Python: Add support for module versions

Function Documentation

def asdl.check (   mod)

Definition at line 387 of file asdl.py.

00387 
00388 def check(mod):
00389     v = Check()
00390     v.visit(mod)
00391 
00392     for t in v.types:
00393         if t not in mod.types and not t in builtin_types:
00394             v.errors += 1
00395             uses = ", ".join(v.types[t])
00396             output("Undefined type %s, used in %s" % (t, uses))
00397 
00398     return not v.errors

Here is the call graph for this function:

Here is the caller graph for this function:

def asdl.output (   string)

Definition at line 19 of file asdl.py.

00019 
00020 def output(string):
00021     sys.stdout.write(string + "\n")
00022 

Here is the caller graph for this function:

def asdl.parse (   file)

Definition at line 399 of file asdl.py.

00399 
00400 def parse(file):
00401     scanner = ASDLScanner()
00402     parser = ASDLParser()
00403 
00404     buf = open(file).read()
00405     tokens = scanner.tokenize(buf)
00406     try:
00407         return parser.parse(tokens)
00408     except ASDLSyntaxError:
00409         err = sys.exc_info()[1]
00410         output(str(err))
00411         lines = buf.split("\n")
00412         output(lines[err.lineno - 1]) # lines starts at 0, files at 1

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

tuple asdl.builtin_types = ("identifier", "string", "int", "bool", "object")

Definition at line 239 of file asdl.py.

tuple asdl.files = sys.argv[1:]

Definition at line 418 of file asdl.py.

tuple asdl.mod = parse(file)

Definition at line 425 of file asdl.py.

string asdl.testdir = "tests"

Definition at line 420 of file asdl.py.