|
Revision 754, 0.9 kB
(checked in by kris, 2 years ago)
|
Overhaul of the tokenizers -- now use iterators instead.
|
| Line | |
|---|
| 1 |
/******************************************************************************* |
|---|
| 2 |
|
|---|
| 3 |
Tokenize input from the console. There are a variety of handy |
|---|
| 4 |
tokenizers in the mango.text package ~ this illustrates simple |
|---|
| 5 |
usage. |
|---|
| 6 |
|
|---|
| 7 |
*******************************************************************************/ |
|---|
| 8 |
|
|---|
| 9 |
private import mango.io.Console; |
|---|
| 10 |
|
|---|
| 11 |
private import mango.text.QuoteIterator; |
|---|
| 12 |
|
|---|
| 13 |
void main() |
|---|
| 14 |
{ |
|---|
| 15 |
char[] args; |
|---|
| 16 |
|
|---|
| 17 |
// prompt user |
|---|
| 18 |
Cout ("Please enter some space-delimited tokens: "); |
|---|
| 19 |
|
|---|
| 20 |
// get console input |
|---|
| 21 |
Cin (args); |
|---|
| 22 |
|
|---|
| 23 |
// create quote-aware tokenizer for handling space-delimited tokens |
|---|
| 24 |
auto token = new QuoteIterator (args, " \t"); |
|---|
| 25 |
|
|---|
| 26 |
// scan and display trimmed tokens |
|---|
| 27 |
Cout ("You entered: "); |
|---|
| 28 |
while (token.next) |
|---|
| 29 |
Cout ("{") (token.trim.get) ("} "); |
|---|
| 30 |
} |
|---|