5 # FIXME: coding standards!
8 # Created 01 September 2003 by Heikki Junes.
9 # Generates lilypond-words.el for (X)Emacs and lilypond-words[.vim] for Vim.
19 # keywords not otherwise found
20 for line in ['include','maininput','version']:
24 F = open('lily/lily-lexer.cc', 'r')
25 for line in F.readlines():
26 m = re.search(r"(\s*{\")(.*)(\",\s*.*},\s*\n)",line)
28 kw = kw + [m.group(2)]
31 F = open('scm/markup.scm', 'r')
32 for line in F.readlines():
33 m = re.search(r"^(\s*\(cons\s*)([a-z-]*)(-markup)",line)
35 kw = kw + [m.group(2)]
37 # identifiers and keywords
38 for name in ['ly/chord-modifiers-init.ly',
39 'ly/dynamic-scripts-init.ly',
40 'ly/engraver-init.ly',
42 'ly/gregorian-init.ly',
43 'ly/music-functions-init.ly',
44 'ly/performer-init.ly',
45 'ly/property-init.ly',
46 'ly/scale-definitions-init.ly',
48 'ly/spanners-init.ly']:
50 for line in F.readlines():
51 m = re.search(r"^([a-zA-Z]+)(\s*=)",line)
53 kw = kw + [m.group(1)]
56 for name in ['ly/declarations-init.ly',
57 'ly/declarations-init.ly',
61 for line in F.readlines():
62 m = re.search(r"^(\s*)([a-zA-Z]+)(\s*=)",line)
64 kw = kw + [m.group(2)]
68 for name in ['ly/catalan.ly',
70 'ly/drumpitch-init.ly',
82 for line in F.readlines():
83 m = re.search(r"^(\s*\()([a-z]+)([^l]+ly:make-pitch)",line)
85 notes = notes + ['' + m.group(2)]
89 for name in ['ly/engraver-init.ly',
90 'ly/performer-init.ly']:
92 for line in f.readlines():
93 for pattern in [r"^(\s*.consists\s+\")([a-zA-Z_]+)(\")",
94 r"([\\]name\s+[\"]?)([a-zA-Z_]+)([\"]?)",
95 r"(\s+)([a-zA-Z_]+)(\s*[\\]((set)|(override)))"]:
96 m = re.search(pattern,line)
98 rw = rw + ['' + m.group(2)]
102 suffix = ['skip','skip','skip'];
104 for s in sys.argv[1:]:
111 m = re.search(r"(--dir=)(\S*)",s)
116 outs[0] = open(outdir+'/lilypond-words'+suffix[0], 'w')
118 outs[1] = open(outdir+'/lilypond-words'+suffix[1], 'w')
120 outs[2] = open(outdir+'/lilypond-words'+suffix[2], 'w')
122 # alphabetically ordered words
127 outs[2].write('syn match lilyKeyword \"[-_^]\\?\\\\\\(');
131 outs[0].write('\\\\' + line + '\n')
133 outs[1].write('\\\\' + line + '\n')
135 outs[2].write(line + '\\|')
138 outs[2].write('n\\)\\(\\A\\|\\n\\)\"me=e-1\n')
144 outs[2].write('syn match lilyReservedWord \"\\(\\A\\|\\n\\)\\(')
148 outs[0].write(line + '\n')
150 outs[1].write(line + '\n')
152 outs[2].write(line + '\\|')
155 outs[2].write('Score\\)\\(\\A\\|\\n\\)\"ms=s+1,me=e-1\n')
161 outs[2].write('syn match lilyNote \"\\<\\(\\(\\(');
165 outs[0].write(line + '\n')
167 outs[1].write(line + '\n')
169 outs[2].write(line + '\\|')
172 outs[2].write('a\\)\\([,\']\\)\\{,4}\\([?!]\\)\\?\\)\\|s\\|r\\)\\(\\(128\\|64\\|32\\|16\\|8\\|4\\|2\\|1\\|\\\\breve\\|\\\\longa\\|\\\\maxima\\)[.]\\{,8}\\)\\?\\(\\A\\|\\n\\)\"me=e-1\n')
174 # the menu in lilypond-mode.el
175 for line in ['/( - _ /) -',
183 '//center - / << _ >> -',
184 '//column - / << _ >> -',
185 '//context/ Staff/ = - % { _ } -',
186 '//context/ Voice/ = - % { _ } -',
187 '//markup - { _ } -',
189 '//relative - % { _ } -',
190 '//score - { //n /? //simultaneous { //n _ //n } /! //n //paper { } //n /? //midi { } //n /! } //n -',
191 '//simultaneous - { _ } -',
192 '//sustainDown - _ //sustainUp -',
193 '//times - % { _ } -',
194 '//transpose - % { _ } -',
196 # urg. escape char '/' is replaced with '\\' which python writes as a '\'.
198 outs[1].write(string.join(string.split(line,'/'),'\\') + '\n')