HHH-14033 - SQL script parsing problem with multi-line comments

- Better handling of multi-line comments
- Restructured some internal classes to consolidate packages
- Added "system"-style SchemaToolingLogging

This commit:

- unifies handling of Antlr `-traceParser` across parsers
- adds comment crediting to Terrance Parr for the BLOCK_COMMENT lexer rule in the sql-script grammar
This commit is contained in:
Steve Ebersole 2020-05-20 07:02:20 -05:00
parent b658e903d7
commit 7dfb0fdf24
3 changed files with 27 additions and 2 deletions

View File

@ -126,6 +126,11 @@ LINE_COMMENT
}
;
/**
* Note : this comes from the great Terrance Parr (author of Antlr) -
*
* https://theantlrguy.atlassian.net/wiki/spaces/ANTLR3/pages/2687360/How+do+I+match+multi-line+comments
*/
BLOCK_COMMENT
: "/*"
( /* '\r' '\n' can be matched in one alternative or by matching

View File

@ -164,4 +164,14 @@ public class GraphParser extends GeneratedGraphParser {
);
}
}
@Override
public void traceIn(String s) throws TokenStreamException {
// nothing to do - this parser already does a good job with logging trace info
}
@Override
public void traceOut(String s) throws TokenStreamException {
// nothing to do - this parser already does a good job with logging trace info
}
}

View File

@ -293,19 +293,29 @@ public class OrderByFragmentParser extends GeneratedOrderByFragmentParser {
@Override
public void traceIn(String ruleName) {
if ( ! LOG.isTraceEnabled() ) {
return;
}
if ( inputState.guessing > 0 ) {
return;
}
String prefix = StringHelper.repeat( '-', ( traceDepth++ * 2 ) ) + "-> ";
final String prefix = StringHelper.repeat( '-', ( traceDepth++ * 2 ) ) + "-> ";
LOG.trace( prefix + ruleName );
}
@Override
public void traceOut(String ruleName) {
if ( ! LOG.isTraceEnabled() ) {
return;
}
if ( inputState.guessing > 0 ) {
return;
}
String prefix = "<-" + StringHelper.repeat( '-', ( --traceDepth * 2 ) ) + " ";
final String prefix = "<-" + StringHelper.repeat( '-', ( --traceDepth * 2 ) ) + " ";
LOG.trace( prefix + ruleName );
}