# Lexer Class Reference

Lexer of a file. More...

## Public Member Functions

| Lexer (const File *file)
| Create the lexer and fill the keywords table.
| ~Lexer ()
| Free everything.
void | Next ()
| Read the next character into 'current_char'.
Token | GetToken () const
| Get the current token.
const char * | GetString () const
| Read the currenty processed string.
void | Lex ()
| Perform the lexing/tokenizing of the file till we can return something that must be parsed.

## Private Member Functions

Token | FindKeyword (const char *name) const
| The token based on keyword with a given name.
void | ReadIdentifier ()
| Read an identifier.
void | ReadString (char end, Token token)
| Read a string up to a given character, then set the given token.

## Private Attributes

const File * | file
| The file to read from.
char | current_char
| The current character to process.
char * | string
| Currently processed string.
Token | token
| The current token to process.
char * | buf
| Temporary buffer.
size_t | buf_len
| Length of the temporary buffer.
KeywordList | keywords
| All keywords we know of.

## Detailed Description

Lexer of a file.

Definition at line 158 of file depend.cpp.

## Constructor & Destructor Documentation

Lexer::Lexer | ( | const File * | file | ) | `[inline]`

Create the lexer and fill the keywords table.

Parameters:

  | file | the file to read from.

Definition at line 164 of file depend.cpp.

References buf, buf_len, keywords, Next(), TOKEN_DEFINE, TOKEN_DEFINED, TOKEN_ELIF, TOKEN_ELSE, TOKEN_ENDIF, TOKEN_IF, TOKEN_IFDEF, TOKEN_IFNDEF, TOKEN_INCLUDE, and TOKEN_UNDEF.

## Member Function Documentation

Token Lexer::FindKeyword | ( | const char * | name | ) | const`[inline, private]`

The token based on keyword with a given name.

Parameters:

  | name | the actual keyword.

Returns:
  the token of the keyword.

Definition at line 346 of file depend.cpp.

References keywords, and TOKEN_IDENTIFIER.

Referenced by ReadIdentifier().

const char* Lexer::GetString | ( |  | ) | const`[inline]`

Read the currenty processed string.

Returns:
  the string, can be NULL.

Definition at line 212 of file depend.cpp.

References string.

Referenced by ExpressionDefined(), and ScanFile().

Token Lexer::GetToken | ( |  | ) | const`[inline]`

Get the current token.

Returns:
  the token.

Definition at line 203 of file depend.cpp.

References token.

Referenced by ExpressionAnd(), ExpressionDefined(), ExpressionNot(), ExpressionOr(), and ScanFile().

void Lexer::ReadString | ( | char | end,
|  | Token | token |
| ) |  |  | `[inline, private]`

Read a string up to a given character, then set the given token.

Parameters:

  | end | the 'marker' for the end of the string.
  | token | the token to set after returning.

Definition at line 383 of file depend.cpp.

References buf, buf_len, current_char, and Next().

Referenced by Lex().

The documentation for this class was generated from the following file:

- src/depend/depend.cpp