annotate chord/urispace/chord_parser.pl @ 27:d95e683fbd35 tip

Enable CORS on urispace redirects as well
author Chris Cannam
date Tue, 20 Feb 2018 14:52:02 +0000
parents 7902f428bc60
children
rev   line source
Chris@10 1 :- module(chord_parser,[chord/4,tokenise/2,parse/2]).
Chris@10 2
Chris@10 3 /**
Chris@10 4 * A SWI DCG for parsing chord textual representation
Chris@10 5 * as defined in Harte, 2005 (ISMIR proceedings)
Chris@10 6 *
Chris@10 7 * Yves Raimond, C4DM, Queen Mary, University of London
Chris@10 8 */
Chris@10 9
Chris@10 10 :- use_module(library('semweb/rdf_db')).
Chris@10 11
Chris@10 12
Chris@10 13 parse(ChordSymbol,RDF) :-
Chris@10 14 tokenise(ChordSymbol,Tokens),
Chris@10 15 phrase(chord(ChordSymbol,RDF2),Tokens),
Chris@10 16 clean(RDF2,RDF3),
Chris@10 17 ((add_image_link(RDF3,RDF,[],_, ''),!);(RDF3=RDF)).
Chris@10 18
Chris@10 19
Chris@10 20 clean(Description,Rest) :-
Chris@10 21 member(rdf(A,'http://purl.org/ontology/chord/without_interval',I1),Description),
Chris@10 22 member(rdf(I1,'http://purl.org/ontology/chord/degree',D),Description),
Chris@10 23 member(rdf(I1,'http://purl.org/ontology/chord/modifier',M),Description),
Chris@10 24 select(rdf(A,'http://purl.org/ontology/chord/interval',I2),Description,R1),
Chris@10 25 select(rdf(I2,'http://purl.org/ontology/chord/degree',D),R1,R2),
Chris@10 26 select(rdf(I2,'http://purl.org/ontology/chord/modifier',M),R2,Rest),!.
Chris@10 27 clean(Description,Rest) :-
Chris@10 28 member(rdf(A,'http://purl.org/ontology/chord/without_interval',I1),Description),
Chris@10 29 member(rdf(I1,'http://purl.org/ontology/chord/degree',D),Description),
Chris@10 30 \+member(rdf(I1,'http://purl.org/ontology/chord/modifier',M),Description),
Chris@10 31 select(rdf(A,'http://purl.org/ontology/chord/interval',I2),Description,R1),
Chris@10 32 select(rdf(I2,'http://purl.org/ontology/chord/degree',D),R1,Rest),
Chris@10 33 \+member(rdf(I2,'http://purl.org/ontology/chord/modifier',M),Rest),!.
Chris@10 34 clean(Description,Description).
Chris@10 35
Chris@10 36
Chris@10 37 add_image_link(DescIn, DescOut, IntsIn, IntsOut, _) :-
Chris@10 38 member(rdf(_, 'http://purl.org/ontology/chord/interval', I), DescIn),
Chris@10 39 member(rdf(I,'http://purl.org/ontology/chord/degree',literal(type(_,D))),DescIn),
Chris@10 40 \+member(D, IntsIn),
Chris@10 41 append([D], IntsIn, I2),
Chris@10 42 add_image_link(DescIn, DescOut, I2, IntsOut).
Chris@10 43
Chris@10 44 add_image_link(DescIn, DescOut, IntsIn, IntsIn) :-
Chris@10 45 member(rdf(C,'http://purl.org/ontology/chord/interval',_), DescIn),
Chris@10 46 %root_for_chord(DescIn,C,Root),
Chris@10 47 %sort(IntsIn, SortedInts),
Chris@10 48 %concat_atom(SortedInts,',',Ints),
Chris@10 49 atom_concat('http://purl.org/ontology/chord/symbol/',Symbol,C),
Chris@10 50 format(atom(Image),'http://rvw.doc.gold.ac.uk/omras2/widgets/chord/~w',[Symbol]),
Chris@10 51 append([rdf(C,'http://xmlns.com/foaf/0.1/depiction', Image)],DescIn, DescOut).
Chris@10 52
Chris@10 53
Chris@10 54 root_for_chord(RDF, C, Root) :-
Chris@10 55 member(rdf(C,'http://purl.org/ontology/chord/root',RNote), RDF),
Chris@10 56 atom_concat('http://purl.org/ontology/chord/note/',Root,RNote).
Chris@10 57
Chris@10 58 root_for_chord(RDF, C, Root) :-
Chris@10 59 member(rdf(C,'http://purl.org/ontology/chord/root',RNote), RDF),
Chris@10 60 member(rdf(RNote,'http://purl.org/ontology/chord/natural',Natural), RDF),
Chris@10 61 atom_concat('http://purl.org/ontology/chord/note/',RootNat,Natural),
Chris@10 62 member(rdf(RNote,'http://purl.org/ontology/chord/modifier', M), RDF),
Chris@10 63 modifier(M,MText),
Chris@10 64 atom_concat(RootNat,MText,Root).
Chris@10 65
Chris@10 66 modifier('http://purl.org/ontology/chord/flat', T) :- T='b'.
Chris@10 67 modifier('http://purl.org/ontology/chord/sharp', T) :- T='s'.
Chris@10 68 modifier('http://purl.org/ontology/chord/doubleflat', T) :- T='bb'.
Chris@10 69 modifier('http://purl.org/ontology/chord/doublesharp', T) :- T='ss'.
Chris@10 70
Chris@10 71
Chris@10 72 % DCG
Chris@10 73
Chris@10 74 namespace('http://purl.org/ontology/chord/symbol/').
Chris@10 75
Chris@10 76 chord(Symbol,
Chris@10 77 [
Chris@10 78 rdf(ID,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/Chord')
Chris@10 79 , rdf(ID,'http://www.w3.org/2002/07/owl#sameAs','http://purl.org/ontology/chord/noChord')
Chris@10 80 ]
Chris@10 81 ) -->
Chris@10 82 {namespace(NS),atom_concat(NS,Symbol,ID)},
Chris@10 83 ['N'].
Chris@10 84 chord(Symbol,
Chris@10 85 [
Chris@10 86 rdf(ID,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/Chord')
Chris@10 87 , rdf(ID,'http://purl.org/ontology/chord/root',NoteURI)
Chris@10 88 , rdf(ID,'http://purl.org/ontology/chord/base_chord',ShorthandURI)
Chris@10 89 | Tail
Chris@10 90 ]
Chris@10 91 ) -->
Chris@10 92 {namespace(NS),atom_concat(NS,Symbol,ID)},
Chris@10 93 note(NoteURI,T1),
Chris@10 94 [':'],
Chris@10 95 shorthand(ShorthandURI),
Chris@10 96 optdegreelist(ID,T2),
Chris@10 97 optdegree(ID,T3),
Chris@10 98 !,
Chris@10 99 {shorthand_rdf(ID,ShorthandURI,ShorthandRDF),flatten([ShorthandRDF,T1,T2,T3],Tail)}.
Chris@10 100 chord(Symbol,
Chris@10 101 [
Chris@10 102 rdf(ID,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/Chord')
Chris@10 103 , rdf(ID,'http://purl.org/ontology/chord/root',NoteURI)
Chris@10 104 | Tail
Chris@10 105 ]
Chris@10 106 ) -->
Chris@10 107 {namespace(NS),atom_concat(NS,Symbol,ID)},
Chris@10 108 note(NoteURI,T1),
Chris@10 109 [':'],
Chris@10 110 ['('],
Chris@10 111 degreelist(ID,T2),
Chris@10 112 [')'],
Chris@10 113 optdegree(ID,T3),!,
Chris@10 114 {flatten([T1,T2,T3],Tail)}.
Chris@10 115 chord(Symbol,
Chris@10 116 [
Chris@10 117 rdf(ID,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/Chord')
Chris@10 118 , rdf(ID,'http://purl.org/ontology/chord/root',NoteURI)
Chris@10 119 , rdf(ID,'http://purl.org/ontology/chord/base_chord','http://purl.org/ontology/chord/maj')
Chris@10 120 | Tail
Chris@10 121 ]
Chris@10 122 ) -->
Chris@10 123 {namespace(NS),atom_concat(NS,Symbol,ID)},
Chris@10 124 note(NoteURI,T1),
Chris@10 125 optdegree(ID,T2),!,
Chris@10 126 {shorthand_rdf(ID,'http://purl.org/ontology/chord/maj',ShorthandRDF),flatten([T1,T2,ShorthandRDF],Tail)}.
Chris@10 127 chord([]) --> [].
Chris@10 128
Chris@10 129 note(ID,[
Chris@10 130 rdf(ID,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/Note')
Chris@10 131 , rdf(ID,'http://purl.org/ontology/chord/modifier',Modifier)
Chris@10 132 , rdf(ID,'http://purl.org/ontology/chord/natural',NoteURI)
Chris@10 133 ]) -->
Chris@10 134 {rdf_bnode(ID)},
Chris@10 135 natural(NoteURI),
Chris@10 136 modifier(Modifier),!.
Chris@10 137 note(NoteURI,[]) -->
Chris@10 138 natural(NoteURI).
Chris@10 139
Chris@10 140 optdegreelist(ID,Triples) -->
Chris@10 141 ['('],degreelist(ID,Triples),[')'],!.
Chris@10 142 optdegreelist(_,[]) --> [].
Chris@10 143
Chris@10 144 optdegree(ID,[rdf(ID,'http://purl.org/ontology/chord/bass',BassNode),rdf(BassNode,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/ScaleInterval')|Triples]) -->
Chris@10 145 {rdf_bnode(BassNode)},
Chris@10 146 ['/'],degree(BassNode,Triples),!.
Chris@10 147 optdegree(_,[]) --> [].
Chris@10 148
Chris@10 149 natural('http://purl.org/ontology/chord/note/A') --> ['A'].
Chris@10 150 natural('http://purl.org/ontology/chord/note/B') --> ['B'].
Chris@10 151 natural('http://purl.org/ontology/chord/note/C') --> ['C'].
Chris@10 152 natural('http://purl.org/ontology/chord/note/D') --> ['D'].
Chris@10 153 natural('http://purl.org/ontology/chord/note/E') --> ['E'].
Chris@10 154 natural('http://purl.org/ontology/chord/note/F') --> ['F'].
Chris@10 155 natural('http://purl.org/ontology/chord/note/G') --> ['G'].
Chris@10 156
Chris@10 157 modifier('http://purl.org/ontology/chord/doubleflat') --> ['b','b'].
Chris@10 158 modifier('http://purl.org/ontology/chord/doublesharp') --> ['s','s'].
Chris@10 159 modifier('http://purl.org/ontology/chord/flat') --> ['b'].
Chris@10 160 modifier('http://purl.org/ontology/chord/sharp') --> ['s']. %will perhaps have to change it
Chris@10 161
Chris@10 162 degreelist(URI,[
Chris@10 163 rdf(URI,'http://purl.org/ontology/chord/without_interval',Interval)
Chris@10 164 , rdf(Interval,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/ScaleInterval')
Chris@10 165 | Tail
Chris@10 166 ]) -->
Chris@10 167 {rdf_bnode(Interval)},
Chris@10 168 ['*'],
Chris@10 169 degree(Interval,T1),
Chris@10 170 [','],
Chris@10 171 degreelist(URI,T2),
Chris@10 172 {append(T1,T2,Tail)}.
Chris@10 173 degreelist(URI,[
Chris@10 174 rdf(URI,'http://purl.org/ontology/chord/without_interval',Interval)
Chris@10 175 , rdf(Interval,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/ScaleInterval')
Chris@10 176 | Tail
Chris@10 177 ]) -->
Chris@10 178 ['*'],
Chris@10 179 {rdf_bnode(Interval)},
Chris@10 180 degree(Interval,Tail).
Chris@10 181 degreelist(URI,[
Chris@10 182 rdf(URI,'http://purl.org/ontology/chord/interval',Interval)
Chris@10 183 , rdf(Interval,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/ScaleInterval')
Chris@10 184 | Tail
Chris@10 185 ]) -->
Chris@10 186 {rdf_bnode(Interval)},
Chris@10 187 degree(Interval,T1),
Chris@10 188 [','],
Chris@10 189 degreelist(URI,T2),
Chris@10 190 {append(T1,T2,Tail)}.
Chris@10 191 degreelist(URI,[
Chris@10 192 rdf(URI,'http://purl.org/ontology/chord/interval',Interval)
Chris@10 193 , rdf(Interval,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/ScaleInterval')
Chris@10 194 | Tail
Chris@10 195 ]) -->
Chris@10 196 {rdf_bnode(Interval)},
Chris@10 197 degree(Interval,Tail).
Chris@10 198
Chris@10 199
Chris@10 200 degree(IntervalURI,[rdf(IntervalURI,'http://purl.org/ontology/chord/degree',literal(type('http://www.w3.org/2001/XMLSchema#int',Interval)))]) -->
Chris@10 201 interval(Interval).
Chris@10 202 %No more than two modifiers - hardcoded
Chris@10 203 degree(IntervalURI,
Chris@10 204 [
Chris@10 205 rdf(IntervalURI,'http://purl.org/ontology/chord/modifier',ModifierURI)
Chris@10 206 , rdf(IntervalURI,'http://purl.org/ontology/chord/degree',literal(type('http://www.w3.org/2001/XMLSchema#int',Interval)))
Chris@10 207 ]) -->
Chris@10 208 modifier(ModifierURI),
Chris@10 209 interval(Interval).
Chris@10 210
Chris@10 211
Chris@10 212 interval(N) -->
Chris@10 213 [N],
Chris@10 214 {member(N,['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24'])}.
Chris@10 215
Chris@10 216 shorthand('http://purl.org/ontology/chord/maj') -->
Chris@10 217 ['maj'].
Chris@10 218 shorthand('http://purl.org/ontology/chord/min') -->
Chris@10 219 ['min'].
Chris@10 220 shorthand('http://purl.org/ontology/chord/dim') -->
Chris@10 221 ['dim'].
Chris@10 222 shorthand('http://purl.org/ontology/chord/aug') -->
Chris@10 223 ['aug'].
Chris@10 224 shorthand('http://purl.org/ontology/chord/maj7') -->
Chris@10 225 ['maj7'].
Chris@10 226 shorthand('http://purl.org/ontology/chord/min7') -->
Chris@10 227 ['min7'].
Chris@10 228 shorthand('http://purl.org/ontology/chord/seventh') -->
Chris@10 229 ['7'].
Chris@10 230 shorthand('http://purl.org/ontology/chord/dim7') -->
Chris@10 231 ['dim7'].
Chris@10 232 shorthand('http://purl.org/ontology/chord/hdim7') -->
Chris@10 233 ['hdim7'].
Chris@10 234 shorthand('http://purl.org/ontology/chord/minmaj7') -->
Chris@10 235 ['minmaj7'].
Chris@10 236 shorthand('http://purl.org/ontology/chord/maj6') -->
Chris@10 237 ['maj6'].
Chris@10 238 shorthand('http://purl.org/ontology/chord/min6') -->
Chris@10 239 ['min6'].
Chris@10 240 shorthand('http://purl.org/ontology/chord/ninth') -->
Chris@10 241 ['9'].
Chris@10 242 shorthand('http://purl.org/ontology/chord/maj9') -->
Chris@10 243 ['maj9'].
Chris@10 244 shorthand('http://purl.org/ontology/chord/min9') -->
Chris@10 245 ['min9'].
Chris@10 246 shorthand('http://purl.org/ontology/chord/sus4') -->
Chris@10 247 ['sus4'].
Chris@10 248 shorthand('http://purl.org/ontology/chord/sus2') -->
Chris@10 249 ['sus2'].
Chris@10 250
Chris@10 251
Chris@10 252 shorthand_intervals('http://purl.org/ontology/chord/maj',['1','3','5']).
Chris@10 253 shorthand_intervals('http://purl.org/ontology/chord/min',['1',flat('3'),'5']).
Chris@10 254 shorthand_intervals('http://purl.org/ontology/chord/dim',['1',flat('3'),flat('5')]).
Chris@10 255 shorthand_intervals('http://purl.org/ontology/chord/aug',['1','3',sharp('5')]).
Chris@10 256 shorthand_intervals('http://purl.org/ontology/chord/maj7',['1','3','5','7']).
Chris@10 257 shorthand_intervals('http://purl.org/ontology/chord/seventh',['1','3','5',flat('7')]).
Chris@10 258 shorthand_intervals('http://purl.org/ontology/chord/min7',['1',flat('3'),'5',flat('7')]).
Chris@10 259 shorthand_intervals('http://purl.org/ontology/chord/dim7',['1',flat('3'),flat('5'),doubleflat('7')]).
Chris@10 260 shorthand_intervals('http://purl.org/ontology/chord/hdim7',['1',flat('3'),flat('5'),flat('7')]).
Chris@10 261 shorthand_intervals('http://purl.org/ontology/chord/minmaj7',['1',flat('3'),'5','7']).
Chris@10 262 shorthand_intervals('http://purl.org/ontology/chord/maj6',['1','3','5','6']).
Chris@10 263 shorthand_intervals('http://purl.org/ontology/chord/min6',['1',flat('3'),'5','6']).
Chris@10 264 shorthand_intervals('http://purl.org/ontology/chord/ninth',['1','3','5',flat('7'),'9']).
Chris@10 265 shorthand_intervals('http://purl.org/ontology/chord/maj9',['1','3','5','7','9']).
Chris@10 266 shorthand_intervals('http://purl.org/ontology/chord/min9',['1',flat('3'),'5',flat('7'),'9']).
Chris@10 267 shorthand_intervals('http://purl.org/ontology/chord/sus4',['1','4','5']).
Chris@10 268 shorthand_intervals('http://purl.org/ontology/chord/sus2',['1','2','5']).
Chris@10 269
Chris@10 270 shorthand_rdf(Chord,Shorthand,RDF) :-
Chris@10 271 shorthand_intervals(Shorthand,Intervals),
Chris@10 272 intervals_to_rdf(Chord,Intervals,RDF).
Chris@10 273
Chris@10 274 intervals_to_rdf(Chord,[flat(H)|T],[rdf(Chord,'http://purl.org/ontology/chord/interval',SI),rdf(SI,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/ScaleInterval'),rdf(SI,'http://purl.org/ontology/chord/degree',literal(type('http://www.w3.org/2001/XMLSchema#int',H))),rdf(SI,'http://purl.org/ontology/chord/modifier','http://purl.org/ontology/chord/flat')|T2]) :-
Chris@10 275 !,rdf_bnode(SI),
Chris@10 276 intervals_to_rdf(Chord,T,T2).
Chris@10 277
Chris@10 278 intervals_to_rdf(Chord,[doubleflat(H)|T],[rdf(Chord,'http://purl.org/ontology/chord/interval',SI),rdf(SI,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/ScaleInterval'),rdf(SI,'http://purl.org/ontology/chord/degree',literal(type('http://www.w3.org/2001/XMLSchema#int',H))),rdf(SI,'http://purl.org/ontology/chord/modifier','http://purl.org/ontology/chord/doubleflat')|T2]) :-
Chris@10 279 !,rdf_bnode(SI),
Chris@10 280 intervals_to_rdf(Chord,T,T2).
Chris@10 281
Chris@10 282 intervals_to_rdf(Chord,[sharp(H)|T],[rdf(Chord,'http://purl.org/ontology/chord/interval',SI),rdf(SI,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/ScaleInterval'),rdf(SI,'http://purl.org/ontology/chord/degree',literal(type('http://www.w3.org/2001/XMLSchema#int',H))),rdf(SI,'http://purl.org/ontology/chord/modifier','http://purl.org/ontology/chord/sharp')|T2]) :-
Chris@10 283 !,rdf_bnode(SI),
Chris@10 284 intervals_to_rdf(Chord,T,T2).
Chris@10 285
Chris@10 286 intervals_to_rdf(Chord,[doublesharp(H)|T],[rdf(Chord,'http://purl.org/ontology/chord/interval',SI),rdf(SI,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/ScaleInterval'),rdf(SI,'http://purl.org/ontology/chord/degree',literal(type('http://www.w3.org/2001/XMLSchema#int',H))),rdf(SI,'http://purl.org/ontology/chord/modifier','http://purl.org/ontology/chord/doublesharp')|T2]) :-
Chris@10 287 !,rdf_bnode(SI),
Chris@10 288 intervals_to_rdf(Chord,T,T2).
Chris@10 289
Chris@10 290 intervals_to_rdf(Chord,[H|T],[rdf(Chord,'http://purl.org/ontology/chord/interval',SI),rdf(SI,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://purl.org/ontology/chord/ScaleInterval'),rdf(SI,'http://purl.org/ontology/chord/degree',literal(type('http://www.w3.org/2001/XMLSchema#int',H)))|T2]) :-
Chris@10 291 rdf_bnode(SI),
Chris@10 292 intervals_to_rdf(Chord,T,T2).
Chris@10 293
Chris@10 294 intervals_to_rdf(_,[],[]).
Chris@10 295
Chris@10 296
Chris@10 297
Chris@10 298 %tokeniser
Chris@10 299
Chris@10 300 %tokens - the order is actually important (longer first)
Chris@10 301
Chris@10 302 token(minmaj7).
Chris@10 303 token(maj9).
Chris@10 304 token(maj7).
Chris@10 305 token(maj6).
Chris@10 306 token(maj).
Chris@10 307 token(min9).
Chris@10 308 token(min7).
Chris@10 309 token(min6).
Chris@10 310 token(min).
Chris@10 311 token(dim7).
Chris@10 312 token(dim).
Chris@10 313 token(aug).
Chris@10 314 token('7').
Chris@10 315 token(hdim7).
Chris@10 316 token('9').
Chris@10 317 token(sus4).
Chris@10 318 token(sus2).
Chris@10 319
Chris@10 320 token('A').
Chris@10 321 token('B').
Chris@10 322 token('C').
Chris@10 323 token('D').
Chris@10 324 token('E').
Chris@10 325 token('F').
Chris@10 326 token('G').
Chris@10 327
Chris@10 328 token('10').
Chris@10 329 token('11').
Chris@10 330 token('12').
Chris@10 331 token('13').
Chris@10 332 token('14').
Chris@10 333 token('15').
Chris@10 334 token('16').
Chris@10 335 token('17').
Chris@10 336 token('18').
Chris@10 337 token('19').
Chris@10 338 token('1').
Chris@10 339 token('20').
Chris@10 340 token('21').
Chris@10 341 token('22').
Chris@10 342 token('23').
Chris@10 343 token('24').
Chris@10 344 token('2').
Chris@10 345 token('3').
Chris@10 346 token('4').
Chris@10 347 token('5').
Chris@10 348 token('6').
Chris@10 349 token('7').
Chris@10 350 token('8').
Chris@10 351 token('9').
Chris@10 352
Chris@10 353 %token('#').
Chris@10 354 token(s).
Chris@10 355 token(':').
Chris@10 356 token('b').
Chris@10 357 token('/').
Chris@10 358 token('(').
Chris@10 359 token(')').
Chris@10 360 token(',').
Chris@10 361 token('*').
Chris@10 362 token('N').
Chris@10 363
Chris@10 364
Chris@10 365 tokenise(Atom,Tokens) :-
Chris@10 366 atom_chars(Atom,Chars),
Chris@10 367 tokenise_l(Chars,Tokens),!.
Chris@10 368 tokenise_l([],[]) :- !.
Chris@10 369 tokenise_l(Chars,[Token|Tail]) :-
Chris@10 370 grab_token(Chars,Token,CharRest),
Chris@10 371 tokenise_l(CharRest,Tail).
Chris@10 372
Chris@10 373 grab_token([H|T1],Atom,CharRest) :-
Chris@10 374 token(Token),atom_chars(Token,[H|T2]),
Chris@10 375 grab_token2(T1,T2,H,Atom,CharRest).
Chris@10 376 grab_token2(Tail,[],Atom,Atom,Tail) :- !.
Chris@10 377 grab_token2([H|T1],[H|T2],At,Atom,CharRest) :-
Chris@10 378 atom_concat(At,H,NewAt),
Chris@10 379 grab_token2(T1,T2,NewAt,Atom,CharRest).
Chris@10 380
Chris@10 381
Chris@10 382