Skip to content

Commit

Permalink
Debug to error stream, not out stream, as in java & csharp
Browse files Browse the repository at this point in the history
Signed-off-by: mmazas <[email protected]>
  • Loading branch information
mmazas authored and mmazas committed Sep 4, 2024
1 parent af3ba87 commit c3a4a0f
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ int ${parserName}TokenManager::jjRunStringLiteralMatch() {
int ignoreCase = (int) stringLiterals[index++];
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(Looking for string literal match of kind: ) << stringLiterals[index + len]
JJERR << JJWIDE(Looking for string literal match of kind: ) << stringLiterals[index + len]
<< JJSPACE << JJWIDE(token image:) << JJSPACE
<< JJQUOTE << addUnicodeEscapes(tokenImages[stringLiterals[index + len]]) << JJQUOTE << std::endl;
}
#fi
do {
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJSPACE << JJSPACE << JJWIDE(Current character:) << JJSPACE << JJQUOTE << ((char)curChar) << JJQUOTE << std::endl;
JJERR << JJSPACE << JJSPACE << JJWIDE(Current character:) << JJSPACE << JJQUOTE << ((char)curChar) << JJQUOTE << std::endl;
}
#fi
if (curChar != stringLiterals[index + curPos] &&
Expand All @@ -100,7 +100,7 @@ int ${parserName}TokenManager::jjRunStringLiteralMatch() {
startState = (int) stringLiterals[index + len + (ignoreCase * len) + 1];
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJSPACE << JJSPACE
JJERR << JJSPACE << JJSPACE
<< JJWIDE(Currently matched the first:) << JJSPACE << jjmatchedPos << JJSPACE
<< JJWIDE(chars as kind:) << JJSPACE << stringLiterals[index + len] << JJCOMMA
<< JJWIDE(with image:) << JJSPACE << addUnicodeEscapes(tokenImages[jjmatchedKind]) << std::endl;
Expand All @@ -123,7 +123,7 @@ int ${parserName}TokenManager::jjRunStringLiteralMatch() {
} else {
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(No string literal start with char:) << JJSPACE << JJQUOTE << ((char)curChar) << JJQUOTE << std::endl;
JJERR << JJWIDE(No string literal start with char:) << JJSPACE << JJQUOTE << ((char)curChar) << JJQUOTE << std::endl;
}
#fi
}
Expand All @@ -136,7 +136,7 @@ int ${parserName}TokenManager::jjMoveNfa(int startState, int curPos) {
if (startState < 0) {
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(No NFA state at pos:) << JJSPACE << curPos << std::endl;
JJERR << JJWIDE(No NFA state at pos:) << JJSPACE << curPos << std::endl;
}
#fi
return curPos;
Expand Down Expand Up @@ -178,13 +178,13 @@ int ${parserName}TokenManager::jjMoveNfa(int startState, int curPos) {

#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(Starting NFA with start state:) << JJSPACE << startState << std::endl;
JJERR << JJWIDE(Starting NFA with start state:) << JJSPACE << startState << std::endl;
}
#fi
do {
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJSPACE << JJSPACE << JJWIDE(Current character:) << JJSPACE << JJQUOTE << (char)curChar << JJQUOTE << std::endl;
JJERR << JJSPACE << JJSPACE << JJWIDE(Current character:) << JJSPACE << JJQUOTE << (char)curChar << JJQUOTE << std::endl;
}
#fi
int newCnt = 0;
Expand All @@ -201,11 +201,11 @@ int ${parserName}TokenManager::jjMoveNfa(int startState, int curPos) {
int state = stateSet[--cnt];
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(Looking to move from state: ) << JJSPACE << state << JJSPACE << JJWIDE(for:) << JJSPACE
JJERR << JJWIDE(Looking to move from state: ) << JJSPACE << state << JJSPACE << JJWIDE(for:) << JJSPACE
<< (jjmatchKinds[state] != INT_MAX
? addUnicodeEscapes(tokenImages[jjmatchKinds[state]]) : JJWIDE( <UNKNOWN>))
<< std::endl;
JJLOG << "state=" << state << " vectorindex=" << vectorIndex << " bitpattern=" << bitpattern
JJERR << "state=" << state << " vectorindex=" << vectorIndex << " bitpattern=" << bitpattern
<< " jjChars[state][vectorIndex]=" << jjChars[state][vectorIndex] << std::endl;
}
#fi
Expand All @@ -228,7 +228,7 @@ int ${parserName}TokenManager::jjMoveNfa(int startState, int curPos) {
kind = newKind;
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(Found a match of kind: ) << kind << JJWIDE(; kind: ) << JJSPACE
JJERR << JJWIDE(Found a match of kind: ) << kind << JJWIDE(; kind: ) << JJSPACE
<< addUnicodeEscapes(tokenLabels[kind]) << JJSPACE << JJWIDE(using the first:) << JJSPACE
<< curPos << JJSPACE << JJWIDE(characters.) << std::endl;
}
Expand Down Expand Up @@ -260,7 +260,7 @@ int ${parserName}TokenManager::jjMoveNfa(int startState, int curPos) {
// current input. So we are done.
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(Done with NFA at pos: ) << JJSPACE << curPos << std::endl;
JJERR << JJWIDE(Done with NFA at pos: ) << JJSPACE << curPos << std::endl;
}
#fi
return curPos;
Expand All @@ -270,7 +270,7 @@ int ${parserName}TokenManager::jjMoveNfa(int startState, int curPos) {
// EOF reached!
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(Reached EOF here at pos: ) << JJSPACE << curPos << std::endl;
JJERR << JJWIDE(Reached EOF here at pos: ) << JJSPACE << curPos << std::endl;
}
#fi
return curPos;
Expand Down Expand Up @@ -355,7 +355,7 @@ Token * ${parserName}TokenManager::getNextToken() {
if(input_stream->endOfInput()) {
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(<) << addUnicodeEscapes(lexStateNames[curLexState]) << JJWIDE(> ) << JJSPACE
JJERR << JJWIDE(<) << addUnicodeEscapes(lexStateNames[curLexState]) << JJWIDE(> ) << JJSPACE
<< JJWIDE(Reached EOF at ) << JJSPACE << input_stream->getBeginLine()
<< JJWIDE(:) << input_stream->getBeginColumn() << std::endl;
}
Expand All @@ -376,7 +376,7 @@ Token * ${parserName}TokenManager::getNextToken() {

#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(<) << addUnicodeEscapes(lexStateNames[curLexState]) << JJWIDE(>) << std::endl
JJERR << JJWIDE(<) << addUnicodeEscapes(lexStateNames[curLexState]) << JJWIDE(>) << std::endl
<< JJSPACE << JJSPACE << JJWIDE( Current character:) << JJSPACE << JJQUOTE << (char)curChar << JJQUOTE << JJSPACE
<< JJWIDE( at ) << JJSPACE << input_stream->getBeginLine()
<< JJWIDE(:) << input_stream->getBeginColumn() << std::endl;
Expand All @@ -401,7 +401,7 @@ Token * ${parserName}TokenManager::getNextToken() {
jjmatchedKind = canMatchAnyChar[curLexState];
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(Matched current char:) << JJSPACE << JJQUOTE << (char)curChar << JJQUOTE << JJSPACE
JJERR << JJWIDE(Matched current char:) << JJSPACE << JJQUOTE << (char)curChar << JJQUOTE << JJSPACE
<< JJWIDE(as a wildcard kind:) << JJSPACE << jjmatchedKind
<< std::endl;
}
Expand All @@ -426,7 +426,7 @@ Token * ${parserName}TokenManager::getNextToken() {
#fi
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(Returning token:) << JJSPACE << JJQUOTE
JJERR << JJWIDE(Returning token:) << JJSPACE << JJQUOTE
<< addUnicodeEscapes(matchedToken->image()) << JJQUOTE << JJSPACE
<< std::endl;
}
Expand All @@ -436,7 +436,7 @@ Token * ${parserName}TokenManager::getNextToken() {
if (isSkip(jjmatchedKind) || isSpecial(jjmatchedKind)) {
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(Found a SKIP match.) << std::endl;
JJERR << JJWIDE(Found a SKIP match.) << std::endl;
}
#fi
// Matched kind is a SKIP or SPECIAL_TOKEN.
Expand All @@ -459,7 +459,7 @@ Token * ${parserName}TokenManager::getNextToken() {
}
#if DEBUG_TOKEN_MANAGER
if (trace_enabled()) {
JJLOG << JJWIDE(Found a MORE match.) << std::endl;
JJERR << JJWIDE(Found a MORE match.) << std::endl;
}
#fi
// Here it's a MORE.
Expand Down

0 comments on commit c3a4a0f

Please sign in to comment.