Inherits from NSObject
Conforms to CPTokenRecogniser
Declared in CPIdentifierRecogniser.h
CPIdentifierRecogniser.m

Overview

The CPIdentifierRecogniser class attempts to recognise identifiers on the input string.

Identifiers are sequences of characters which begin with a character in one set, and then may contain many characters in a further set subsequently.

This recogniser produces CPIdentifierTokens.

Tasks

Creating and Initialising an Identifier Recogniser

Configuring an Identifier Recogniser

  •   initialCharacters

    Specifies the set of characters the recognised identifiers may begin with.

    property
  •   identifierCharacters

    Specifies the set of characters the recognised identifiers may contain, other than their first character.

    property

Other Methods

Properties

identifierCharacters

Specifies the set of characters the recognised identifiers may contain, other than their first character.

@property (readwrite, retain) NSCharacterSet *identifierCharacters

Discussion

Specifies the set of characters the recognised identifiers may contain, other than their first character.

Declared In

CPIdentifierRecogniser.h

initialCharacters

Specifies the set of characters the recognised identifiers may begin with.

@property (readwrite, retain) NSCharacterSet *initialCharacters

Discussion

Specifies the set of characters the recognised identifiers may begin with.

Declared In

CPIdentifierRecogniser.h

Class Methods

identifierRecogniser

Creates an identifier recogniser that recognises identifiers starting with any english alphabetic character or underscore, and then containing any number of those characters, hyphens, or numeric characters.

+ (id)identifierRecogniser

Return Value

Returns a CPIdentifierRecogniser that recognises C like identifiers.

Discussion

Creates an identifier recogniser that recognises identifiers starting with any english alphabetic character or underscore, and then containing any number of those characters, hyphens, or numeric characters.

Declared In

CPIdentifierRecogniser.h

identifierRecogniserWithInitialCharacters:identifierCharacters:

Creates an identifier recogniser that recognises identifiers starting with any character in initialCharacters, and then containing any number of characters in identifierCharacters.

+ (id)identifierRecogniserWithInitialCharacters:(NSCharacterSet *)initialCharacters identifierCharacters:(NSCharacterSet *)identifierCharacters

Parameters

initialCharacters

The set of characters that the identifier may begin with.

identifierCharacters

The set of characters that the identifier may contain, after its first character.

Return Value

Returns a CPIdentifierRecogniser that recognises identifiers based on the input character sets.

Discussion

Creates an identifier recogniser that recognises identifiers starting with any character in initialCharacters, and then containing any number of characters in identifierCharacters.

Declared In

CPIdentifierRecogniser.h

Instance Methods

initWithInitialCharacters:identifierCharacters:

Initialises an identifier recogniser that recognises identifiers starting with any character in initialCharacters, and then containing any number of characters in identifierCharacters.

- (id)initWithInitialCharacters:(NSCharacterSet *)initialCharacters identifierCharacters:(NSCharacterSet *)identifierCharacters

Parameters

initialCharacters

The set of characters that the identifier may begin with.

identifierCharacters

The set of characters that the identifier may contain, after its first character.

Return Value

Returns the CPIdentifierRecogniser that recognises identifiers based on the input character sets.

Discussion

Initialises an identifier recogniser that recognises identifiers starting with any character in initialCharacters, and then containing any number of characters in identifierCharacters.

Declared In

CPIdentifierRecogniser.h

recogniseTokenInString:currentTokenPosition:

Attempts to recognise a token at tokenPosition in tokenString.

- (CPToken *)recogniseTokenInString:(NSString *)tokenString currentTokenPosition:(NSUInteger *)tokenPosition

Parameters

tokenString

The string in which to recognise tokens.

tokenPosition

The position at which to try to find the token. On output, the position after the recognised token.

Return Value

Returns the token recognised.

Discussion

Attempts to recognise a token at tokenPosition in tokenString.

If a token is successfully recognised, it should be returned, and tokenPosition advanced to after the consumed characters. If no valid token is found nil must be returned instead, and tokenPosition left unchanged.

Declared In

CPTokenRecogniser.h