DynGenPar
Dynamic Generalized Parser
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DynGenPar::ByteTokenSource Class Reference
Inheritance diagram for DynGenPar::ByteTokenSource:
Inheritance graph

Public Member Functions

 ByteTokenSource ()
 
 ByteTokenSource (const QString &fileName)
 
virtual ~ByteTokenSource ()
 
virtual bool rewindTo (int pos, const LexerState &=LexerState())
 rewind to an older position (requires buffering) More...
 
void setInputStdin ()
 
void setInputFile (const QString &fileName)
 
void setInputBytes (const QByteArray &bytes)
 
void setInputString (const QString &string)
 
void setInputBuffer (QByteArray *buffer)
 
- Public Member Functions inherited from DynGenPar::TokenSource
 TokenSource ()
 
virtual ~TokenSource ()
 
Cat nextToken ()
 get the next token from the input, increment current position, save parse tree More...
 
Node parseTree ()
 get the parse tree for the last shifted token More...
 
virtual bool matchParseTree (const Node &treeToMatch)
 match the parse tree for the last shifted token against the given tree More...
 
int currentPosition ()
 get the current input position More...
 
bool rewindTo (int pos, const Node &parseTree, const LexerState &lexerState=LexerState())
 rewind to an older position (requires buffering) and restore the parse tree (needed for lookahead) More...
 
virtual LexerState saveState ()
 saves the current lexer state, by default a null LexerState More...
 

Protected Member Functions

virtual Cat readToken ()
 get the next token from the input, to be implemented by subclasses More...
 
virtual void reset ()
 
- Protected Member Functions inherited from DynGenPar::TokenSource
bool simpleRewind (int pos, bool rewindOnly=false)
 basic implementation of rewindTo for subclasses which support it More...
 

Protected Attributes

QIODevice * stream
 
- Protected Attributes inherited from DynGenPar::TokenSource
int currPos
 
Node tree
 sub-parse-tree for hierarchical parsing More...
 

Detailed Description

Definition at line 44 of file bytetokensource.h.

Constructor & Destructor Documentation

◆ ByteTokenSource() [1/2]

DynGenPar::ByteTokenSource::ByteTokenSource ( )
inline

Definition at line 46 of file bytetokensource.h.

◆ ByteTokenSource() [2/2]

DynGenPar::ByteTokenSource::ByteTokenSource ( const QString &  fileName)
inline

Definition at line 49 of file bytetokensource.h.

◆ ~ByteTokenSource()

virtual DynGenPar::ByteTokenSource::~ByteTokenSource ( )
inlinevirtual

Definition at line 53 of file bytetokensource.h.

Member Function Documentation

◆ readToken()

virtual Cat DynGenPar::ByteTokenSource::readToken ( )
inlineprotectedvirtual

get the next token from the input, to be implemented by subclasses

Implements DynGenPar::TokenSource.

Reimplemented in DynGenPar::TextByteTokenSource.

Definition at line 95 of file bytetokensource.h.

◆ reset()

virtual void DynGenPar::ByteTokenSource::reset ( )
inlineprotectedvirtual

Reimplemented in DynGenPar::TextByteTokenSource.

Definition at line 102 of file bytetokensource.h.

◆ rewindTo()

virtual bool DynGenPar::ByteTokenSource::rewindTo ( int  pos,
const LexerState = LexerState() 
)
inlinevirtual

rewind to an older position (requires buffering)

Returns
true if successful, false otherwise

in all cases, destroys the saved parse tree

By default, only succeeds if the position is the current one, otherwise always returns false. Can be overridden by subclasses.

Some subclasses (e.g., file-backed ones) can wind both forward and backward, some can only rewind, some cannot wind at all. The method will return false if seeking to the new position is not possible.

Reimplemented from DynGenPar::TokenSource.

Reimplemented in DynGenPar::TextByteTokenSource.

Definition at line 54 of file bytetokensource.h.

◆ setInputBuffer()

void DynGenPar::ByteTokenSource::setInputBuffer ( QByteArray *  buffer)
inline

Definition at line 88 of file bytetokensource.h.

◆ setInputBytes()

void DynGenPar::ByteTokenSource::setInputBytes ( const QByteArray &  bytes)
inline

Definition at line 78 of file bytetokensource.h.

◆ setInputFile()

void DynGenPar::ByteTokenSource::setInputFile ( const QString &  fileName)
inline

Definition at line 72 of file bytetokensource.h.

◆ setInputStdin()

void DynGenPar::ByteTokenSource::setInputStdin ( )
inline

Definition at line 66 of file bytetokensource.h.

◆ setInputString()

void DynGenPar::ByteTokenSource::setInputString ( const QString &  string)
inline

Definition at line 85 of file bytetokensource.h.

Member Data Documentation

◆ stream

QIODevice* DynGenPar::ByteTokenSource::stream
protected

Definition at line 101 of file bytetokensource.h.


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