aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/antlr4_cpp_runtime/src/atn/ATNDeserializationOptions.cpp
blob: e0a7cb2b279e2be05508dc53850942f855da6ec0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
 * Use of this file is governed by the BSD 3-clause license that
 * can be found in the LICENSE.txt file in the project root.
 */

#include "atn/ATNDeserializationOptions.h"
#include "Exceptions.h"

using namespace antlr4;
using namespace antlr4::atn;

ATNDeserializationOptions::ATNDeserializationOptions(ATNDeserializationOptions *options)
    : _readOnly(false), _verifyATN(options->_verifyATN),
      _generateRuleBypassTransitions(options->_generateRuleBypassTransitions) {}

const ATNDeserializationOptions& ATNDeserializationOptions::getDefaultOptions() {
  static const ATNDeserializationOptions* const defaultOptions = new ATNDeserializationOptions();
  return *defaultOptions;
}

void ATNDeserializationOptions::makeReadOnly() {
  _readOnly = true;
}

void ATNDeserializationOptions::setVerifyATN(bool verify) {
  throwIfReadOnly();
  _verifyATN = verify;
}

void ATNDeserializationOptions::setGenerateRuleBypassTransitions(bool generate) {
  throwIfReadOnly();
  _generateRuleBypassTransitions = generate;
}

void ATNDeserializationOptions::throwIfReadOnly() const {
  if (isReadOnly()) {
    throw IllegalStateException("ATNDeserializationOptions is read only.");
  }
}