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

IntelibReader Class Reference

#include <sreader.hpp>

Inheritance diagram for IntelibReader:

Inheritance graph
[legend]
Collaboration diagram for IntelibReader:

Collaboration graph
[legend]
List of all members.

Detailed Description

The reader preprogramed for Lisp S-expressions.

This object differs from IntelibGenericReader only in the constructor, which sets up the reader to recognize the parentheses, the dot, the double-quotes, the character escapes and the comment.

Warning:
It doesn't set up any quoters such as ', #', ,@ etc; use the appropriate child objects instead if you need the quoters: LispReader introduces ', #', #& etc; SchemeReader doesn't introduce #', but introduces T and #F.

Definition at line 252 of file sreader.hpp.

Public Types

typedef SReference(* process_function )(SReference &)
 A function used to process some syntax constructs.

Public Member Functions

 IntelibReader ()
void AddDelimiter (char *str, SReference &tok)
 lexem to be considered a delimiter in itself
void AddToken (char *str, SReference &tok)
 lexem that isn't a delimiter but nevertheless special
void AddTokenType (char *str, SReference(*fun)(char *))
 lexem to be read until a delimiter, such as : or &
void AddStringLiteral (char *str, int closing_char, SReference(*fun)(char *)=0)
 lexem to be read until a delimiter, such as : or &
void AddQuoter (char *str, process_function proc)
 lexem that modifies the following expression, such as ', #', `
void AddSequenceOpener (char *str, process_function proc, char *closer, char *cons_sign=0, bool cons_sign_delimiter=false)
 lexem which opens a sequence, such as (, #(, #S(
void AddTailSeparator (char *str, bool is_delimiter=false)
 lexem for separating a cons, such as . in lisp, or | in prolog
void AddComment (char *starter, char *closer="\n")
 comment
IntelibPackageSetPackage (IntelibPackage *a_package)
 install a package
void SetUppercase (bool u)
 Should the identifiers be converted into the upper case.
void SetLine (int l, SString &afn="")
 Set the fule name and line number information.
int GetLine ()
 Get the current line number.
SStringGetFileName ()
 Get the current file name.
void FeedChar (int c)
 Pass another character to the reader.
void FeedString (char *s)
 Pass a string to the reader, char by char.
void FeedEof ()
 Pass the End Of File condition to the reader.
bool IsEmpty ()
 Is the buffer totally empty?
bool IsReady ()
 Is there an expression to get?
SReference Get ()
 Get the next expression constructed by the reader.
void Drop ()
 Drop all the stored information.
SReference Read (SStreamRef &stream)
 Read one expression from the given stream.

Static Public Attributes

static SLabelEofMarker = LexemaEof
 The end of file marker.


Member Typedef Documentation

typedef SReference(* IntelibGenericReader::process_function)(SReference &) [inherited]
 

A function used to process some syntax constructs.

Definition at line 85 of file sreader.hpp.


Constructor & Destructor Documentation

IntelibReader::IntelibReader  ) 
 

Definition at line 448 of file sreader.cpp.

References IntelibGenericReader::AddComment(), IntelibGenericReader::AddSequenceOpener(), IntelibGenericReader::AddStringLiteral(), and IntelibGenericReader::AddTokenType().


Member Function Documentation

void IntelibGenericReader::AddDelimiter char *  str,
SReference tok
[inherited]
 

lexem to be considered a delimiter in itself

Definition at line 66 of file sreader.cpp.

References IntelibSLexAnalyser::AddDelimiter(), IntelibSLexAnalyser::GetErrorMessage(), and INTELIB_ASSERT.

Referenced by SchemeReader::SchemeReader().

void IntelibGenericReader::AddToken char *  str,
SReference tok
[inherited]
 

lexem that isn't a delimiter but nevertheless special

Definition at line 73 of file sreader.cpp.

References IntelibSLexAnalyser::AddNonDelimiter(), IntelibSLexAnalyser::GetErrorMessage(), and INTELIB_ASSERT.

void IntelibGenericReader::AddTokenType char *  str,
SReference(*)(char *)  fun
[inherited]
 

lexem to be read until a delimiter, such as : or &

Definition at line 80 of file sreader.cpp.

References IntelibSLexAnalyser::AddTokenStarter(), IntelibSLexAnalyser::GetErrorMessage(), and INTELIB_ASSERT.

Referenced by IntelibReader(), and LispReader::LispReader().

void IntelibGenericReader::AddStringLiteral char *  str,
int  closing_char,
SReference(*)(char *)  fun = 0
[inherited]
 

lexem to be read until a delimiter, such as : or &

Definition at line 87 of file sreader.cpp.

References IntelibSLexAnalyser::AddStringStarter(), IntelibSLexAnalyser::GetErrorMessage(), and INTELIB_ASSERT.

Referenced by IntelibReader(), LispReader::LispReader(), and SchemeReader::SchemeReader().

void IntelibGenericReader::AddQuoter char *  str,
process_function  proc
[inherited]
 

lexem that modifies the following expression, such as ', #', `

Definition at line 94 of file sreader.cpp.

References IntelibSLexAnalyser::AddDelimiter(), IntelibSLexAnalyser::GetErrorMessage(), and INTELIB_ASSERT.

Referenced by LispReader::LispReader(), and SchemeReader::SchemeReader().

void IntelibGenericReader::AddSequenceOpener char *  str,
process_function  proc,
char *  closer,
char *  cons_sign = 0,
bool  cons_sign_delimiter = false
[inherited]
 

lexem which opens a sequence, such as (, #(, #S(

Definition at line 101 of file sreader.cpp.

References IntelibSLexAnalyser::AddDelimiter(), IntelibSLexAnalyser::AddNonDelimiter(), and SReference::GetPtr().

Referenced by IntelibReader().

void IntelibGenericReader::AddTailSeparator char *  str,
bool  is_delimiter = false
[inherited]
 

lexem for separating a cons, such as . in lisp, or | in prolog

void IntelibGenericReader::AddComment char *  starter,
char *  closer = "\n"
[inherited]
 

comment

by default, it is a line-based comment; just specify your desired comment closing token to create a block comment

Definition at line 149 of file sreader.cpp.

References IntelibSLexAnalyser::AddCommentStarter().

Referenced by IntelibReader().

IntelibPackage* IntelibGenericReader::SetPackage IntelibPackage a_package  )  [inherited]
 

install a package

Warning:
The package object is not deleted by the destructor, so it is the caller's duty to take care about it

Definition at line 158 of file sreader.hpp.

void IntelibGenericReader::SetUppercase bool  u  )  [inherited]
 

Should the identifiers be converted into the upper case.

Definition at line 166 of file sreader.hpp.

void IntelibGenericReader::SetLine int  l,
SString afn = ""
[inherited]
 

Set the fule name and line number information.

Parameters:
l is the line number
afn is the file name, none by default

Definition at line 154 of file sreader.cpp.

References IntelibSLexAnalyser::SetLine().

int IntelibGenericReader::GetLine  )  [inherited]
 

Get the current line number.

Definition at line 160 of file sreader.cpp.

References IntelibSLexAnalyser::GetLine().

SString& IntelibGenericReader::GetFileName  )  [inherited]
 

Get the current file name.

Definition at line 176 of file sreader.hpp.

void IntelibGenericReader::FeedChar int  c  )  [inherited]
 

Pass another character to the reader.

Definition at line 165 of file sreader.cpp.

References IntelibSLexAnalyser::FeedChar(), IntelibSLexAnalyser::Get(), IntelibSLexAnalyser::GetErrorMessage(), IntelibSLexAnalyser::GetLine(), and SString::SString().

Referenced by IntelibGenericReader::FeedEof(), IntelibGenericReader::FeedString(), and IntelibGenericReader::Read().

void IntelibGenericReader::FeedString char *  s  )  [inherited]
 

Pass a string to the reader, char by char.

Definition at line 188 of file sreader.cpp.

References IntelibGenericReader::FeedChar().

void IntelibGenericReader::FeedEof  )  [inherited]
 

Pass the End Of File condition to the reader.

Definition at line 183 of file sreader.hpp.

References IntelibGenericReader::FeedChar().

bool IntelibGenericReader::IsEmpty  )  [inherited]
 

Is the buffer totally empty?

Returns true if there are neither complete expressions nor incomplete lexem chains stored within the reader. Generally speaking, this can only be true if only whitespace and comments were read so far (or since the last sequence of Get() operations which emptied the buffer, or since the last Drop() operation).

Definition at line 193 of file sreader.hpp.

References SQueue::IsEmpty().

bool IntelibGenericReader::IsReady  )  [inherited]
 

Is there an expression to get?

Definition at line 195 of file sreader.hpp.

References SQueue::IsEmpty().

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

SReference IntelibGenericReader::Get  )  [inherited]
 

Get the next expression constructed by the reader.

If there's an expression (that is, if IsReady() method returns true), Get() returns the first expression and removes it from the internal buffer. The behaviour is undefined if you call Get() when IsReady() returns false.

Definition at line 193 of file sreader.cpp.

References SReference::Car(), INTELIB_ASSERT, IntelibGenericReader::IsReady(), and SQueue::RemoveFirst().

Referenced by IntelibGenericReader::Read().

void IntelibGenericReader::Drop  )  [inherited]
 

Drop all the stored information.

Both complete expressions and incomplete lexem sequences are dropped, the lexer is reset. This can be useful, for example, if the user decides to cancel the interactive input

Definition at line 201 of file sreader.cpp.

References IntelibSLexAnalyser::Drop(), and SQueue::RemoveFirst().

SReference IntelibGenericReader::Read SStreamRef stream  )  [inherited]
 

Read one expression from the given stream.

Feeds the reader with chars read from the stream until IsReady() returns true, then returns the expression.

Warning:
This can actually take more chars from the stream than it is necessary to form a complete expression, and thus leave the reader object in an unempty state. For example, if the stream contains smth. like ``abc('', then a token will be built off the 'abc', but the char '(' will be read as well, transformed into the lexem and stored in ther incomplete expression queue.

Definition at line 209 of file sreader.cpp.

References SReference::DynamicCastGetPtr(), EOF, IntelibGenericReader::EofMarker, IntelibGenericReader::FeedChar(), IntelibGenericReader::Get(), IntelibGenericReader::IsReady(), IntelibSLexAnalyser::SetLine(), and SExpressionStreamTextInput::TellLine().


Member Data Documentation

SLabel & IntelibGenericReader::EofMarker = LexemaEof [static, inherited]
 

The end of file marker.

The object returned as an expression when the end of file is reached

Definition at line 23 of file sreader.cpp.

Referenced by IntelibGenericReader::Read().


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