diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2011-02-07 12:39:53 +0000 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2011-02-07 12:39:53 +0000 |
commit | 83c20525094b1085a06821be2011ab794cd51e46 (patch) | |
tree | 64531b1dd3428894dd75af46eb70fe9d3d3f4d58 /scintilla/include/Face.py | |
parent | 28e3c223e8e2463630d7fb298eb51b78c662d2d8 (diff) | |
download | notepad2-mod-83c20525094b1085a06821be2011ab794cd51e46.zip notepad2-mod-83c20525094b1085a06821be2011ab794cd51e46.tar.gz notepad2-mod-83c20525094b1085a06821be2011ab794cd51e46.tar.bz2 |
update Scintilla, also add the python scripts for updating SciLexer.h
git-svn-id: https://notepad2-mod.googlecode.com/svn/trunk@396 28bd50df-7adb-d945-0439-6e466c6a13cc
Diffstat (limited to 'scintilla/include/Face.py')
-rw-r--r-- | scintilla/include/Face.py | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/scintilla/include/Face.py b/scintilla/include/Face.py new file mode 100644 index 0000000..9a92bb0 --- /dev/null +++ b/scintilla/include/Face.py @@ -0,0 +1,110 @@ +# Module for reading and parsing Scintilla.iface file
+
+def sanitiseLine(line):
+ if line[-1:] == '\n': line = line[:-1]
+ if line.find("##") != -1:
+ line = line[:line.find("##")]
+ line = line.strip()
+ return line
+
+def decodeFunction(featureVal):
+ retType, rest = featureVal.split(" ", 1)
+ nameIdent, params = rest.split("(")
+ name, value = nameIdent.split("=")
+ params, rest = params.split(")")
+ param1, param2 = params.split(",")[0:2]
+ return retType, name, value, param1, param2
+
+def decodeEvent(featureVal):
+ retType, rest = featureVal.split(" ", 1)
+ nameIdent, params = rest.split("(")
+ name, value = nameIdent.split("=")
+ return retType, name, value
+
+def decodeParam(p):
+ param = p.strip()
+ type = ""
+ name = ""
+ value = ""
+ if " " in param:
+ type, nv = param.split(" ")
+ if "=" in nv:
+ name, value = nv.split("=")
+ else:
+ name = nv
+ return type, name, value
+
+class Face:
+
+ def __init__(self):
+ self.order = []
+ self.features = {}
+ self.values = {}
+ self.events = {}
+
+ def ReadFromFile(self, name):
+ currentCategory = ""
+ currentComment = []
+ currentCommentFinished = 0
+ file = open(name)
+ for line in file.readlines():
+ line = sanitiseLine(line)
+ if line:
+ if line[0] == "#":
+ if line[1] == " ":
+ if currentCommentFinished:
+ currentComment = []
+ currentCommentFinished = 0
+ currentComment.append(line[2:])
+ else:
+ currentCommentFinished = 1
+ featureType, featureVal = line.split(" ", 1)
+ if featureType in ["fun", "get", "set"]:
+ retType, name, value, param1, param2 = decodeFunction(featureVal)
+ p1 = decodeParam(param1)
+ p2 = decodeParam(param2)
+ self.features[name] = {
+ "FeatureType": featureType,
+ "ReturnType": retType,
+ "Value": value,
+ "Param1Type": p1[0], "Param1Name": p1[1], "Param1Value": p1[2],
+ "Param2Type": p2[0], "Param2Name": p2[1], "Param2Value": p2[2],
+ "Category": currentCategory, "Comment": currentComment
+ }
+ if value in self.values:
+ raise "Duplicate value " + value + " " + name
+ self.values[value] = 1
+ self.order.append(name)
+ elif featureType == "evt":
+ retType, name, value = decodeEvent(featureVal)
+ self.features[name] = {
+ "FeatureType": featureType,
+ "ReturnType": retType,
+ "Value": value,
+ "Category": currentCategory, "Comment": currentComment
+ }
+ if value in self.events:
+ raise "Duplicate event " + value + " " + name
+ self.events[value] = 1
+ self.order.append(name)
+ elif featureType == "cat":
+ currentCategory = featureVal
+ elif featureType == "val":
+ try:
+ name, value = featureVal.split("=", 1)
+ except ValueError:
+ print("Failure %s" % featureVal)
+ raise
+ self.features[name] = {
+ "FeatureType": featureType,
+ "Category": currentCategory,
+ "Value": value }
+ self.order.append(name)
+ elif featureType == "enu" or featureType == "lex":
+ name, value = featureVal.split("=", 1)
+ self.features[name] = {
+ "FeatureType": featureType,
+ "Category": currentCategory,
+ "Value": value }
+ self.order.append(name)
+
|