Differences From Artifact [50586221a28fd499]:
- File
polemy/lex.d
- 2010-11-08 14:59:30 - part of checkin [b985f3bf91] on branch trunk - refactored parser to change AST to ML-like one. (user: kinaba) [annotate]
To Artifact [cc80329bc2ab2034]:
- File
polemy/lex.d
- 2010-11-08 16:40:55 - part of checkin [aa770610d3] on branch trunk - added layered-let (user: kinaba) [annotate]
153 this.current = (current is null ? readNext() : current); 153 this.current = (current is null ? readNext() : current);
154 } 154 }
155 155
156 public static { 156 public static {
157 bool isSpace (dchar c) { return std.ctype.isspace(c)!=0; } 157 bool isSpace (dchar c) { return std.ctype.isspace(c)!=0; }
158 bool isSymbol (dchar c) { return 0x21<=c && c<=0x7f && !std.cty 158 bool isSymbol (dchar c) { return 0x21<=c && c<=0x7f && !std.cty
159 bool isSSymbol (dchar c) { return !find("()[]{};", c).empty; } 159 bool isSSymbol (dchar c) { return !find("()[]{};", c).empty; }
160 bool isMSymbol (dchar c) { return isSymbol(c) && !isSSymbol(c); | 160 bool isMSymbol (dchar c) { return isSymbol(c) && !isSSymbol(c) &
161 bool isLetter (dchar c) { return !isSpace(c) && !isSymbol(c); } 161 bool isLetter (dchar c) { return !isSpace(c) && !isSymbol(c); }
162 } 162 }
163 163
164 string readQuoted(const LexPosition pos){char[] buf; return readQuoted(p 164 string readQuoted(const LexPosition pos){char[] buf; return readQuoted(p
165 string readQuoted(const LexPosition pos, ref char[] buf) 165 string readQuoted(const LexPosition pos, ref char[] buf)
166 { 166 {
167 if( reader.empty ) 167 if( reader.empty )
................................................................................................................................................................................
349 assert_eq( lex2.front.str, "5" ); 349 assert_eq( lex2.front.str, "5" );
350 lex2.popFront; 350 lex2.popFront;
351 lex3.popFront; 351 lex3.popFront;
352 assert( lex2.empty ); 352 assert( lex2.empty );
353 assert( !lex3.empty ); 353 assert( !lex3.empty );
354 assert_eq( lex3.front.str, "5" ); 354 assert_eq( lex3.front.str, "5" );
355 } 355 }
> 356
> 357 unittest
> 358 {
> 359 auto lex = lexerFromString(`=""`);
> 360 assert_eq(lex.front.str, "="); lex.popFront;
> 361 assert_eq(lex.front.str, ""); lex.popFront;
> 362 assert( lex.empty );
> 363 }
356 364
357 /// Forward range for reader character by character, 365 /// Forward range for reader character by character,
358 /// keeping track of position information and caring \r\n -> \n conversion. 366 /// keeping track of position information and caring \r\n -> \n conversion.
359 367
360 private 368 private
361 struct PositionedReader(CharSeq) 369 struct PositionedReader(CharSeq)
362 if( isForwardRange!(CharSeq) && is(ElementType!(CharSeq) == dchar) ) 370 if( isForwardRange!(CharSeq) && is(ElementType!(CharSeq) == dchar) )