1 /* 2 * [The "BSD license"] 3 * Copyright (c) 2013 Terence Parr 4 * Copyright (c) 2013 Sam Harwell 5 * Copyright (c) 2017 Egbert Voigt 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 module antlr.v4.runtime.atn.ATNDeserializationOptions; 33 34 // Class ATNDeserializationOptions 35 /** 36 * Options setting for deserialization 37 */ 38 class ATNDeserializationOptions 39 { 40 41 public static ATNDeserializationOptions defaultOptions; 42 43 /** 44 * @uml 45 * @read 46 */ 47 private bool readOnly_; 48 49 /** 50 * @uml 51 * @read 52 * @write 53 */ 54 private bool verifyATN_; 55 56 /** 57 * @uml 58 * @read 59 * @write 60 */ 61 private bool generateRuleBypassTransitions_; 62 63 /** 64 * @uml 65 * @read 66 * @write 67 */ 68 private bool optimize_; 69 70 public static this() 71 { 72 defaultOptions = new ATNDeserializationOptions(); 73 defaultOptions.readOnly_ = true; 74 } 75 76 public this() 77 { 78 this.verifyATN_ = true; 79 this.generateRuleBypassTransitions_ = false; 80 this.optimize_ = true; 81 } 82 83 public this(ATNDeserializationOptions options) 84 { 85 this.verifyATN_ = options.verifyATN; 86 this.generateRuleBypassTransitions_ = options.generateRuleBypassTransitions; 87 this.optimize_ = options.optimize; 88 } 89 90 public void makeReadOnly() 91 { 92 readOnly_ = true; 93 } 94 95 private void throwIfReadOnly() 96 { 97 assert(!readOnly_, "The object is read only."); 98 } 99 100 public final bool readOnly() 101 { 102 return this.readOnly_; 103 } 104 105 public final bool verifyATN() 106 { 107 return this.verifyATN_; 108 } 109 110 public final void verifyATN(bool verifyATN) 111 { 112 this.verifyATN_ = verifyATN; 113 } 114 115 public final bool generateRuleBypassTransitions() 116 { 117 return this.generateRuleBypassTransitions_; 118 } 119 120 public final void generateRuleBypassTransitions(bool generateRuleBypassTransitions) 121 { 122 this.generateRuleBypassTransitions_ = generateRuleBypassTransitions; 123 } 124 125 public final bool optimize() 126 { 127 return this.optimize_; 128 } 129 130 public final void optimize(bool optimize) 131 { 132 this.optimize_ = optimize; 133 } 134 135 }