mirror of
https://github.com/cwbaker/lalr.git
synced 2026-09-26 16:33:18 +03:00
Move Lexer::set_action_handler() to non-const member section
This commit is contained in:
parent
5ce357e651
commit
b7b7c4d61e
2 changed files with 38 additions and 38 deletions
|
|
@ -48,13 +48,13 @@ class Lexer
|
|||
|
||||
public:
|
||||
Lexer( const LexerStateMachine* state_machine, const LexerStateMachine* whitespace_state_machine = nullptr, const void* end_symbol = nullptr, ErrorPolicy* error_policy = nullptr );
|
||||
void set_action_handler( const char* identifier, LexerActionFunction function );
|
||||
const std::basic_string<Char, Traits, Allocator>& lexeme() const;
|
||||
int line() const;
|
||||
int column() const;
|
||||
const void* symbol() const;
|
||||
const Iterator& position() const;
|
||||
bool full() const;
|
||||
void set_action_handler( const char* identifier, LexerActionFunction function );
|
||||
void reset( Iterator start, Iterator finish );
|
||||
void advance();
|
||||
|
||||
|
|
|
|||
|
|
@ -88,43 +88,6 @@ Lexer<Iterator, Char, Traits, Allocator>::Lexer( const LexerStateMachine* state_
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
// Set the action handler for \e identifier to \e function.
|
||||
//
|
||||
// @param identifier
|
||||
// The identifier of the action to set a handler for.
|
||||
//
|
||||
// @param function
|
||||
// The function to set as the handler.
|
||||
*/
|
||||
template <class Iterator, class Char, class Traits, class Allocator>
|
||||
void Lexer<Iterator, Char, Traits, Allocator>::set_action_handler( const char* identifier, LexerActionFunction function )
|
||||
{
|
||||
LALR_ASSERT( identifier );
|
||||
|
||||
typename std::vector<LexerActionHandler>::iterator action_handler = action_handlers_.begin();
|
||||
while ( action_handler != action_handlers_.end() && strcmp(action_handler->action_->identifier, identifier) != 0 )
|
||||
{
|
||||
++action_handler;
|
||||
}
|
||||
|
||||
if ( action_handler != action_handlers_.end() )
|
||||
{
|
||||
action_handler->function_ = function;
|
||||
}
|
||||
|
||||
action_handler = whitespace_action_handlers_.begin();
|
||||
while ( action_handler != whitespace_action_handlers_.end() && strcmp(action_handler->action_->identifier, identifier) != 0 )
|
||||
{
|
||||
++action_handler;
|
||||
}
|
||||
|
||||
if ( action_handler != whitespace_action_handlers_.end() )
|
||||
{
|
||||
action_handler->function_ = function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
// Get the most recently scanned lexeme.
|
||||
//
|
||||
|
|
@ -197,6 +160,43 @@ bool Lexer<Iterator, Char, Traits, Allocator>::full() const
|
|||
return full_;
|
||||
}
|
||||
|
||||
/**
|
||||
// Set the action handler for \e identifier to \e function.
|
||||
//
|
||||
// @param identifier
|
||||
// The identifier of the action to set a handler for.
|
||||
//
|
||||
// @param function
|
||||
// The function to set as the handler.
|
||||
*/
|
||||
template <class Iterator, class Char, class Traits, class Allocator>
|
||||
void Lexer<Iterator, Char, Traits, Allocator>::set_action_handler( const char* identifier, LexerActionFunction function )
|
||||
{
|
||||
LALR_ASSERT( identifier );
|
||||
|
||||
typename std::vector<LexerActionHandler>::iterator action_handler = action_handlers_.begin();
|
||||
while ( action_handler != action_handlers_.end() && strcmp(action_handler->action_->identifier, identifier) != 0 )
|
||||
{
|
||||
++action_handler;
|
||||
}
|
||||
|
||||
if ( action_handler != action_handlers_.end() )
|
||||
{
|
||||
action_handler->function_ = function;
|
||||
}
|
||||
|
||||
action_handler = whitespace_action_handlers_.begin();
|
||||
while ( action_handler != whitespace_action_handlers_.end() && strcmp(action_handler->action_->identifier, identifier) != 0 )
|
||||
{
|
||||
++action_handler;
|
||||
}
|
||||
|
||||
if ( action_handler != whitespace_action_handlers_.end() )
|
||||
{
|
||||
action_handler->function_ = function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
// Reset this %Lexer to scan [\e start, \e finish) starting its line count
|
||||
// from \e line.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue