This routine consumes the input stream, returning the next token found. If a token could not be found, then an error is raised.
1 auto scanner = new Scanner(cast(ubyte[])"".representation); 2 assert(cast(EndOfStream)scanner.nextToken()); 3 4 scanner = new Scanner(cast(ubyte[])"\n\n\r\n ".representation); 5 assert(cast(Whitespace)scanner.nextToken()); 6 assert(scanner.lineNumber == 4); 7 assert(scanner.columnNumber == 3); 8 9 scanner = new Scanner(cast(ubyte[])"STOP".representation); 10 StackOpcode stackToken = cast(StackOpcode)scanner.nextToken(); 11 assert(stackToken.m_opcode == "STOP"); 12 13 scanner = new Scanner(cast(ubyte[])"PUSH1 0xa".representation); 14 PushOpcode pushToken = cast(PushOpcode)scanner.nextToken(); 15 assert(pushToken.m_opcode == "PUSH1"); 16 assert(cast(Whitespace)scanner.nextToken()); 17 Number number = cast(Number)scanner.nextToken(); 18 assert(number.m_value == BigInt(10)); 19 20 scanner = new Scanner(cast(ubyte[])"PUSH1 1234".representation); 21 pushToken = cast(PushOpcode)scanner.nextToken(); 22 assert(pushToken.m_opcode == "PUSH1"); 23 assert(cast(Whitespace)scanner.nextToken()); 24 number = cast(Number)scanner.nextToken(); 25 assert(number.m_value == BigInt("1234"));
Scans the input stream provided into a series of tokens.