- Inherits from:
- Object
- Declared in:
- DObjcTokenizer.h
Object
|
+---DObjcTokenizer
Class Description
The class DObjcTokenizer implements an Objective-C lexical scanner. The
tokenizer scans a text stream for whitespace, strings, keywords,
comments, operators, numbers, predefined types, names, character constants,
etc. There are two methods: nextToken and checkToken. The first method checks
for a token and if there is a match, the scanner location is moved to
the next location in the source. The second method only returns
the result of the match, the client must call the 'next' method to move the
scanner location.
- Last modified:
- 31-Oct-2007 (DObjcTokenizer.h)
Instance Variables
- private DList *_sources
- the stack with the sources
- private DSource *_source
- the source for the tokenizer
- private DText *_text
- the last scanned, processed text
- private DText *_raw
- the last scanned, unprocessed text
- private BOOL _eoff
- is end of file reached ?
- private BOOL _eofl
- is end of line reached ?
- private BOOL _sofl
- is start of line active ?
- private BOOL _comment
- is (block) comment active ?
- private unsigned _scanned
- the length of the scanned text
- private BOOL _skipWhiteSpace
- should whitespace be skipped ? (def. YES)
- private const char *_scanLine
- the current line for the scanner
- private int _currIndex
- the current index in the scanner line
- private int _nextIndex
- the next index in the scanner line
- private int _thrdIndex
- the third index in the scanner line
- private char _currChar
- the current character from the scanner line
- private char _nextChar
- the next character from the scanner line
- private char _thrdChar
- the third character from the scanner line
- private BOOL _currEsc
- is the current character escaped ?
- private BOOL _nextEsc
- is the next character escaped ?
- private BOOL _thrdEsc
- is the third character escaped ?
- Constructors
- - (DObjcTokenizer *) init
- Initialise a tokenizer
- Returns:
- the object
- - (DObjcTokenizer *) init :(id <DTextReadable>) source :(const char *) name
- Initialise a tokenizer with a file
- Parameters:
- source - the source
name - the name for the source
- Returns:
- the object
- Copy related methods
- - shallowCopy
- Do a shallow copy of the object (not implemented)
- Returns:
- the object
- Deconstructor
- - free
- Free the tokenizer (but *NOT* the TextReadables)
- Returns:
- the object
- Class methods
- + (const char *) directive :(int) token
- Return the text for a (preprocessor) directive token
- Parameters:
- token - the directive token
- Returns:
- the text for the directive (or NULL)
- + (BOOL) isArithmeticOperator :(int) token
- Check if the token is an assignment operator token
- Parameters:
- token - the token
- Returns:
- is it?
- + (BOOL) isAssignmentOperator :(int) token
- Check if the token is an assignment operator token
- Parameters:
- token - the token
- Returns:
- is it?
- + (BOOL) isBitOperator :(int) token
- Check if the token is a logical operator token
- Parameters:
- token - the token
- Returns:
- is it?
- + (BOOL) isComparisonOperator :(int) token
- Check if the token is a comparison operator token
- Parameters:
- token - the token
- Returns:
- is it?
- + (BOOL) isDirective :(int) token
- Check if the token is a (preprocessor) directive token
- Parameters:
- token - the token
- Returns:
- is it ?
- + (BOOL) isFlowKeyword :(int) token
- Check if the token is a flow keyword token
- Parameters:
- token - the token
- Returns:
- is it?
- + (BOOL) isKeyword :(int) token
- Check if the token is a keyword token
- Parameters:
- token - the token
- Returns:
- is it?
- + (BOOL) isLogicalOperator :(int) token
- Check if the token is a logical operator token
- Parameters:
- token - the token
- Returns:
- is it?
- + (BOOL) isObjcKeyword :(int) token
- Check if the token is an objective-c keyword token
- Parameters:
- token - the token
- Returns:
- is it?
- + (BOOL) isOperator :(int) token
- Check if the token is an operator token
- Parameters:
- token - the token
- Returns:
- is it?
- + (BOOL) isPredefinedTypeKeyword :(int) token
- Check if the token is a predefined type keyword token
- Parameters:
- token - the token
- Returns:
- is it?
- + (BOOL) isStorageKeyword :(int) token
- Check if the token is a storage keyword token
- Parameters:
- token - the token
- Returns:
- is it?
- + (BOOL) isTypeDefinitionKeyword :(int) token
- Check if the token is a type definition keyword token
- Parameters:
- token - the token
- Returns:
- is it?
- + (const char *) keyword :(int) token
- Return the text for a keyword token
- Parameters:
- token - the keyword token
- Returns:
- the text for the keyword (or NULL)
- + (const char *) objcKeyword :(int) token
- Return the text for an Objective-c keyword
- Parameters:
- token - the keyword
- Returns:
- the text for the keyword (or NULL)
- + (const char *) operator :(int) token
- Return the text for an operator
- Parameters:
- token - the operator token
- Returns:
- the text for the operator (or NULL)
- Member methods
- - (int) columnNumber
- Get the current column number
- Returns:
- the current column number
- - (BOOL) isEof
- Is the end of file reached ?
- Returns:
- is it ?
- - (int) lineNumber
- Get the current line number
- Returns:
- the current line number
- - (const char *) name
- Get the name of the current file
- Returns:
- the name of the file (or NULL)
- - (const char *) raw
- Get the last scanned and unprocessed text
- Returns:
- the last unprocessed text (or NULL)
- - (BOOL) skipWhiteSpace
- Return whether white space is be skipped
- Returns:
- is it ?
- - (DObjcTokenizer *) skipWhiteSpace :(BOOL) skip
- Set whether white space should be skipped
- Parameters:
- skip - should white space be skipped
- Returns:
- the object
- - (const char *) text
- Get the last scanned and processed text
- Returns:
- the last scanned text (or NULL)
- Source methods
- - (BOOL) popSource
- Pop a source from the sources stack
- Returns:
- success
- - (BOOL) source :(id <DTextReadable>) source :(const char *) name
- Start using a source (an already open source is pushed on the sources stack)
- Parameters:
- source - the source
name - the name for the source
- Returns:
- success
- Scanner methods
- - (int) checkToken
- Check the source for the next token (white space is not skipped)
- Returns:
- the scanned token
- - (DObjcTokenizer *) next
- Move the scanned indicator after a checkToken method
- Returns:
- the object
- - (int) nextToken
- Scan the source for the next token (white space is skipped if
this is active)
- Returns:
- the next token
- Error methods
- - (DObjcTokenizer *) error :(const char *) msg
- Generate an error on stderr for the current file and line
- Parameters:
- msg - the error message
- Returns:
- the object
generated 05-Nov-2007 by ObjcDoc 3.0.0