Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
token Namespace Reference

Functions

def ISTERMINAL
 
def ISNONTERMINAL
 
def ISEOF
 
def main
 

Variables

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 BACKQUOTE = 25
 
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 OP = 50
 
int ERRORTOKEN = 51
 
int N_TOKENS = 52
 
int NT_OFFSET = 256
 
dictionary tok_name = {}
 

Function Documentation

def token.ISEOF (   x)

Definition at line 81 of file token.py.

81 
82 def ISEOF(x):
83  return x == ENDMARKER
84 
def token.ISNONTERMINAL (   x)

Definition at line 78 of file token.py.

78 
79 def ISNONTERMINAL(x):
80  return x >= NT_OFFSET
def token.ISTERMINAL (   x)

Definition at line 75 of file token.py.

75 
76 def ISTERMINAL(x):
77  return x < NT_OFFSET
def token.main ( )

Definition at line 85 of file token.py.

References dospath.join(), aifc.open(), dospath.split(), and locale.str().

85 
86 def main():
87  import re
88  import sys
89  args = sys.argv[1:]
90  inFileName = args and args[0] or "Include/token.h"
91  outFileName = "Lib/token.py"
92  if len(args) > 1:
93  outFileName = args[1]
94  try:
95  fp = open(inFileName)
96  except IOError, err:
97  sys.stdout.write("I/O error: %s\n" % str(err))
98  sys.exit(1)
99  lines = fp.read().split("\n")
100  fp.close()
101  prog = re.compile(
102  "#define[ \t][ \t]*([A-Z][A-Z_]*)[ \t][ \t]*([0-9][0-9]*)",
103  re.IGNORECASE)
104  tokens = {}
105  for line in lines:
106  match = prog.match(line)
107  if match:
108  name, val = match.group(1, 2)
109  val = int(val)
110  tokens[val] = name # reverse so we can sort them...
111  keys = tokens.keys()
112  keys.sort()
113  # load the output skeleton from the target:
114  try:
115  fp = open(outFileName)
116  except IOError, err:
117  sys.stderr.write("I/O error: %s\n" % str(err))
118  sys.exit(2)
119  format = fp.read().split("\n")
120  fp.close()
121  try:
122  start = format.index("#--start constants--") + 1
123  end = format.index("#--end constants--")
124  except ValueError:
125  sys.stderr.write("target does not contain format markers")
126  sys.exit(3)
127  lines = []
128  for val in keys:
129  lines.append("%s = %d" % (tokens[val], val))
130  format[start:end] = lines
131  try:
132  fp = open(outFileName, 'w')
133  except IOError, err:
134  sys.stderr.write("I/O error: %s\n" % str(err))
135  sys.exit(4)
136  fp.write("\n".join(format))
137  fp.close()
138 

Variable Documentation

int AMPER = 19

Definition at line 32 of file token.py.

int AMPEREQUAL = 42

Definition at line 55 of file token.py.

int BACKQUOTE = 25

Definition at line 38 of file token.py.

int CIRCUMFLEX = 33

Definition at line 46 of file token.py.

int CIRCUMFLEXEQUAL = 44

Definition at line 57 of file token.py.

int COLON = 11

Definition at line 24 of file token.py.

int COMMA = 12

Definition at line 25 of file token.py.

int DEDENT = 6

Definition at line 19 of file token.py.

int DOT = 23

Definition at line 36 of file token.py.

int DOUBLESLASH = 48

Definition at line 61 of file token.py.

int DOUBLESLASHEQUAL = 49

Definition at line 62 of file token.py.

int DOUBLESTAR = 36

Definition at line 49 of file token.py.

int DOUBLESTAREQUAL = 47

Definition at line 60 of file token.py.

int ENDMARKER = 0

Definition at line 13 of file token.py.

int EQEQUAL = 28

Definition at line 41 of file token.py.

int EQUAL = 22

Definition at line 35 of file token.py.

int ERRORTOKEN = 51

Definition at line 64 of file token.py.

int GREATER = 21

Definition at line 34 of file token.py.

int GREATEREQUAL = 31

Definition at line 44 of file token.py.

int INDENT = 5

Definition at line 18 of file token.py.

int LBRACE = 26

Definition at line 39 of file token.py.

int LEFTSHIFT = 34

Definition at line 47 of file token.py.

int LEFTSHIFTEQUAL = 45

Definition at line 58 of file token.py.

int LESS = 20

Definition at line 33 of file token.py.

int LESSEQUAL = 30

Definition at line 43 of file token.py.

int LPAR = 7

Definition at line 20 of file token.py.

int LSQB = 9

Definition at line 22 of file token.py.

int MINEQUAL = 38

Definition at line 51 of file token.py.

int MINUS = 15

Definition at line 28 of file token.py.

int N_TOKENS = 52

Definition at line 65 of file token.py.

int NAME = 1

Definition at line 14 of file token.py.

int NEWLINE = 4

Definition at line 17 of file token.py.

int NOTEQUAL = 29

Definition at line 42 of file token.py.

int NT_OFFSET = 256

Definition at line 66 of file token.py.

int NUMBER = 2

Definition at line 15 of file token.py.

int OP = 50

Definition at line 63 of file token.py.

int PERCENT = 24

Definition at line 37 of file token.py.

int PERCENTEQUAL = 41

Definition at line 54 of file token.py.

int PLUS = 14

Definition at line 27 of file token.py.

int PLUSEQUAL = 37

Definition at line 50 of file token.py.

int RBRACE = 27

Definition at line 40 of file token.py.

int RIGHTSHIFT = 35

Definition at line 48 of file token.py.

int RIGHTSHIFTEQUAL = 46

Definition at line 59 of file token.py.

int RPAR = 8

Definition at line 21 of file token.py.

int RSQB = 10

Definition at line 23 of file token.py.

int SEMI = 13

Definition at line 26 of file token.py.

int SLASH = 17

Definition at line 30 of file token.py.

int SLASHEQUAL = 40

Definition at line 53 of file token.py.

int STAR = 16

Definition at line 29 of file token.py.

int STAREQUAL = 39

Definition at line 52 of file token.py.

int STRING = 3

Definition at line 16 of file token.py.

int TILDE = 32

Definition at line 45 of file token.py.

dictionary tok_name = {}

Definition at line 69 of file token.py.

int VBAR = 18

Definition at line 31 of file token.py.

int VBAREQUAL = 43

Definition at line 56 of file token.py.