mirror of
https://github.com/cwbaker/lalr.git
synced 2026-09-26 16:33:18 +03:00
Move Parser::fire_{error,print}() and Parser::is_debug_enabled() to const member section
This commit is contained in:
parent
b7b7c4d61e
commit
e56556f390
2 changed files with 67 additions and 69 deletions
|
|
@ -68,18 +68,16 @@ public:
|
|||
bool full() const;
|
||||
const UserData& user_data() const;
|
||||
const Lexer<Iterator, Char, Traits, Allocator>& lexer() const;
|
||||
void fire_error(int line, int column, int error, const char* format, ... ) const;
|
||||
void fire_printf( const char* format, ... ) const;
|
||||
bool is_debug_enabled() const;
|
||||
|
||||
AddParserActionHandler<Iterator, UserData, Char, Traits, Allocator> parser_action_handlers();
|
||||
AddLexerActionHandler<Iterator, Char, Traits, Allocator> lexer_action_handlers();
|
||||
void set_default_action_handler( ParserActionFunction function );
|
||||
void set_action_handler( const char* identifier, ParserActionFunction function );
|
||||
void set_lexer_action_handler( const char* identifier, LexerActionFunction function );
|
||||
|
||||
void fire_error(int line, int column, int error, const char* format, ... ) const;
|
||||
void fire_printf( const char* format, ... ) const;
|
||||
|
||||
void set_lexer_action_handler( const char* identifier, LexerActionFunction function );
|
||||
void set_debug_enabled( bool debug_enabled );
|
||||
bool is_debug_enabled() const;
|
||||
|
||||
private:
|
||||
const ParserTransition* find_transition( const ParserSymbol* symbol, const ParserState* state ) const;
|
||||
|
|
|
|||
|
|
@ -254,6 +254,69 @@ const Lexer<Iterator, Char, Traits, Allocator>& Parser<Iterator, UserData, Char,
|
|||
return lexer_;
|
||||
}
|
||||
|
||||
/**
|
||||
// Fire an %error event.
|
||||
//
|
||||
// @param line
|
||||
// The line number to associate with the %error (or 0 if there is no line
|
||||
// to associate with the %error).
|
||||
//
|
||||
// @param error
|
||||
// The %Error that describes the %error that has occured.
|
||||
*/
|
||||
template <class Iterator, class UserData, class Char, class Traits, class Allocator>
|
||||
void Parser<Iterator, UserData, Char, Traits, Allocator>::fire_error( int line, int column, int error, const char* format, ... ) const
|
||||
{
|
||||
if ( error_policy_ )
|
||||
{
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
error_policy_->lalr_error( line, column, error, format, args );
|
||||
va_end( args );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
// Fire a printf event.
|
||||
//
|
||||
// @param format
|
||||
// A printf style format string that describes the message to print.
|
||||
//
|
||||
// @param ...
|
||||
// Parameters to fill in the message as specified by \e format.
|
||||
*/
|
||||
template <class Iterator, class UserData, class Char, class Traits, class Allocator>
|
||||
void Parser<Iterator, UserData, Char, Traits, Allocator>::fire_printf( const char* format, ... ) const
|
||||
{
|
||||
if ( error_policy_ )
|
||||
{
|
||||
LALR_ASSERT( format );
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
error_policy_->lalr_vprintf( format, args );
|
||||
va_end( args );
|
||||
}
|
||||
else
|
||||
{
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
vfprintf( stdout, format, args );
|
||||
va_end( args );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
// Are shift and reduce operations printed?
|
||||
//
|
||||
// @return
|
||||
// True if shift and reduce operations are printed otherwise false.
|
||||
*/
|
||||
template <class Iterator, class UserData, class Char, class Traits, class Allocator>
|
||||
bool Parser<Iterator, UserData, Char, Traits, Allocator>::is_debug_enabled() const
|
||||
{
|
||||
return debug_enabled_;
|
||||
}
|
||||
|
||||
/**
|
||||
// Add action handlers to this %Parser.
|
||||
//
|
||||
|
|
@ -337,57 +400,6 @@ void Parser<Iterator, UserData, Char, Traits, Allocator>::set_lexer_action_handl
|
|||
lexer_.set_action_handler( identifier, function );
|
||||
}
|
||||
|
||||
/**
|
||||
// Fire an %error event.
|
||||
//
|
||||
// @param line
|
||||
// The line number to associate with the %error (or 0 if there is no line
|
||||
// to associate with the %error).
|
||||
//
|
||||
// @param error
|
||||
// The %Error that describes the %error that has occured.
|
||||
*/
|
||||
template <class Iterator, class UserData, class Char, class Traits, class Allocator>
|
||||
void Parser<Iterator, UserData, Char, Traits, Allocator>::fire_error( int line, int column, int error, const char* format, ... ) const
|
||||
{
|
||||
if ( error_policy_ )
|
||||
{
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
error_policy_->lalr_error( line, column, error, format, args );
|
||||
va_end( args );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
// Fire a printf event.
|
||||
//
|
||||
// @param format
|
||||
// A printf style format string that describes the message to print.
|
||||
//
|
||||
// @param ...
|
||||
// Parameters to fill in the message as specified by \e format.
|
||||
*/
|
||||
template <class Iterator, class UserData, class Char, class Traits, class Allocator>
|
||||
void Parser<Iterator, UserData, Char, Traits, Allocator>::fire_printf( const char* format, ... ) const
|
||||
{
|
||||
if ( error_policy_ )
|
||||
{
|
||||
LALR_ASSERT( format );
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
error_policy_->lalr_vprintf( format, args );
|
||||
va_end( args );
|
||||
}
|
||||
else
|
||||
{
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
vfprintf( stdout, format, args );
|
||||
va_end( args );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
// Set whether or not shift operations are printed.
|
||||
//
|
||||
|
|
@ -401,18 +413,6 @@ void Parser<Iterator, UserData, Char, Traits, Allocator>::set_debug_enabled( boo
|
|||
debug_enabled_ = debug_enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
// Are shift and reduce operations printed?
|
||||
//
|
||||
// @return
|
||||
// True if shift and reduce operations are printed otherwise false.
|
||||
*/
|
||||
template <class Iterator, class UserData, class Char, class Traits, class Allocator>
|
||||
bool Parser<Iterator, UserData, Char, Traits, Allocator>::is_debug_enabled() const
|
||||
{
|
||||
return debug_enabled_;
|
||||
}
|
||||
|
||||
/**
|
||||
// Find the Transition for \e symbol in \e state.
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue