Declaration

class TDTokenizer

Declaration

@interface TDTokenizer : NSObject

Declaration

class TDTokenizer(NSObject)

Overview

@class	  TDTokenizer
@brief	  A tokenizer divides a string into tokens.
@details	<p>This class is highly customizable with regard to exactly how this division occurs, but it also has defaults that are suitable for many languages. This class assumes that the character values read from the string lie in the range <tt>0-MAXINT</tt>. For example, the Unicode value of a capital A is 65, so <tt>NSLog(@"%C", (unichar)65);</tt> prints out a capital A.</p>
			<p>The behavior of a tokenizer depends on its character state table. This table is an array of 256 <tt>TDTokenizerState</tt> states. The state table decides which state to enter upon reading a character from the input string.</p>
			<p>For example, by default, upon reading an 'A', a tokenizer will enter a "word" state. This means the tokenizer will ask a <tt>TDWordState</tt> object to consume the 'A', along with the characters after the 'A' that form a word. The state's responsibility is to consume characters and return a complete token.</p>
			<p>The default table sets a <tt>TDSymbolState</tt> for every character from 0 to 255, and then overrides this with:</p>
 From	 To	State
	0	' '	whitespaceState
  'a'	'z'	wordState
  'A'	'Z'	wordState
  160	255	wordState
  '0'	'9'	numberState
  '-'	'-'	numberState
  '.'	'.'	numberState
  '"'	'"'	quoteState
 '\''   '\''	quoteState
  '/'	'/'	commentState
			<p>In addition to allowing modification of the state table, this class makes each of the states above available. Some of these states are customizable. For example, wordState allows customization of what characters can be part of a word, after the first character.</p>

Relationships

Inherits From

  • NSObject

Conforms To

  • ObjectiveC.NSObjectProtocol
  • Swift.CVarArg
  • Swift.CustomDebugStringConvertible
  • Swift.CustomStringConvertible
  • Swift.Equatable
  • Swift.Hashable

Relationships

Inherits From

  • NSObject