Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python3....
File: token.py
"""Token constants (from "token.h")."""
[0] Fix | Delete
[1] Fix | Delete
__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
[2] Fix | Delete
[3] Fix | Delete
# This file is automatically generated; please don't muck it up!
[4] Fix | Delete
#
[5] Fix | Delete
# To update the symbols in this file, 'cd' to the top directory of
[6] Fix | Delete
# the python source tree after building the interpreter and run:
[7] Fix | Delete
#
[8] Fix | Delete
# ./python Lib/token.py
[9] Fix | Delete
[10] Fix | Delete
#--start constants--
[11] Fix | Delete
ENDMARKER = 0
[12] Fix | Delete
NAME = 1
[13] Fix | Delete
NUMBER = 2
[14] Fix | Delete
STRING = 3
[15] Fix | Delete
NEWLINE = 4
[16] Fix | Delete
INDENT = 5
[17] Fix | Delete
DEDENT = 6
[18] Fix | Delete
LPAR = 7
[19] Fix | Delete
RPAR = 8
[20] Fix | Delete
LSQB = 9
[21] Fix | Delete
RSQB = 10
[22] Fix | Delete
COLON = 11
[23] Fix | Delete
COMMA = 12
[24] Fix | Delete
SEMI = 13
[25] Fix | Delete
PLUS = 14
[26] Fix | Delete
MINUS = 15
[27] Fix | Delete
STAR = 16
[28] Fix | Delete
SLASH = 17
[29] Fix | Delete
VBAR = 18
[30] Fix | Delete
AMPER = 19
[31] Fix | Delete
LESS = 20
[32] Fix | Delete
GREATER = 21
[33] Fix | Delete
EQUAL = 22
[34] Fix | Delete
DOT = 23
[35] Fix | Delete
PERCENT = 24
[36] Fix | Delete
LBRACE = 25
[37] Fix | Delete
RBRACE = 26
[38] Fix | Delete
EQEQUAL = 27
[39] Fix | Delete
NOTEQUAL = 28
[40] Fix | Delete
LESSEQUAL = 29
[41] Fix | Delete
GREATEREQUAL = 30
[42] Fix | Delete
TILDE = 31
[43] Fix | Delete
CIRCUMFLEX = 32
[44] Fix | Delete
LEFTSHIFT = 33
[45] Fix | Delete
RIGHTSHIFT = 34
[46] Fix | Delete
DOUBLESTAR = 35
[47] Fix | Delete
PLUSEQUAL = 36
[48] Fix | Delete
MINEQUAL = 37
[49] Fix | Delete
STAREQUAL = 38
[50] Fix | Delete
SLASHEQUAL = 39
[51] Fix | Delete
PERCENTEQUAL = 40
[52] Fix | Delete
AMPEREQUAL = 41
[53] Fix | Delete
VBAREQUAL = 42
[54] Fix | Delete
CIRCUMFLEXEQUAL = 43
[55] Fix | Delete
LEFTSHIFTEQUAL = 44
[56] Fix | Delete
RIGHTSHIFTEQUAL = 45
[57] Fix | Delete
DOUBLESTAREQUAL = 46
[58] Fix | Delete
DOUBLESLASH = 47
[59] Fix | Delete
DOUBLESLASHEQUAL = 48
[60] Fix | Delete
AT = 49
[61] Fix | Delete
ATEQUAL = 50
[62] Fix | Delete
RARROW = 51
[63] Fix | Delete
ELLIPSIS = 52
[64] Fix | Delete
OP = 53
[65] Fix | Delete
AWAIT = 54
[66] Fix | Delete
ASYNC = 55
[67] Fix | Delete
ERRORTOKEN = 56
[68] Fix | Delete
N_TOKENS = 57
[69] Fix | Delete
NT_OFFSET = 256
[70] Fix | Delete
#--end constants--
[71] Fix | Delete
[72] Fix | Delete
tok_name = {value: name
[73] Fix | Delete
for name, value in globals().items()
[74] Fix | Delete
if isinstance(value, int) and not name.startswith('_')}
[75] Fix | Delete
__all__.extend(tok_name.values())
[76] Fix | Delete
[77] Fix | Delete
def ISTERMINAL(x):
[78] Fix | Delete
return x < NT_OFFSET
[79] Fix | Delete
[80] Fix | Delete
def ISNONTERMINAL(x):
[81] Fix | Delete
return x >= NT_OFFSET
[82] Fix | Delete
[83] Fix | Delete
def ISEOF(x):
[84] Fix | Delete
return x == ENDMARKER
[85] Fix | Delete
[86] Fix | Delete
[87] Fix | Delete
def _main():
[88] Fix | Delete
import re
[89] Fix | Delete
import sys
[90] Fix | Delete
args = sys.argv[1:]
[91] Fix | Delete
inFileName = args and args[0] or "Include/token.h"
[92] Fix | Delete
outFileName = "Lib/token.py"
[93] Fix | Delete
if len(args) > 1:
[94] Fix | Delete
outFileName = args[1]
[95] Fix | Delete
try:
[96] Fix | Delete
fp = open(inFileName)
[97] Fix | Delete
except OSError as err:
[98] Fix | Delete
sys.stdout.write("I/O error: %s\n" % str(err))
[99] Fix | Delete
sys.exit(1)
[100] Fix | Delete
with fp:
[101] Fix | Delete
lines = fp.read().split("\n")
[102] Fix | Delete
prog = re.compile(
[103] Fix | Delete
"#define[ \t][ \t]*([A-Z0-9][A-Z0-9_]*)[ \t][ \t]*([0-9][0-9]*)",
[104] Fix | Delete
re.IGNORECASE)
[105] Fix | Delete
tokens = {}
[106] Fix | Delete
for line in lines:
[107] Fix | Delete
match = prog.match(line)
[108] Fix | Delete
if match:
[109] Fix | Delete
name, val = match.group(1, 2)
[110] Fix | Delete
val = int(val)
[111] Fix | Delete
tokens[val] = name # reverse so we can sort them...
[112] Fix | Delete
keys = sorted(tokens.keys())
[113] Fix | Delete
# load the output skeleton from the target:
[114] Fix | Delete
try:
[115] Fix | Delete
fp = open(outFileName)
[116] Fix | Delete
except OSError as err:
[117] Fix | Delete
sys.stderr.write("I/O error: %s\n" % str(err))
[118] Fix | Delete
sys.exit(2)
[119] Fix | Delete
with fp:
[120] Fix | Delete
format = fp.read().split("\n")
[121] Fix | Delete
try:
[122] Fix | Delete
start = format.index("#--start constants--") + 1
[123] Fix | Delete
end = format.index("#--end constants--")
[124] Fix | Delete
except ValueError:
[125] Fix | Delete
sys.stderr.write("target does not contain format markers")
[126] Fix | Delete
sys.exit(3)
[127] Fix | Delete
lines = []
[128] Fix | Delete
for val in keys:
[129] Fix | Delete
lines.append("%s = %d" % (tokens[val], val))
[130] Fix | Delete
format[start:end] = lines
[131] Fix | Delete
try:
[132] Fix | Delete
fp = open(outFileName, 'w')
[133] Fix | Delete
except OSError as err:
[134] Fix | Delete
sys.stderr.write("I/O error: %s\n" % str(err))
[135] Fix | Delete
sys.exit(4)
[136] Fix | Delete
with fp:
[137] Fix | Delete
fp.write("\n".join(format))
[138] Fix | Delete
[139] Fix | Delete
[140] Fix | Delete
if __name__ == "__main__":
[141] Fix | Delete
_main()
[142] Fix | Delete
[143] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function