1 # Module for reading and parsing Scintilla.iface file
3 def sanitiseLine(line
):
4 if line
[-1:] == '\n': line
= line
[:-1]
5 if line
.find("##") != -1:
6 line
= line
[:line
.find("##")]
10 def decodeFunction(featureVal
):
11 retType
, rest
= featureVal
.split(" ", 1)
12 nameIdent
, params
= rest
.split("(")
13 name
, value
= nameIdent
.split("=")
14 params
, rest
= params
.split(")")
15 param1
, param2
= params
.split(",")
16 return retType
, name
, value
, param1
, param2
18 def decodeEvent(featureVal
):
19 retType
, rest
= featureVal
.split(" ", 1)
20 nameIdent
, params
= rest
.split("(")
21 name
, value
= nameIdent
.split("=")
22 return retType
, name
, value
30 type, nv
= param
.split(" ")
32 name
, value
= nv
.split("=")
35 return type, name
, value
45 def ReadFromFile(self
, name
):
48 currentCommentFinished
= 0
50 for line
in file.readlines():
51 line
= sanitiseLine(line
)
55 if currentCommentFinished
:
57 currentCommentFinished
= 0
58 currentComment
.append(line
[2:])
60 currentCommentFinished
= 1
61 featureType
, featureVal
= line
.split(" ", 1)
62 if featureType
in ["fun", "get", "set"]:
64 retType
, name
, value
, param1
, param2
= decodeFunction(featureVal
)
66 print("Failed to decode %s" % line
)
68 p1
= decodeParam(param1
)
69 p2
= decodeParam(param2
)
70 self
.features
[name
] = {
71 "FeatureType": featureType
,
72 "ReturnType": retType
,
74 "Param1Type": p1
[0], "Param1Name": p1
[1], "Param1Value": p1
[2],
75 "Param2Type": p2
[0], "Param2Name": p2
[1], "Param2Value": p2
[2],
76 "Category": currentCategory
, "Comment": currentComment
78 if value
in self
.values
:
79 raise Exception("Duplicate value " + value
+ " " + name
)
80 self
.values
[value
] = 1
81 self
.order
.append(name
)
82 elif featureType
== "evt":
83 retType
, name
, value
= decodeEvent(featureVal
)
84 self
.features
[name
] = {
85 "FeatureType": featureType
,
86 "ReturnType": retType
,
88 "Category": currentCategory
, "Comment": currentComment
90 if value
in self
.events
:
91 raise Exception("Duplicate event " + value
+ " " + name
)
92 self
.events
[value
] = 1
93 self
.order
.append(name
)
94 elif featureType
== "cat":
95 currentCategory
= featureVal
96 elif featureType
== "val":
98 name
, value
= featureVal
.split("=", 1)
100 print("Failure %s" % featureVal
)
102 self
.features
[name
] = {
103 "FeatureType": featureType
,
104 "Category": currentCategory
,
106 self
.order
.append(name
)
107 elif featureType
== "enu" or featureType
== "lex":
108 name
, value
= featureVal
.split("=", 1)
109 self
.features
[name
] = {
110 "FeatureType": featureType
,
111 "Category": currentCategory
,
113 self
.order
.append(name
)