24 #ifndef DYNGENPAR_INTEGER_CATEGORIES 25 #define DYNGENPAR_INTEGER_CATEGORIES 47 static_cast<QFile *
>(
stream)->open(stdin, QIODevice::ReadOnly);
51 stream->open(QIODevice::ReadOnly);
56 if (
stream->isSequential())
69 static_cast<QFile *
>(
stream)->open(stdin, QIODevice::ReadOnly);
74 stream =
new QFile(fileName);
75 stream->open(QIODevice::ReadOnly);
81 static_cast<QBuffer *
>(
stream)->setData(bytes);
82 stream->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
90 stream =
new QBuffer(buffer);
91 stream->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
99 if (c)
return (
unsigned char)c;
else return ByteTokenNul;
120 textPos(textPosition) {}
140 if (
stream->isSequential() || (pos && lexerState.isNull()))
178 }
while (token ==
'\r');
180 textPos.countCharacter((
unsigned char) token);
we have to remap this because 0 is epsilon
const AbstractLexerStateData * data() const
void setInputString(const QString &string)
static TextPosition textPosition(const LexerState &lexerState)
Retrieves the text position (line and column) stored in the lexer state.
void setInputFile(const QString &fileName)
void setInputBytes(const QByteArray &bytes)
Q_DECLARE_TYPEINFO(ByteTokens, Q_PRIMITIVE_TYPE)
virtual Cat readToken()
Overrides readToken to strip CRs.
virtual Cat readToken()
get the next token from the input, to be implemented by subclasses
QString Cat
Category type: string or integer depending on DYNGENPAR_INTEGER_CATEGORIES.
TextByteTokenSource(const QString &fileName)
ByteTokenSource(const QString &fileName)
You should not have to use this class directly, ever.
bool simpleRewind(int pos, bool rewindOnly=false)
basic implementation of rewindTo for subclasses which support it
TextByteLexerStateData(qint64 streamPosition, TextPosition textPosition)
virtual bool rewindTo(int pos, const LexerState &=LexerState())
rewind to an older position (requires buffering)
virtual ~TextByteTokenSource()
API for stateful lexers to save their state for rewinding.
virtual ~ByteTokenSource()
Node tree
sub-parse-tree for hierarchical parsing
virtual AbstractLexerStateData * clone()
virtual bool rewindTo(int pos, const LexerState &=LexerState())
rewind to an older position (requires buffering)
virtual bool rewindTo(int pos, const LexerState &lexerState=LexerState())
We can only rewind if we have a lexer state with the true position.
void setInputBuffer(QByteArray *buffer)
virtual LexerState saveState()
Saves the true stream position (including CRs) and the text position in lines and columns into a lexe...