1
# Module for reading and parsing Scintilla.iface file
4
def sanitiseLine(line):
5
if line[-1:] == '\n': line = line[:-1]
6
if string.find(line, "##") != -1:
7
line = line[:string.find(line, "##")]
8
line = string.strip(line)
11
def decodeFunction(featureVal):
12
retType, rest = string.split(featureVal, " ", 1)
13
nameIdent, params = string.split(rest, "(")
14
name, value = string.split(nameIdent, "=")
15
params, rest = string.split(params, ")")
16
param1, param2 = string.split(params, ",")[0:2]
17
return retType, name, value, param1, param2
19
def decodeEvent(featureVal):
20
retType, rest = string.split(featureVal, " ", 1)
21
nameIdent, params = string.split(rest, "(")
22
name, value = string.split(nameIdent, "=")
23
return retType, name, value
26
param = string.strip(p)
31
type, nv = string.split(param, " ")
33
name, value = string.split(nv, "=")
36
return type, name, value
46
def ReadFromFile(self, name):
49
currentCommentFinished = 0
51
for line in file.readlines():
52
line = sanitiseLine(line)
56
if currentCommentFinished:
58
currentCommentFinished = 0
59
currentComment.append(line[2:])
61
currentCommentFinished = 1
62
featureType, featureVal = string.split(line, " ", 1)
63
if featureType in ["fun", "get", "set"]:
64
retType, name, value, param1, param2 = decodeFunction(featureVal)
65
p1 = decodeParam(param1)
66
p2 = decodeParam(param2)
67
self.features[name] = {
68
"FeatureType": featureType,
69
"ReturnType": retType,
71
"Param1Type": p1[0], "Param1Name": p1[1], "Param1Value": p1[2],
72
"Param2Type": p2[0], "Param2Name": p2[1], "Param2Value": p2[2],
73
"Category": currentCategory, "Comment": currentComment
75
if self.values.has_key(value):
76
raise "Duplicate value " + value + " " + name
77
self.values[value] = 1
78
self.order.append(name)
79
elif featureType == "evt":
80
retType, name, value = decodeEvent(featureVal)
81
self.features[name] = {
82
"FeatureType": featureType,
83
"ReturnType": retType,
85
"Category": currentCategory, "Comment": currentComment
87
if self.events.has_key(value):
88
raise "Duplicate event " + value + " " + name
89
self.events[value] = 1
90
self.order.append(name)
91
elif featureType == "cat":
92
currentCategory = featureVal
93
elif featureType == "val":
94
name, value = string.split(featureVal, "=", 1)
95
self.features[name] = {
96
"FeatureType": featureType,
97
"Category": currentCategory,
99
self.order.append(name)
100
elif featureType == "enu" or featureType == "lex":
101
name, value = string.split(featureVal, "=", 1)
102
self.features[name] = {
103
"FeatureType": featureType,
104
"Category": currentCategory,
106
self.order.append(name)