Skip to content

Commit

Permalink
Merge pull request #48 from vladimirralev/issue46
Browse files Browse the repository at this point in the history
Fix for #46 debug counter not…
  • Loading branch information
vladimirralev authored Jan 24, 2019
2 parents beaefa3 + 60a7e27 commit d49c03f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/gov/nist/core/ParserCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package gov.nist.core;

import java.text.ParseException;
import java.util.concurrent.atomic.AtomicInteger;

/** Generic parser class.
* All parsers inherit this class.
Expand All @@ -40,7 +41,7 @@
public abstract class ParserCore {
public static final boolean debug = Debug.parserDebug;

static volatile int nesting_level;
static AtomicInteger nesting_level;

protected LexerCore lexer;

Expand Down Expand Up @@ -99,7 +100,7 @@ protected NameValue nameValue(char separator) throws ParseException {

protected void dbg_enter(String rule) {
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < nesting_level ; i++)
for (int i = 0; i < nesting_level.get() ; i++)
stringBuilder.append(">");

if (debug) {
Expand All @@ -108,12 +109,12 @@ protected void dbg_enter(String rule) {
"\nlexer buffer = \n" +
lexer.getRest());
}
nesting_level++;
nesting_level.incrementAndGet();
}

protected void dbg_leave(String rule) {
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < nesting_level ; i++)
for (int i = 0; i < nesting_level.get() ; i++)
stringBuilder.append("<");

if (debug) {
Expand All @@ -123,7 +124,7 @@ protected void dbg_leave(String rule) {
"\nlexer buffer = \n" +
lexer.getRest());
}
nesting_level --;
nesting_level.decrementAndGet();
}

protected NameValue nameValue() throws ParseException {
Expand Down

0 comments on commit d49c03f

Please sign in to comment.