-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.php
235 lines (206 loc) · 7.31 KB
/
tests.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php
// various tests
require_once("imslp_db.inc");
if (0) {
print_r(DB_person::enum_join(1, 2, "sex='Female'"));
}
/////////////
require_once("imslp_util.inc");
if (0) {
print_r(parse_title(
"Piano_Sonata_No.13,_Op.27_No.1_(suite)_(Beethoven,_Ludwig_van)"
));
}
if (0) {
print_r(parse_name('John Paul Jones'));
print_r(parse_name('Jones, John Paul'));
print_r(parse_name('Charo'));
}
/////////////
require_once("mediawiki.inc");
if (0) {
$x = "Copyright=Public Domain
|Thumb Filename=Contenu neutre.jpg|200px|thumb|left
|Misc. Notes=";
$x = 'List of works by Felix Mendelssohn#{{{1|A}}}| {{{1}}} {{{2}}}]]';
print_r(scan_arg($x, 0));
echo substr($x, 44);
}
if (0) {
$str = <<<'EOT'
{{#fte:imslppage
|Incipit=
<score>\relative c'{ \key c \major \tempo \"Allegro maestoso\" \time 4/4 c8 r g r c r e r f4.( \tuplet 3/2 {e16 d c)} b4 r8. g16 b8 r d r f r d r g4.( \tuplet 3/2 {a16 g f)} e4 r}</score>
<score>\relative c'' { \key f \major \tempo \"Andante\" \time 4/4 f4..( \p c16) a'4..( f16) c'2. bes16( a g f) fis4( g) r2 c,2( e4 g) bes2~( bes8 d c bes) gis( a) a4 r2 }</score>
<br><score>\relative c'' { \key c\major \tempo \"Allegro vivace assai\" \time 2/4 e8-. f-. fis-. g-. a( g) f-. e-. d \appoggiatura {e16} d16( c d8) d-. d4( e8) c | e8-. f-. fis-. g-. a( g) f-. e-. d \appoggiatura {e16} d16( c d8) e-. c4 r }
</Score>
| *****COMMENTS***** =
{{Piano Concertos (Mozart, Wolfgang Amadeus)}}
| *****END OF TEMPLATE***** }}
EOT;
$str = <<<'EOT'
{{#fte:imslppage
|Incipit=Quartet No.1 in D major, 1st mvt. <span class='expandline'><br/><score raw="1">
\header {tagline = ##f}
\score{
\new GrandStaff <<
\new Staff {
\relative c'''{
\set Staff.instrumentName="Flauto o Violino"
\version "2.18.0"
\key d \major
\clef treble
\tempo "Allegro"
\time 4/4
a8_\markup{"dol."}[ fis] d4~ d8[ d' cis b]
a16[ fis a fis] d4. d'8[ cis b]
a[( fis) d-. d]-. g[( e) cis-. cis]-.
d16[( fis d fis)] a4. d8[ cis b]
}
}
\new Staff { \relative c' {
\set Staff.instrumentName="Violino 2o"
\version "2.18.0"
\key d \major
\time 4/4
\clef treble
fis8_\p([ d fis d]) fis([ d g d])
fis([ d fis d] fis[ d g d])
<a fis'>4 r <a g'> r
fis'8[ d fis d] fis[ d g d]
}
}
\new Staff { \relative c' {
\set Staff.instrumentName="Viola"
\version "2.18.0"
\key d \major
\time 4/4
\clef alto
a8_\p([ d a d]) a([ d b d])
a([ d a d]) a([ d b d])
a4 r a r
a8([ d a d] a)[ d b d]
}
}
\new Staff { \relative c, {
\set Staff.instrumentName="Cello"
\version "2.18.0"
\key d \major
\time 4/4
\clef bass
d4_\p d' d d
d, d' d d
d r a r
d, d' d d
}
}
>>
}
</score></span>
|Piece Style=Classical
| *****COMMENTS***** =
{{Piano Concertos (Mozart, Wolfgang Amadeus)}}
| *****END OF TEMPLATE***** }}
EOT;
$pos = 0;
while (true) {
[$item, $new_pos] = parse_item($str, $pos);
$pos = $new_pos;
if ($item === false) break;
if (is_string($item)) {
echo "got text: $item\n";
} else {
echo "got template call\n";
echo " name: $item->name\n";
foreach ($item->args as $n=>$v) {
echo " arg $n\n $v\n";
}
}
}
}
if (0) {
$str = "{{#fte:mclink
|catname = {{ #if:{{{5|}}}|{{#if:{{{2|}}}|{{{2}}}, {{{1}}} @{{{5}}}^|{{{1}}} @{{{5}}}^}} | {{#if:{{{2|}}}|{{{2}}}, {{{1}}}|{{{1}}}}}}}
|sortkey = {{#worksortkey:}}
|mctype = Arranger
|show = {{{1}}}{{#if:{{{2|}}}| {{{2|}}}}}
}}{{ #ifeq: 0{{{3|}}} | 0 | {{ #ifeq: 0{{{4|}}} | 0 | {{#if: {{{5|}}} | ({{{5}}}) | }} | ({{#if: {{{5|}}} |{{{5}}}, |}}d. {{{4}}}) }} | {{ #ifeq: 0{{{4|}}} | 0 | ({{#if: {{{5|}}} |{{{5}}}, |}}b. {{{3}}}) | ({{#if: {{{5|}}} |{{{5}}}, |}}{{{3}}}-{{{4}}})}}}}";
//$str = '{{P|Edition Peters|C.F. Peters|Leipzig|n.d.[{{{2|1902-07}}}]|{{{2|1902}}}|3100|{{{3|8800, 10037-38}}}}}';
//$str = '{{#if:{{{3|}}}|{{{3}}}:<nowiki> </nowiki>|}}';
//$str = '{{#if:{{{4|}}}|{{{4}}}|{{#if:{{{5|}}}|{{{5}}}|n.d}}}}';
//$str = '{{#switch: blah|foo}}';
//$str = '{{#if:{{{4|}}}|(pp.{{{4}}})|}}';
//$str = '{{padleft:{{{2}}}|8|0}}';
$str = '{{Tooltip|{{#iflang:|en=F-Pn}}|{{#iflang:|en=Bibliothèque Nationale de France}}}}';
print_r(parse_template_call($str, 0));
}
if (0) {
$str = '{{MiscLib|PLKj|2||Mus. ms. autogr. Mendelssohn 38.2/4}}';
//$str = '{{#switch: abc|A=fooA|fooB}}';
print_r(parse_template_call($str, 0));
}
/////////////
require_once("parse_work.inc");
if (0) {
$x = [];
//add_elements('xxx 4,5,8', 'foo', $x);
add_elements('xxx 1-3,5,8', 'foo', $x);
print_r($x);
exit;
}
if (0) {
//$x = "''[[Haydn - Piano Sonatas (Martienssen)|Sonaten f▒~C¼r Klavier zu zwei H▒~CC¤nden]]''<br>{{P|Edition Peters|C.F. Peters|Leipzig||1937||11261}}";
$x = "''[[Haydn - Piano Sonatas (Martienssen)|Sonaten für Klavier zu zwei Händen]]''<br>{{P|Edition Peters|C.F. Peters|Leipzig||1937||11333}}";
print_r(parse_publisher($x));
}
if (0) {
//$str = '{{GardnerPerf|Martina Filjak, Piano}}';
//$str = '{{GardnerPerf|Yunjie Chen (piano)}}';
//$str = '{{GardnerPerf|Mark Padmore (voice), Jonathan Biss (piano)}}';
//$str = '{{GardnerPerf|Benjamin Beilman, violin}}; {{GardnerPerf|Yekwon Sunwoo, piano}}';
//$str = '{{GardnerPerf|Rebel Baroque Orchestra (ensemble)}}';
$str = '{{GardnerPerf|Orion String Quartet}}';
print_r(parse_gardner_perfs($str));
}
if (0) {
print_r(parse_perf('Joe Smith, piano'));
print_r(parse_perf('Joe Smith (piano)'));
print_r(parse_perf('Joe Smith piano'));
}
if (0) {
//$str = '{{GardnerPerf|Benjamin Beilman, violin}}; {{GardnerPerf|Yekwon Sunwoo, piano}}';
//$str = '{{GardnerPerf|Rebel Baroque Orchestra (ensemble)}}';
//$str = 'Galaxy Bosendorfer 290 (Tatiana Kolesova)';
//$str = 'Daniel Guilet (violin)<br>{{Plain|http://www.rene-gagnaux.ch/tichman_herbert/courte_biographie.html#Ruth_Budnevich|Ruth Budnevich}} (piano)';
$str = 'Boston Symphony Orchestra=orchestra;Koussevitzky, Serge=conductor';
print_r(parse_performers($str ,''));
}
/////////////
require_once("template.inc");
$verbose = true;
if (1) {
$str = "[foo {{FE}}]";
//$str = "{{GriegKlavierwerke|foo|blah|x3|x4|x5}}";
//$str = "{{P|a|b|c|d|e|f|g|h}}";
//$str = "{{LinkArr|Charles-Valentin|Alkan|1813|1888}}";
//$str = "{{FE}}";
//$str = "{{Années_de_Pèlerinage_(Liszt,_Franz)}}";
//$str = "{{P|Carl Simon||Berlin||||C.S. 1823}}";
//$str = '{{AMG|mc0002406942}}';
//$str = '{{#switch: X|A=fooA|fooB}}';
//$str = '{{Bluefatbox|title=See Also|body= [[List of Intermediate Piano Repertoire]] }}';
//$str = '{{JagU|374138}}';
//$str = '{{MiscLib|PLKj|2||Mus. ms. autogr. Mendelssohn 38.2/4}}';
//$str = '{{JagU|374138}}';
//$str = '1845 - Bonn: [[Simrock]] // London: [[Ewer|J.J. Ewer & Co.]] // Paris: [[Schlesinger|M. Schlesinger]] // Milan: [[Ricordi|J. Ricordi]]';
//$str = '{{LinkEd|Julius|Rietz}} (1812–1877)';
//$str = '{{MendelssohnComplete|11||80|70-83}}';
//$str = '{{MWV|N|19}}';
//$str = '{{HMB|1834|2}}';
//$str = '{{BNFref|12148/cb42870812s|BNF}}';
//$str = "{{P||{{LinkCompS|Carl Philipp Emanuel|Bach|[C.P.E. Bach]}}|Berlin|n.d.[1751]|1751}}<br>''Revised printing'', n.d.[1752].";
//$str = '{{HaydnSonKohler|II, No.17||6424|54-58}}';
$str = "{{pa|Boivin|Mme Boivin}}";
expand_mw_text($str);
}
?>