Scanner style.

This commit is contained in:
Ferdinand Majerech 2014-07-23 02:46:36 +02:00
parent 10120b53c2
commit aadf3232f0

View file

@ -811,7 +811,10 @@ final class Scanner
dstring scanToNextBreak() @safe dstring scanToNextBreak() @safe
{ {
uint length = 0; uint length = 0;
while(!"\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek(length))){++length;} while(!"\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek(length)))
{
++length;
}
return reader_.get(length); return reader_.get(length);
} }
@ -912,7 +915,7 @@ final class Scanner
enforce(isDigit(reader_.peek()), enforce(isDigit(reader_.peek()),
new Error("While scanning a directive", startMark, new Error("While scanning a directive", startMark,
"expected a digit, but found: " ~ "expected a digit, but found: " ~
to!string(reader_.peek()), reader_.mark)); reader_.peek().to!string, reader_.mark));
// Already found the first digit in the enforce(), so set length to 1. // Already found the first digit in the enforce(), so set length to 1.
uint length = 1; uint length = 1;
@ -1461,7 +1464,9 @@ final class Scanner
break; break;
} }
} }
return scalarToken(startMark, endMark, to!string(cast(dstring)appender_.data), ScalarStyle.Plain); return scalarToken(startMark, endMark,
to!string(cast(dstring)appender_.data),
ScalarStyle.Plain);
} }
/// Scan spaces in a plain scalar. /// Scan spaces in a plain scalar.
@ -1518,7 +1523,7 @@ final class Scanner
dchar c = reader_.peek(); dchar c = reader_.peek();
enforce(c == '!', enforce(c == '!',
new Error("While scanning a " ~ name, startMark, new Error("While scanning a " ~ name, startMark,
"expected a '!', but found: " ~ to!string(c), reader_.mark)); "expected a '!', but found: " ~ c.to!string, reader_.mark));
uint length = 1; uint length = 1;
c = reader_.peek(length); c = reader_.peek(length);
@ -1533,7 +1538,7 @@ final class Scanner
{ {
reader_.forward(length); reader_.forward(length);
throw new Error("While scanning a " ~ name, startMark, throw new Error("While scanning a " ~ name, startMark,
"expected a '!', but found: " ~ to!string(c), "expected a '!', but found: " ~ c.to!string,
reader_.mark); reader_.mark);
} }
++length; ++length;
@ -1568,7 +1573,7 @@ final class Scanner
} }
enforce(appender_.data.length > 0, enforce(appender_.data.length > 0,
new Error("While parsing a " ~ name, startMark, new Error("While parsing a " ~ name, startMark,
"expected URI, but found: " ~ to!string(c), reader_.mark)); "expected URI, but found: " ~ c.to!string, reader_.mark));
return cast(dstring)appender_.data; return cast(dstring)appender_.data;
} }
@ -1593,7 +1598,7 @@ final class Scanner
new Error("While scanning a " ~ name, startMark, new Error("While scanning a " ~ name, startMark,
"expected URI escape sequence of " "expected URI escape sequence of "
"2 hexadecimal numbers, but found: " ~ "2 hexadecimal numbers, but found: " ~
to!string(c), reader_.mark)); c.to!string, reader_.mark));
uint digit; uint digit;
if(c - '0' < 10) { digit = c - '0'; } if(c - '0' < 10) { digit = c - '0'; }