Back to index

python3.2  3.2.2
Functions | Variables
token Namespace Reference

Functions

def ISTERMINAL
def ISNONTERMINAL
def ISEOF
def _main

Variables

list __all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
int ENDMARKER = 0
int NAME = 1
int NUMBER = 2
int STRING = 3
int NEWLINE = 4
int INDENT = 5
int DEDENT = 6
int LPAR = 7
int RPAR = 8
int LSQB = 9
int RSQB = 10
int COLON = 11
int COMMA = 12
int SEMI = 13
int PLUS = 14
int MINUS = 15
int STAR = 16
int SLASH = 17
int VBAR = 18
int AMPER = 19
int LESS = 20
int GREATER = 21
int EQUAL = 22
int DOT = 23
int PERCENT = 24
int LBRACE = 26
int RBRACE = 27
int EQEQUAL = 28
int NOTEQUAL = 29
int LESSEQUAL = 30
int GREATEREQUAL = 31
int TILDE = 32
int CIRCUMFLEX = 33
int LEFTSHIFT = 34
int RIGHTSHIFT = 35
int DOUBLESTAR = 36
int PLUSEQUAL = 37
int MINEQUAL = 38
int STAREQUAL = 39
int SLASHEQUAL = 40
int PERCENTEQUAL = 41
int AMPEREQUAL = 42
int VBAREQUAL = 43
int CIRCUMFLEXEQUAL = 44
int LEFTSHIFTEQUAL = 45
int RIGHTSHIFTEQUAL = 46
int DOUBLESTAREQUAL = 47
int DOUBLESLASH = 48
int DOUBLESLASHEQUAL = 49
int AT = 50
int RARROW = 51
int ELLIPSIS = 52
int OP = 53
int ERRORTOKEN = 54
int N_TOKENS = 55
int NT_OFFSET = 256
dictionary tok_name

Detailed Description

Token constants (from "token.h").

Function Documentation

def token._main ( ) [private]

Definition at line 86 of file token.py.

00086 
00087 def _main():
00088     import re
00089     import sys
00090     args = sys.argv[1:]
00091     inFileName = args and args[0] or "Include/token.h"
00092     outFileName = "Lib/token.py"
00093     if len(args) > 1:
00094         outFileName = args[1]
00095     try:
00096         fp = open(inFileName)
00097     except IOError as err:
00098         sys.stdout.write("I/O error: %s\n" % str(err))
00099         sys.exit(1)
00100     lines = fp.read().split("\n")
00101     fp.close()
00102     prog = re.compile(
00103         "#define[ \t][ \t]*([A-Z0-9][A-Z0-9_]*)[ \t][ \t]*([0-9][0-9]*)",
00104         re.IGNORECASE)
00105     tokens = {}
00106     for line in lines:
00107         match = prog.match(line)
00108         if match:
00109             name, val = match.group(1, 2)
00110             val = int(val)
00111             tokens[val] = name          # reverse so we can sort them...
00112     keys = sorted(tokens.keys())
00113     # load the output skeleton from the target:
00114     try:
00115         fp = open(outFileName)
00116     except IOError as err:
00117         sys.stderr.write("I/O error: %s\n" % str(err))
00118         sys.exit(2)
00119     format = fp.read().split("\n")
00120     fp.close()
00121     try:
00122         start = format.index("#--start constants--") + 1
00123         end = format.index("#--end constants--")
00124     except ValueError:
00125         sys.stderr.write("target does not contain format markers")
00126         sys.exit(3)
00127     lines = []
00128     for val in keys:
00129         lines.append("%s = %d" % (tokens[val], val))
00130     format[start:end] = lines
00131     try:
00132         fp = open(outFileName, 'w')
00133     except IOError as err:
00134         sys.stderr.write("I/O error: %s\n" % str(err))
00135         sys.exit(4)
00136     fp.write("\n".join(format))
00137     fp.close()
00138 

Here is the call graph for this function:

def token.ISEOF (   x)

Definition at line 82 of file token.py.

00082 
00083 def ISEOF(x):
00084     return x == ENDMARKER
00085 

def token.ISNONTERMINAL (   x)

Definition at line 79 of file token.py.

00079 
00080 def ISNONTERMINAL(x):
00081     return x >= NT_OFFSET

def token.ISTERMINAL (   x)

Definition at line 76 of file token.py.

00076 
00077 def ISTERMINAL(x):
00078     return x < NT_OFFSET


Variable Documentation

Definition at line 3 of file token.py.

Definition at line 32 of file token.py.

Definition at line 54 of file token.py.

int token.AT = 50

Definition at line 62 of file token.py.

Definition at line 45 of file token.py.

Definition at line 56 of file token.py.

Definition at line 24 of file token.py.

Definition at line 25 of file token.py.

Definition at line 19 of file token.py.

int token.DOT = 23

Definition at line 36 of file token.py.

Definition at line 60 of file token.py.

Definition at line 61 of file token.py.

Definition at line 48 of file token.py.

Definition at line 59 of file token.py.

Definition at line 64 of file token.py.

Definition at line 13 of file token.py.

Definition at line 40 of file token.py.

Definition at line 35 of file token.py.

Definition at line 66 of file token.py.

Definition at line 34 of file token.py.

Definition at line 43 of file token.py.

Definition at line 18 of file token.py.

Definition at line 38 of file token.py.

Definition at line 46 of file token.py.

Definition at line 57 of file token.py.

Definition at line 33 of file token.py.

Definition at line 42 of file token.py.

Definition at line 20 of file token.py.

Definition at line 22 of file token.py.

Definition at line 50 of file token.py.

Definition at line 28 of file token.py.

Definition at line 67 of file token.py.

Definition at line 14 of file token.py.

Definition at line 17 of file token.py.

Definition at line 41 of file token.py.

Definition at line 68 of file token.py.

Definition at line 15 of file token.py.

int token.OP = 53

Definition at line 65 of file token.py.

Definition at line 37 of file token.py.

Definition at line 53 of file token.py.

Definition at line 27 of file token.py.

Definition at line 49 of file token.py.

Definition at line 63 of file token.py.

Definition at line 39 of file token.py.

Definition at line 47 of file token.py.

Definition at line 58 of file token.py.

Definition at line 21 of file token.py.

Definition at line 23 of file token.py.

Definition at line 26 of file token.py.

Definition at line 30 of file token.py.

Definition at line 52 of file token.py.

Definition at line 29 of file token.py.

Definition at line 51 of file token.py.

Definition at line 16 of file token.py.

Definition at line 44 of file token.py.

Initial value:
00001 {value: name
00002             for name, value in globals().items()
00003             if isinstance(value, int)}

Definition at line 71 of file token.py.

Definition at line 31 of file token.py.

Definition at line 55 of file token.py.