]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/convertrules.py
Issue 4422/4: convert-ly rule for removing parser/location
[lilypond.git] / python / convertrules.py
index 68c7288de865548afab85684746bd5d23f7b3b90..7029c10619f170ea3b64438b6fc7d64f279bfe6a 100644 (file)
@@ -3746,6 +3746,22 @@ def conv(str):
                   + after_id, r'\1-\2', str)
     return str
 
+@rule ((2, 19, 22), "(define-xxx-function (parser location ...) -> (define-xxx-function (...)")
+def conv(str):
+    def subst(m):
+        def subsub(m):
+            str = (m.group (1)
+                   + re.sub ('(?<=\s|["\\()])' + m.group (2) + r'(?=\s|["\\()])',
+                             r'(*location*)',
+                             re.sub (r'(?<=\s|["\\()])parser(?=\s|["\\()])',
+                                     r'(*parser*)', m.group (3))))
+            return str
+        return re.sub (r'(\([-a-z]+\s*\(+)parser\s+([-a-z]+)\s*((?:.|\n)*)$',
+                       subsub, m.group (0))
+    str = re.sub (r'\(define-(?:music|event|scheme|void)-function(?=\s|["(])'
+                  + paren_matcher (20) + r'\)', subst, str)
+    return str
+
 # Guidelines to write rules (please keep this at the end of this file)
 #
 # - keep at most one rule per version; if several conversions should be done,