Differences From Artifact [1725bdb3bf054565]:
- File
polemy/lex.d
- 2010-11-09 14:24:09 - part of checkin [2459e9a821] on branch trunk - refactored eof-driven REPL (user: kinaba) [annotate]
To Artifact [caf474d107a1f8cb]:
- File
polemy/lex.d
- 2010-11-09 14:59:36 - part of checkin [7465fcdd7f] on branch trunk - layered function invocation (user: kinaba) [annotate]
159 159 readWhile!isSpace();
160 160 this.current = (current is null ? readNext() : current);
161 161 }
162 162
163 163 public static {
164 164 bool isSpace (dchar c) { return std.ctype.isspace(c)!=0; }
165 165 bool isSymbol (dchar c) { return 0x21<=c && c<=0x7f && !std.ctype.isalnum(c) && c!='_' && c!='\''; }
166 - bool isSSymbol (dchar c) { return !find("()[]{};", c).empty; }
166 + bool isSSymbol (dchar c) { return "()[]{};@".canFind(c); }
167 167 bool isMSymbol (dchar c) { return isSymbol(c) && !isSSymbol(c) && c!='"' && c!='#'; }
168 168 bool isLetter (dchar c) { return !isSpace(c) && !isSymbol(c); }
169 169 }
170 170
171 171 string readQuoted(const LexPosition pos){char[] buf; return readQuoted(pos,buf);}
172 172 string readQuoted(const LexPosition pos, ref char[] buf)
173 173 {
................................................................................
269 269 assert_eq( ts[4].pos.lineno, 2 );
270 270 assert_eq( ts[4].pos.column, 6 );
271 271 assert_eq( ts[4].str, ":-" );
272 272
273 273 assert_eq( ts[5].pos.lineno, 2 );
274 274 assert_eq( ts[5].pos.column, 8 );
275 275 assert_eq( ts[5].str, "(" );
276 - assert_eq( ts[6].str, "@@" );
277 - assert_eq( ts[7].str, ";" ); // paren and simicolons are split
276 + assert_eq( ts[6].str, "@" );
277 + assert_eq( ts[7].str, "@" );
278 + assert_eq( ts[8].str, ";" ); // paren and simicolons, atmarks are split
278 279
279 - assert_eq( ts.length, 8 );
280 + assert_eq( ts.length, 9 );
280 281 }
281 282
282 283 unittest
283 284 {
284 285 // !! be sure to run the unittest on the root of the source directory
285 286 auto lexf = lexerFromFile("polemy/lex.d");
286 287 lexf = find!`a.str == "module"`(lexf);
................................................................................
364 365
365 366 unittest
366 367 {
367 368 auto lex = lexerFromString(`=""`);
368 369 assert_eq(lex.front.str, "="); lex.popFront;
369 370 assert_eq(lex.front.str, ""); lex.popFront;
370 371 assert( lex.empty );
372 + assert_eq( lexerFromString(`-@`).front.str, "-" );
371 373 }
372 374
373 375 /// Forward range for reader character by character,
374 376 /// keeping track of position information and caring \r\n -> \n conversion.
375 377
376 378 private
377 379 struct PositionedReader(CharSeq)