mirror of
https://github.com/cwbaker/lalr.git
synced 2026-09-26 16:33:18 +03:00
Use correct string for lexeme when debugging parsers
This works for UTF-8 encoded strings but debugging will fail when using UTF-16 or UTF-32 as the printf() formatted string won't deal with null characters embedded within the wider character encodings. Committing this for now because it doesn't break any existing functionality but does enable parsing of wider character inputs.
This commit is contained in:
parent
1f85c9d00a
commit
d03a02d3e5
1 changed files with 4 additions and 4 deletions
|
|
@ -494,7 +494,7 @@ void Parser<Iterator, UserData, Char, Traits, Allocator>::debug_shift( const Par
|
|||
if ( debug_enabled_ )
|
||||
{
|
||||
const ParserSymbol* symbol = node.symbol();
|
||||
const std::string& lexeme = node.lexeme();
|
||||
const std::basic_string<Char, Traits, Allocator>& lexeme = node.lexeme();
|
||||
int line = node.line();
|
||||
int column = node.column();
|
||||
fire_printf( "SHIFT: (%s %s %d:%d)\n", symbol ? symbol->identifier : "", lexeme.c_str(), line, column );
|
||||
|
|
@ -521,14 +521,14 @@ void Parser<Iterator, UserData, Char, Traits, Allocator>::debug_reduce( const Pa
|
|||
|
||||
if ( debug_enabled_ )
|
||||
{
|
||||
fire_printf( "REDUCE: %s <- ", reduced_symbol->identifier );
|
||||
fire_printf( "REDUCE: %s <- ", reduced_symbol->identifier );
|
||||
|
||||
const ParserNode* node = nodes_.data() + start;
|
||||
const ParserNode* node_end = nodes_.data() + finish;
|
||||
if ( node != node_end )
|
||||
{
|
||||
const ParserSymbol* symbol = node->symbol();
|
||||
const std::string& lexeme = node->lexeme();
|
||||
const std::basic_string<Char, Traits, Allocator>& lexeme = node->lexeme();
|
||||
int line = node->line();
|
||||
int column = node->column();
|
||||
fire_printf( "(%s %s %d:%d)", symbol ? symbol->identifier : "", lexeme.c_str(), line, column );
|
||||
|
|
@ -538,7 +538,7 @@ void Parser<Iterator, UserData, Char, Traits, Allocator>::debug_reduce( const Pa
|
|||
while ( node != node_end )
|
||||
{
|
||||
const ParserSymbol* symbol = node->symbol();
|
||||
const std::string& lexeme = node->lexeme();
|
||||
const std::basic_string<Char, Traits, Allocator>& lexeme = node->lexeme();
|
||||
int line = node->line();
|
||||
int column = node->column();
|
||||
fire_printf( " (%s %s %d:%d)", symbol ? symbol->identifier : "", lexeme.c_str(), line, column );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue