aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2002-07-29 07:12:35 +0000
committernyamatongwe <devnull@localhost>2002-07-29 07:12:35 +0000
commit3e20aa7ba9496654464241733059ec4173f06d13 (patch)
tree1ad638dd822145da58154edf6d2597c9cbac5eda /src
parent7eb1a92df1ca078dfbd33c385afa1a3fd01a61e1 (diff)
downloadscintilla-mirror-3e20aa7ba9496654464241733059ec4173f06d13.tar.gz
Can now generate into a new file as well as regenerate in place.
Creates a VS .NET project file from an input template.
Diffstat (limited to 'src')
-rw-r--r--src/LexGen.py54
1 files changed, 36 insertions, 18 deletions
diff --git a/src/LexGen.py b/src/LexGen.py
index 50b088613..1969d085d 100644
--- a/src/LexGen.py
+++ b/src/LexGen.py
@@ -2,13 +2,19 @@
# Released to the public domain.
# Regenerate the Scintilla and SciTE source files that list
-# all the lexers. Should be run whenever a new lexer is added or removed.
+# all the lexers and all the properties files.
+# Should be run whenever a new lexer is added or removed.
# Requires Python 2.1 or later
-# The files are copied to a temporary file apart from sections between
-# a ++Autogenerated comment and a --Autogenerated comment which is
-# generated by the CopyWithInsertion function. After the temporary
-# file is created, it is copied back to the original file name.
-# Does not regenerate the Visual C++ project files.
+# Most files are regenerated in place with templates stored in comments.
+# The VS .NET project file is generated into a different file as the
+# VS .NET environment will not retain comments when modifying the file.
+# The files are copied to a string apart from sections between a
+# ++Autogenerated comment and a --Autogenerated comment which is
+# generated by the CopyWithInsertion function. After the whole
+# string is instantiated, it is compared with the target file and
+# if different the file is rewritten.
+# Does not regenerate the Visual C++ 6 project files but does the VS .NET
+# project file.
import string
import sys
@@ -24,18 +30,22 @@ import glob
# Backslash is used as an escape within the definition line.
# The part between \( and \) is repeated for each item in the list.
# \* is replaced by each list item. \t, and \n are tab and newline.
-def CopyWithInsertion(input, commentPrefix, *lists):
+def CopyWithInsertion(input, commentPrefix, retainDefs, *lists):
copying = 1
listid = 0
output = []
for line in input.split("\n"):
- if copying:
+ isStartGenerated = line.startswith(commentPrefix + "++Autogenerated")
+ if copying and not isStartGenerated:
output.append(line)
- if line.startswith(commentPrefix + "++Autogenerated"):
+ if isStartGenerated:
+ if retainDefs:
+ output.append(line)
copying = 0
definition = ""
elif not copying and line.startswith(commentPrefix + "**"):
- output.append(line)
+ if retainDefs:
+ output.append(line)
definition = line[len(commentPrefix + "**"):]
listid = 0
if definition[0] in string.digits:
@@ -72,7 +82,8 @@ def CopyWithInsertion(input, commentPrefix, *lists):
output.append(out)
elif line.startswith(commentPrefix + "--Autogenerated"):
copying = 1
- output.append(line)
+ if retainDefs:
+ output.append(line)
return "\n".join(output)
def UpdateFile(filename, updated):
@@ -89,25 +100,29 @@ def UpdateFile(filename, updated):
out.close()
print "Changed", filename
-def RegenerateOverLists(filename, commentPrefix, crlf, *lists):
+def RegenerateOverLists(inpath, outpath, commentPrefix, crlf, *lists):
try:
- infile = open(filename, "rb")
+ infile = open(inpath, "rb")
except IOError:
- print "Can not open", filename
+ print "Can not open", inpath
return
original = infile.read()
infile.close()
contents = original.replace("\r\n", "\n")
- updated = CopyWithInsertion(contents, commentPrefix, *lists)
+ updated = CopyWithInsertion(contents, commentPrefix,
+ inpath == outpath, *lists)
if crlf:
updated = updated.replace("\n", "\r\n")
- UpdateFile(filename, updated)
+ UpdateFile(outpath, updated)
def Regenerate(filename, commentPrefix, *lists):
- RegenerateOverLists(filename, commentPrefix, 1, *lists)
+ RegenerateOverLists(filename, filename, commentPrefix, 1, *lists)
def RegenerateBinary(filename, commentPrefix, *lists):
- RegenerateOverLists(filename, commentPrefix, 0, *lists)
+ RegenerateOverLists(filename, filename, commentPrefix, 0, *lists)
+
+def Generate(inpath, outpath, commentPrefix, *lists):
+ RegenerateOverLists(inpath, outpath, commentPrefix, 1, *lists)
def FindModules(lexFile):
modules = []
@@ -117,6 +132,7 @@ def FindModules(lexFile):
l = l.replace("(", " ")
modules.append(l.split()[1])
return modules
+
root="../../"
lexFilePaths = glob.glob(root + "scintilla/src/Lex*.cxx")
lexFiles = [os.path.basename(f)[:-4] for f in lexFilePaths]
@@ -128,6 +144,7 @@ otherProps = ["abbrev.properties", "Embedded.properties", "SciTEGlobal.propertie
propFilePaths = glob.glob(root + "scite/src/*.properties")
propFiles = [os.path.basename(f) for f in propFilePaths if os.path.basename(f) not in otherProps]
print propFiles
+
Regenerate(root + "scintilla/src/KeyWords.cxx", "//", lexerModules)
Regenerate(root + "scintilla/win32/makefile", "#", lexFiles)
Regenerate(root + "scintilla/win32/scintilla.mak", "#", lexFiles)
@@ -136,3 +153,4 @@ RegenerateBinary(root + "scintilla/gtk/makefile", "#", lexFiles)
Regenerate(root + "scintilla/gtk/scintilla.mak", "#", lexFiles)
Regenerate(root + "scite/win32/makefile", "#", lexFiles, propFiles)
Regenerate(root + "scite/win32/scite.mak", "#", lexFiles, propFiles)
+Generate(root + "scite/boundscheck/vcproj.gen", root + "scite/boundscheck/SciTE.vcproj", "#", lexFiles)