Vega strike Python Modules doc
0.5.1
Documentation of the " Modules " folder of Vega strike
Main Page
Namespaces
Data Structures
Files
File List
All
Data Structures
Namespaces
Files
Functions
Variables
token.py
Go to the documentation of this file.
1
#! /usr/bin/env python
2
3
"""Token constants (from "token.h")."""
4
5
# This file is automatically generated; please don't muck it up!
6
#
7
# To update the symbols in this file, 'cd' to the top directory of
8
# the python source tree after building the interpreter and run:
9
#
10
# python Lib/token.py
11
12
#--start constants--
13
ENDMARKER = 0
14
NAME = 1
15
NUMBER = 2
16
STRING = 3
17
NEWLINE = 4
18
INDENT = 5
19
DEDENT = 6
20
LPAR = 7
21
RPAR = 8
22
LSQB = 9
23
RSQB = 10
24
COLON = 11
25
COMMA = 12
26
SEMI = 13
27
PLUS = 14
28
MINUS = 15
29
STAR = 16
30
SLASH = 17
31
VBAR = 18
32
AMPER = 19
33
LESS = 20
34
GREATER = 21
35
EQUAL = 22
36
DOT = 23
37
PERCENT = 24
38
BACKQUOTE = 25
39
LBRACE = 26
40
RBRACE = 27
41
EQEQUAL = 28
42
NOTEQUAL = 29
43
LESSEQUAL = 30
44
GREATEREQUAL = 31
45
TILDE = 32
46
CIRCUMFLEX = 33
47
LEFTSHIFT = 34
48
RIGHTSHIFT = 35
49
DOUBLESTAR = 36
50
PLUSEQUAL = 37
51
MINEQUAL = 38
52
STAREQUAL = 39
53
SLASHEQUAL = 40
54
PERCENTEQUAL = 41
55
AMPEREQUAL = 42
56
VBAREQUAL = 43
57
CIRCUMFLEXEQUAL = 44
58
LEFTSHIFTEQUAL = 45
59
RIGHTSHIFTEQUAL = 46
60
DOUBLESTAREQUAL = 47
61
DOUBLESLASH = 48
62
DOUBLESLASHEQUAL = 49
63
OP = 50
64
ERRORTOKEN = 51
65
N_TOKENS = 52
66
NT_OFFSET = 256
67
#--end constants--
68
69
tok_name = {}
70
for
_name, _value
in
globals().items():
71
if
type(_value)
is
type(0):
72
tok_name[_value] = _name
73
74
75
def
ISTERMINAL
(x):
76
return
x < NT_OFFSET
77
78
def
ISNONTERMINAL
(x):
79
return
x >= NT_OFFSET
80
81
def
ISEOF
(x):
82
return
x == ENDMARKER
83
84
85
def
main
():
86
import
re
87
import
sys
88
args = sys.argv[1:]
89
inFileName = args
and
args[0]
or
"Include/token.h"
90
outFileName =
"Lib/token.py"
91
if
len(args) > 1:
92
outFileName = args[1]
93
try
:
94
fp =
open
(inFileName)
95
except
IOError, err:
96
sys.stdout.write(
"I/O error: %s\n"
%
str
(err))
97
sys.exit(1)
98
lines = fp.read().
split
(
"\n"
)
99
fp.close()
100
prog = re.compile(
101
"#define[ \t][ \t]*([A-Z][A-Z_]*)[ \t][ \t]*([0-9][0-9]*)"
,
102
re.IGNORECASE)
103
tokens = {}
104
for
line
in
lines:
105
match = prog.match(line)
106
if
match:
107
name, val = match.group(1, 2)
108
val = int(val)
109
tokens[val] = name
# reverse so we can sort them...
110
keys = tokens.keys()
111
keys.sort()
112
# load the output skeleton from the target:
113
try
:
114
fp =
open
(outFileName)
115
except
IOError, err:
116
sys.stderr.write(
"I/O error: %s\n"
%
str
(err))
117
sys.exit(2)
118
format = fp.read().
split
(
"\n"
)
119
fp.close()
120
try
:
121
start = format.index(
"#--start constants--"
) + 1
122
end = format.index(
"#--end constants--"
)
123
except
ValueError:
124
sys.stderr.write(
"target does not contain format markers"
)
125
sys.exit(3)
126
lines = []
127
for
val
in
keys:
128
lines.append(
"%s = %d"
% (tokens[val], val))
129
format[start:end] = lines
130
try
:
131
fp =
open
(outFileName,
'w'
)
132
except
IOError, err:
133
sys.stderr.write(
"I/O error: %s\n"
%
str
(err))
134
sys.exit(4)
135
fp.write(
"\n"
.
join
(format))
136
fp.close()
137
138
139
if
__name__ ==
"__main__"
:
140
main
()
builtin
token.py
Generated on Mon Feb 17 2014 12:38:43 for Vega strike Python Modules doc by
1.8.4