- Inherits from:
- Object
- Declared in:
- DLexer.h
Object
|
+---DLexer
Class Description
The DLexer class implements a (simple) lexical scanner. The scanner
scans a text stream for constant strings and regular expressions.
There are two sets of services nextString+nextExpression and
checkString+checkExpression. The first set check for the string or
expression and if it is a match, the scanner location is moved to
the next location in the source. The second set of services only
return the result of the match, the client must call the service
'next' to move the scanner location.
- Last modified:
- 31-Oct-2007 (DLexer.h)
Instance Variables
- private DList *_sources
- the stack with the sources
- private DSource *_source
- the source for the scanner
- private DText *_text
- the last scanned text
- private BOOL _eoff
- is end of file reached ?
- private unsigned _scanned
- the length of the scanned text
- private DRegEx *_whiteSpace
- the white space expression
- private DRegEx *_expression
- the normally used regular expression
- private BOOL _caseSensitive
- is the lexer case sensitive (def: YES)
- Constructors
- - (DLexer *) init
- Initialise a lexer
- Returns:
- the object
- - (DLexer *) init :(id <DTextReadable>) source :(const char *) name
- Initialise a lexer 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 lexer (but *NOT* the TextReadables)
- Returns:
- the object
- Member methods
- - (DLexer *) caseSensitive :(BOOL) caseSensitive
- Set the case sensitivity of the lexer
- Parameters:
- caseSensitive - is the lexer case sensitive ?
- Returns:
- the object
- - (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 in a new DText (or nil)
- - (const char *) text
- Get the last scanned text
- Returns:
- the last scanned text (or NULL)
- - (DLexer *) whiteSpace :(const char *) expression
- Set the skip white space expression
- Parameters:
- expression - the skip white space expression (example : [[:space:]]*)
- Returns:
- the object
- Source methods
- - (BOOL) popSource
- Pop a source from the sources stack
- Returns:
- is a source popped from the sources stack ?
- - (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
- - (BOOL) checkExpression :(const char *) cstring
- Check the source for a regular expression
- Parameters:
- cstring - the regular expression to be checked for
- Returns:
- is the regular expression matched in the source ?
- - (BOOL) checkString :(const char *) cstring
- Check for source for a constant string
- Parameters:
- cstring - the constant string to be checked for
- Returns:
- is the constant string found in the source ?
- - (BOOL) checkWhiteSpace
- Check for white space
- Returns:
- is white space found ?
- - (DLexer *) next
- Move the scanned indicator after a check.. method
- Returns:
- the object
- - (DLexer *) next :(unsigned) positions
- Move the scanned indicator a number of positions
- Parameters:
- positions - the number of position to move
- Returns:
- the object
- - (BOOL) nextExpression :(const char *) cstring
- Scan the source for a regular expression
- Parameters:
- cstring - the regular expression to scan for
- Returns:
- is the expression matched ?
- - (BOOL) nextLine
- Scan the source till the end of line. Note: if the
lexer is on the first column, there is no match, the line must
be scanned before nextLine will match.
- Returns:
- is it matched ?
- - (BOOL) nextString :(const char *) cstring
- Scan the source for a constant string
- Parameters:
- cstring - the string to be scanned for
- Returns:
- is it scanned ?
- - (BOOL) nextWhiteSpace
- Skip white space
- Returns:
- is white space skipped ?
- Error methods
- - (DLexer *) 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