Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

IntelibSLexAnalyser Class Reference

#include <slexer.hpp>

Collaboration diagram for IntelibSLexAnalyser:

Collaboration graph
[legend]
List of all members.

Detailed Description

Lexical analyzer of S-expressions.

The lexer accepts chars one by one until a whole lexem is ready. The lexer is relatively flexible; it allows to add different keywords, both delimiting or non-delimiting, string literals with any symbol used as quoter, tokens such as #\Newline or the like, and any kind of comments. The lexer is also capable of counting lines on its input.

Definition at line 47 of file slexer.hpp.

Public Types

enum  FeedResult {
  res_empty, res_ready, res_continue, res_eof,
  res_error
}
 The possible results of feeding another character. More...

Public Member Functions

 IntelibSLexAnalyser ()
 The constructor.
 ~IntelibSLexAnalyser ()
 The destructor.
bool AddDelimiter (const char *prefix, const SReference &token)
 Add a delimiter.
bool AddNonDelimiter (const char *prefix, const SReference &token)
 Add a keyword.
bool AddTokenStarter (const char *prefix, SReference(*fun)(const char *str)=0)
 Add a sequence which starts a token.
bool AddStringStarter (const char *prefix, int closer_char, SReference(*fun)(const char *str)=0)
 Add a string literal.
bool AddCommentStarter (const char *prefix, const char *closer="\n")
 Add a comment.
FeedResult FeedChar (int c)
 Give the lexer another character.
SReference Get () const
 Get the lexem when it is ready (FeedChar returned res_ready).
int GetLine () const
 Get the current line number.
void SetLine (int l)
 Set the current line number.
const char * GetErrorMessage () const
 Get the error message in case FeedChar returns res_error.
void Drop ()
 Drop and clear all internal data.

Classes

struct  SpecChar


Member Enumeration Documentation

enum IntelibSLexAnalyser::FeedResult
 

The possible results of feeding another character.

Enumeration values:
res_empty  Nothing but whitespace or comments yet.
res_ready  Lexem is ready.
res_continue  Keep feeding chars, lexem is being built.
res_eof  End of file reached.
res_error  Lexical error encountered.

Definition at line 114 of file slexer.hpp.


Constructor & Destructor Documentation

IntelibSLexAnalyser::IntelibSLexAnalyser  ) 
 

The constructor.

Definition at line 28 of file slexer.cpp.

IntelibSLexAnalyser::~IntelibSLexAnalyser  ) 
 

The destructor.

Definition at line 33 of file slexer.cpp.


Member Function Documentation

bool IntelibSLexAnalyser::AddDelimiter const char *  prefix,
const SReference token
 

Add a delimiter.

Definition at line 42 of file slexer.cpp.

Referenced by IntelibGenericReader::AddDelimiter(), IntelibGenericReader::AddQuoter(), and IntelibGenericReader::AddSequenceOpener().

bool IntelibSLexAnalyser::AddNonDelimiter const char *  prefix,
const SReference token
 

Add a keyword.

Definition at line 52 of file slexer.cpp.

Referenced by IntelibGenericReader::AddSequenceOpener(), and IntelibGenericReader::AddToken().

bool IntelibSLexAnalyser::AddTokenStarter const char *  prefix,
SReference(*)(const char *str)  fun = 0
 

Add a sequence which starts a token.

Token is being read until whitespace or a delimiter

Referenced by IntelibGenericReader::AddTokenType().

bool IntelibSLexAnalyser::AddStringStarter const char *  prefix,
int  closer_char,
SReference(*)(const char *str)  fun = 0
 

Add a string literal.

Referenced by IntelibGenericReader::AddStringLiteral().

bool IntelibSLexAnalyser::AddCommentStarter const char *  prefix,
const char *  closer = "\n"
 

Add a comment.

Definition at line 86 of file slexer.cpp.

Referenced by IntelibGenericReader::AddComment().

IntelibSLexAnalyser::FeedResult IntelibSLexAnalyser::FeedChar int  c  ) 
 

Give the lexer another character.

See the FeedResult enum explanation for possible results

Definition at line 173 of file slexer.cpp.

References EOF, res_continue, res_empty, res_eof, res_error, and res_ready.

Referenced by IntelibGenericReader::FeedChar().

SReference IntelibSLexAnalyser::Get  )  const
 

Get the lexem when it is ready (FeedChar returned res_ready).

Definition at line 161 of file slexer.cpp.

Referenced by IntelibGenericReader::FeedChar().

int IntelibSLexAnalyser::GetLine  )  const
 

Get the current line number.

Definition at line 130 of file slexer.hpp.

Referenced by IntelibGenericReader::FeedChar(), and IntelibGenericReader::GetLine().

void IntelibSLexAnalyser::SetLine int  l  ) 
 

Set the current line number.

Definition at line 132 of file slexer.hpp.

Referenced by IntelibGenericReader::Read(), and IntelibGenericReader::SetLine().

const char* IntelibSLexAnalyser::GetErrorMessage  )  const
 

Get the error message in case FeedChar returns res_error.

Definition at line 134 of file slexer.hpp.

Referenced by IntelibGenericReader::AddDelimiter(), IntelibGenericReader::AddQuoter(), IntelibGenericReader::AddStringLiteral(), IntelibGenericReader::AddToken(), IntelibGenericReader::AddTokenType(), and IntelibGenericReader::FeedChar().

void IntelibSLexAnalyser::Drop  ) 
 

Drop and clear all internal data.

Definition at line 166 of file slexer.cpp.

Referenced by IntelibGenericReader::Drop().


The documentation for this class was generated from the following files:
Generated on Tue Dec 18 00:41:50 2007 for InteLib by  doxygen 1.4.1