ANTLR Support Libraries 2.7.1+
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
LLkParser Class Reference

#include <LLkParser.hpp>

Inheritance diagram for LLkParser:
Inheritance graph
[legend]
Collaboration diagram for LLkParser:
Collaboration graph
[legend]

Public Member Functions

 LLkParser (const ParserSharedInputState &lexer, int k_)
 
 LLkParser (TokenBuffer &tokenBuf, int k_)
 
 LLkParser (TokenStream &lexer, int k_)
 
virtual void consume ()
 
virtual int LA (unsigned int i)
 
virtual RefToken LT (unsigned int i)
 Return the i-th token of lookahead.
 
virtual void traceIn (const char *rname)
 
virtual void traceOut (const char *rname)
 
- Public Member Functions inherited from Parser
virtual ~Parser ()
 
virtual int LA (unsigned int i)=0
 
virtual RefToken LT (unsigned int i)=0
 Return the i-th token of lookahead.
 
virtual void setASTNodeFactory (ASTFactory *factory)
 
virtual void setASTFactory (ASTFactory *factory)
 
virtual ASTFactorygetASTFactory ()
 
virtual RefAST getAST ()=0
 
virtual std::string getFilename () const
 Return the filename of the input file.
 
virtual void setFilename (const std ::string &f)
 Set the filename of the input file (used for error reporting).
 
virtual void setInputState (ParserSharedInputState state)
 
virtual ParserSharedInputState getInputState () const
 
virtual void consume ()=0
 Get another token object from the token stream.
 
virtual void consumeUntil (int tokenType)
 Consume tokens until one matches the given token.
 
virtual void consumeUntil (const BitSet &set)
 Consume tokens until one matches the given token set.
 
virtual void match (int t)
 
virtual void matchNot (int t)
 
virtual void match (const BitSet &b)
 
virtual unsigned int mark ()
 
virtual void rewind (unsigned int pos)
 rewind to a previously marked position
 
virtual void recover (const RecognitionException &ex, const BitSet &tokenSet)
 
virtual void reportError (const RecognitionException &ex)
 Parser error-reporting function can be overridden in subclass.
 
virtual void reportError (const std ::string &s)
 Parser error-reporting function can be overridden in subclass.
 
virtual void reportWarning (const std ::string &s)
 Parser warning-reporting function can be overridden in subclass.
 
virtual const char * getTokenName (int num) const =0
 get the token name for the token number 'num'
 
virtual const char *const * getTokenNames () const =0
 get a vector with all token names
 
virtual int getNumTokens (void) const =0
 
virtual void traceIndent ()
 
virtual void traceIn (const char *rname)
 
virtual void traceOut (const char *rname)
 

Protected Attributes

int k
 the lookahead this LL(k) parser is using.
 
- Protected Attributes inherited from Parser
ParserSharedInputState inputState
 
ASTFactoryastFactory
 AST support code; parser and treeparser delegate to this object.
 
int traceDepth
 

Private Member Functions

void trace (const char *ee, const char *rname)
 

Additional Inherited Members

- Protected Member Functions inherited from Parser
 Parser (TokenBuffer &input)
 
 Parser (TokenBuffer *input)
 
 Parser (const ParserSharedInputState &state)
 

Detailed Description

An LL(k) parser.

See also
antlr.Token
antlr.TokenBuffer
antlr.LL1Parser

Constructor & Destructor Documentation

◆ LLkParser() [1/3]

LLkParser::LLkParser ( const ParserSharedInputState state,
int  k_ 
)

An LL(k) parser.

See also
antlr.Token
antlr.TokenBuffer
antlr.LL1Parser

◆ LLkParser() [2/3]

LLkParser::LLkParser ( TokenBuffer tokenBuf,
int  k_ 
)

◆ LLkParser() [3/3]

LLkParser::LLkParser ( TokenStream lexer,
int  k_ 
)

Member Function Documentation

◆ consume()

virtual void LLkParser::consume ( )
inlinevirtual

Consume another token from the input stream. Can only write sequentially! If you need 3 tokens ahead, you must consume() 3 times.

Note that it is possible to overwrite tokens that have not been matched. For example, calling consume() 3 times when k=2, means that the first token consumed will be overwritten with the 3rd.

Implements Parser.

◆ LA()

virtual int LLkParser::LA ( unsigned int  i)
inlinevirtual

Return the token type of the ith token of lookahead where i=1 is the current token being examined by the parser (i.e., it has not been matched yet).

Implements Parser.

◆ LT()

virtual RefToken LLkParser::LT ( unsigned int  i)
inlinevirtual

Return the i-th token of lookahead.

Implements Parser.

◆ trace()

void LLkParser::trace ( const char *  ee,
const char *  rname 
)
private

◆ traceIn()

void LLkParser::traceIn ( const char *  rname)
virtual

Reimplemented from Parser.

◆ traceOut()

void LLkParser::traceOut ( const char *  rname)
virtual

Reimplemented from Parser.

Member Data Documentation

◆ k

int LLkParser::k
protected

the lookahead this LL(k) parser is using.


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