Note: This website is archived. For up-to-date information about D projects and development, please visit

Module Scanner is intended to be used for parsing texts. It consists from set of functions, which uses internally only one operation: scan. Every function scan returnes struct Matcher, which keeps information about results of scanning: status of scanning, error message, matched position, index of match (in case of matching against sets of sequences or sets of characters).

  • position - position in input
  • repeatno - how many times repeat scanning; for uint.max functions scan for more than zero matches
  • All below functions works also with instances of Storages.

Following template functions are available:

  • Matcher scan(input, CharClass?, position, repeatno)  //CharClass -> basically checks if input from 'position' begins with one of characters defined in CharClass?
  • Matcher scan(input, SequenceSet?, position, repeatno) //SequenceSet -> same as CharClass?, but for sequences
  • Matcher scan(input, RegExp?, position, repeatno)
  • Matcher scan(input, array, position, repeatno)
  • Matcher scan(input, element_of_array, position, repeatno)

For below functions condition can be any of types for scan  + Matcher;

  • uint skip(ref T input, S condition, uint repeatno=1) // returns number of skipped characters
  • StorageType?!(T) munch(T, S)(ref T input, S condition, uint repeatno=1) // consumes characters/sequences/etc. returning them from function

Additional high level functions:

  • Matcher scanEscapeSequence - scans for escape sequence
  • Matcher scanString - scans for string
  • Matcher scanRegion - scans for region; region is delimited by matching characters e.g. [5,5,4]
  • Matcher scanNumber - scans for number; needs some more work
  • Matcher scanDate - scans for number; needs some more work

Scanner uses internally among others CharClass? by Jascha Wetzel from Tango ported to Phobos. Module needs some additional work to make it feature complete.