Diff
Not logged in

Differences From Artifact [1725bdb3bf054565]:

To Artifact [caf474d107a1f8cb]:


159 readWhile!isSpace(); 159 readWhile!isSpace(); 160 this.current = (current is null ? readNext() : current); 160 this.current = (current is null ? readNext() : current); 161 } 161 } 162 162 163 public static { 163 public static { 164 bool isSpace (dchar c) { return std.ctype.isspace(c)!=0; } 164 bool isSpace (dchar c) { return std.ctype.isspace(c)!=0; } 165 bool isSymbol (dchar c) { return 0x21<=c && c<=0x7f && !std.cty 165 bool isSymbol (dchar c) { return 0x21<=c && c<=0x7f && !std.cty 166 bool isSSymbol (dchar c) { return !find("()[]{};", c).empty; } | 166 bool isSSymbol (dchar c) { return "()[]{};@".canFind(c); } 167 bool isMSymbol (dchar c) { return isSymbol(c) && !isSSymbol(c) & 167 bool isMSymbol (dchar c) { return isSymbol(c) && !isSSymbol(c) & 168 bool isLetter (dchar c) { return !isSpace(c) && !isSymbol(c); } 168 bool isLetter (dchar c) { return !isSpace(c) && !isSymbol(c); } 169 } 169 } 170 170 171 string readQuoted(const LexPosition pos){char[] buf; return readQuoted(p 171 string readQuoted(const LexPosition pos){char[] buf; return readQuoted(p 172 string readQuoted(const LexPosition pos, ref char[] buf) 172 string readQuoted(const LexPosition pos, ref char[] buf) 173 { 173 { ................................................................................................................................................................................ 269 assert_eq( ts[4].pos.lineno, 2 ); 269 assert_eq( ts[4].pos.lineno, 2 ); 270 assert_eq( ts[4].pos.column, 6 ); 270 assert_eq( ts[4].pos.column, 6 ); 271 assert_eq( ts[4].str, ":-" ); 271 assert_eq( ts[4].str, ":-" ); 272 272 273 assert_eq( ts[5].pos.lineno, 2 ); 273 assert_eq( ts[5].pos.lineno, 2 ); 274 assert_eq( ts[5].pos.column, 8 ); 274 assert_eq( ts[5].pos.column, 8 ); 275 assert_eq( ts[5].str, "(" ); 275 assert_eq( ts[5].str, "(" ); 276 assert_eq( ts[6].str, "@@" ); | 276 assert_eq( ts[6].str, "@" ); > 277 assert_eq( ts[7].str, "@" ); 277 assert_eq( ts[7].str, ";" ); // paren and simicolons are split | 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 unittest 283 unittest 283 { 284 { 284 // !! be sure to run the unittest on the root of the source directory 285 // !! be sure to run the unittest on the root of the source directory 285 auto lexf = lexerFromFile("polemy/lex.d"); 286 auto lexf = lexerFromFile("polemy/lex.d"); 286 lexf = find!`a.str == "module"`(lexf); 287 lexf = find!`a.str == "module"`(lexf); ................................................................................................................................................................................ 364 365 365 unittest 366 unittest 366 { 367 { 367 auto lex = lexerFromString(`=""`); 368 auto lex = lexerFromString(`=""`); 368 assert_eq(lex.front.str, "="); lex.popFront; 369 assert_eq(lex.front.str, "="); lex.popFront; 369 assert_eq(lex.front.str, ""); lex.popFront; 370 assert_eq(lex.front.str, ""); lex.popFront; 370 assert( lex.empty ); 371 assert( lex.empty ); > 372 assert_eq( lexerFromString(`-@`).front.str, "-" ); 371 } 373 } 372 374 373 /// Forward range for reader character by character, 375 /// Forward range for reader character by character, 374 /// keeping track of position information and caring \r\n -> \n conversion. 376 /// keeping track of position information and caring \r\n -> \n conversion. 375 377 376 private 378 private 377 struct PositionedReader(CharSeq) 379 struct PositionedReader(CharSeq)