forked from jasder/antlr
Add the "verifyATN" deserialization option
This commit is contained in:
parent
affbe51077
commit
c4c2546fc9
|
@ -44,11 +44,14 @@ public class ATNDeserializationOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean readOnly;
|
private boolean readOnly;
|
||||||
|
private boolean verifyATN;
|
||||||
|
|
||||||
public ATNDeserializationOptions() {
|
public ATNDeserializationOptions() {
|
||||||
|
this.verifyATN = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ATNDeserializationOptions(ATNDeserializationOptions options) {
|
public ATNDeserializationOptions(ATNDeserializationOptions options) {
|
||||||
|
this.verifyATN = options.verifyATN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -64,6 +67,15 @@ public class ATNDeserializationOptions {
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final boolean isVerifyATN() {
|
||||||
|
return verifyATN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setVerifyATN(boolean verifyATN) {
|
||||||
|
throwIfReadOnly();
|
||||||
|
this.verifyATN = verifyATN;
|
||||||
|
}
|
||||||
|
|
||||||
protected void throwIfReadOnly() {
|
protected void throwIfReadOnly() {
|
||||||
if (isReadOnly()) {
|
if (isReadOnly()) {
|
||||||
throw new IllegalStateException("The object is read only.");
|
throw new IllegalStateException("The object is read only.");
|
||||||
|
|
|
@ -358,7 +358,10 @@ public class ATNDeserializer {
|
||||||
decState.decision = i-1;
|
decState.decision = i-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (deserializationOptions.isVerifyATN()) {
|
||||||
verifyATN(atn);
|
verifyATN(atn);
|
||||||
|
}
|
||||||
|
|
||||||
return atn;
|
return atn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue