parser: print backtrace only in debug mode
parent
0a6840b6a6
commit
f8d14a216b
|
@ -27,8 +27,6 @@ fn (p mut Parser) warn(s string) {
|
||||||
p.warn_with_token_index(s, p.token_idx-1 )
|
p.warn_with_token_index(s, p.token_idx-1 )
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
fn (p mut Parser) production_error_with_token_index(e string, tokenindex int) {
|
fn (p mut Parser) production_error_with_token_index(e string, tokenindex int) {
|
||||||
if p.pref.is_prod {
|
if p.pref.is_prod {
|
||||||
p.error_with_token_index( e, tokenindex )
|
p.error_with_token_index( e, tokenindex )
|
||||||
|
@ -37,8 +35,6 @@ fn (p mut Parser) production_error_with_token_index(e string, tokenindex int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
fn (p mut Parser) error_with_token_index(s string, tokenindex int) {
|
fn (p mut Parser) error_with_token_index(s string, tokenindex int) {
|
||||||
p.error_with_position(s, p.scanner.get_scanner_pos_of_token( p.tokens[ tokenindex ] ) )
|
p.error_with_position(s, p.scanner.get_scanner_pos_of_token( p.tokens[ tokenindex ] ) )
|
||||||
}
|
}
|
||||||
|
@ -47,8 +43,6 @@ fn (p mut Parser) warn_with_token_index(s string, tokenindex int) {
|
||||||
p.warn_with_position(s, p.scanner.get_scanner_pos_of_token( p.tokens[ tokenindex ] ) )
|
p.warn_with_position(s, p.scanner.get_scanner_pos_of_token( p.tokens[ tokenindex ] ) )
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
fn (p mut Parser) error_with_position(s string, sp ScannerPos) {
|
fn (p mut Parser) error_with_position(s string, sp ScannerPos) {
|
||||||
p.print_error_context()
|
p.print_error_context()
|
||||||
e := normalized_error( s )
|
e := normalized_error( s )
|
||||||
|
@ -65,8 +59,6 @@ fn (p mut Parser) warn_with_position(s string, sp ScannerPos) {
|
||||||
p.scanner.goto_scanner_position( cpos )
|
p.scanner.goto_scanner_position( cpos )
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
fn (s &Scanner) error(msg string) {
|
fn (s &Scanner) error(msg string) {
|
||||||
s.error_with_col(msg, 0)
|
s.error_with_col(msg, 0)
|
||||||
}
|
}
|
||||||
|
@ -75,7 +67,6 @@ fn (s &Scanner) warn(msg string) {
|
||||||
s.warn_with_col(msg, 0)
|
s.warn_with_col(msg, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
fn (s &Scanner) warn_with_col(msg string, col int) {
|
fn (s &Scanner) warn_with_col(msg string, col int) {
|
||||||
fullpath := s.get_error_filepath()
|
fullpath := s.get_error_filepath()
|
||||||
color_on := s.is_color_output_on()
|
color_on := s.is_color_output_on()
|
||||||
|
|
|
@ -717,7 +717,9 @@ fn (p mut Parser) check(expected TokenKind) {
|
||||||
s := 'expected `${expected.str()}` but got `${p.strtok()}`'
|
s := 'expected `${expected.str()}` but got `${p.strtok()}`'
|
||||||
p.next()
|
p.next()
|
||||||
println('next token = `${p.strtok()}`')
|
println('next token = `${p.strtok()}`')
|
||||||
|
if p.pref.is_debug {
|
||||||
print_backtrace()
|
print_backtrace()
|
||||||
|
}
|
||||||
p.error(s)
|
p.error(s)
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue