the type to be tested
true if L satisfies the XML lexer specification here stated; false otherwise
Specification: A lexer shall support at least these methods and aliases:
/* extract a word surrounded by whitespaces */ auto getWord(L)(ref L lexer) if (isLexer!L) { // drop leading whitespaces lexer.dropWhile(" \n\r\t"); // start building the word lexer.start; // keep advancing until you find the trailing whitespaces lexer.advanceUntilAny(" \n\r\t", false); // return what you found return lexer.get; } /* extract a key/value pair from a string like " key : value " */ auto getKeyValuePair(ref L lexer) if (isLexer!L) { // drop leading whitespaces lexer.dropWhile(" \n\r\t"); // here starts the key, which ends with either a whitespace or a colon lexer.start; lexer.advanceUntilAny(" \n\r\t:", false); auto key = lexer.get; // skip any spaces after the key lexer.dropWhile(" \n\r\t"); // now there must be a colon assert(lexer.testAndAdvance(':')); // skip all space after the colon lexer.dropWhile(" \n\r\t"); // here starts the value, which ends at the first whitespace lexer.start; lexer.advanceUntilAny(" \n\r\t", false); auto value = lexer.get; // return the pair return tuple(key, value); }
Checks whether its argument fulfills all requirements to be used as an XML lexer.
An XML lexer is the first component in the parsing chain. It masks from the parser the shape of the input and the type of the characters in it. The slices returned by the lexer are ephemeral: every reference to them may or may not be invalidated when a new slice is requested by the parser. It is thus responsibility of the user to copy the output if necessary.