[Swift] Tighten up the permissions on lots of fields
Tighten up the permissions on lots of fields, for debuggability.
This commit is contained in:
parent
623fe00fb7
commit
176d92d373
|
@ -8,24 +8,24 @@
|
|||
public class ATN {
|
||||
public static let INVALID_ALT_NUMBER = 0
|
||||
|
||||
public final var states = [ATNState?]()
|
||||
public private(set) final var states = [ATNState?]()
|
||||
|
||||
///
|
||||
/// Each subrule/rule is a decision point and we must track them so we
|
||||
/// can go back later and build DFA predictors for them. This includes
|
||||
/// all the rules, subrules, optional blocks, ()+, ()* etc...
|
||||
///
|
||||
public final var decisionToState = [DecisionState]()
|
||||
public private(set) final var decisionToState = [DecisionState]()
|
||||
|
||||
///
|
||||
/// Maps from rule index to starting state number.
|
||||
///
|
||||
public final var ruleToStartState: [RuleStartState]!
|
||||
public internal(set) final var ruleToStartState: [RuleStartState]!
|
||||
|
||||
///
|
||||
/// Maps from rule index to stop state number.
|
||||
///
|
||||
public final var ruleToStopState: [RuleStopState]!
|
||||
public internal(set) final var ruleToStopState: [RuleStopState]!
|
||||
|
||||
///
|
||||
/// The type of the ATN.
|
||||
|
@ -43,15 +43,15 @@ public class ATN {
|
|||
/// type if the `ATNDeserializationOptions.generateRuleBypassTransitions`
|
||||
/// deserialization option was specified; otherwise, this is `null`.
|
||||
///
|
||||
public final var ruleToTokenType: [Int]!
|
||||
public internal(set) final var ruleToTokenType: [Int]!
|
||||
|
||||
///
|
||||
/// For lexer ATNs, this is an array of _org.antlr.v4.runtime.atn.LexerAction_ objects which may
|
||||
/// be referenced by action transitions in the ATN.
|
||||
///
|
||||
public final var lexerActions: [LexerAction]!
|
||||
public internal(set) final var lexerActions: [LexerAction]!
|
||||
|
||||
public final var modeToStartState = [TokensStartState]()
|
||||
public internal(set) final var modeToStartState = [TokensStartState]()
|
||||
|
||||
///
|
||||
/// Used for runtime deserialization of ATNs from strings
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ATNConfig: Hashable, CustomStringConvertible {
|
|||
/// with this config. We track only those contexts pushed during
|
||||
/// execution of the ATN simulator.
|
||||
///
|
||||
public final var context: PredictionContext?
|
||||
public internal(set) final var context: PredictionContext?
|
||||
|
||||
///
|
||||
/// We cannot execute predicates dependent upon local context unless
|
||||
|
@ -62,9 +62,7 @@ public class ATNConfig: Hashable, CustomStringConvertible {
|
|||
/// _org.antlr.v4.runtime.atn.ATNConfigSet#add(org.antlr.v4.runtime.atn.ATNConfig, DoubleKeyMap)_ method are
|
||||
/// __completely__ unaffected by the change.
|
||||
///
|
||||
public final var reachesIntoOuterContext: Int = 0
|
||||
//=0 intital by janyou
|
||||
|
||||
public internal(set) final var reachesIntoOuterContext: Int = 0
|
||||
|
||||
public final let semanticContext: SemanticContext
|
||||
|
||||
|
|
|
@ -27,22 +27,22 @@ public final class ATNConfigSet: Hashable, CustomStringConvertible {
|
|||
/// fields; in particular, conflictingAlts is set after
|
||||
/// we've made this readonly.
|
||||
///
|
||||
internal final var readonly = false
|
||||
private var readonly = false
|
||||
|
||||
///
|
||||
/// All configs but hashed by (s, i, _, pi) not including context. Wiped out
|
||||
/// when we go readonly as this set becomes a DFA state.
|
||||
///
|
||||
public final var configLookup: LookupDictionary
|
||||
private var configLookup: LookupDictionary
|
||||
|
||||
///
|
||||
/// Track the elements as they are added to the set; supports get(i)
|
||||
///
|
||||
public final var configs = [ATNConfig]()
|
||||
public private(set) var configs = [ATNConfig]()
|
||||
|
||||
// TODO: these fields make me pretty uncomfortable but nice to pack up info together, saves recomputation
|
||||
// TODO: can we track conflicts as they are added to save scanning configs later?
|
||||
public final var uniqueAlt = 0
|
||||
public internal(set) var uniqueAlt = 0
|
||||
//TODO no default
|
||||
///
|
||||
/// Currently this is only used when we detect SLL conflict; this does
|
||||
|
@ -50,13 +50,13 @@ public final class ATNConfigSet: Hashable, CustomStringConvertible {
|
|||
/// I should also point out that this seems to include predicated alternatives
|
||||
/// that have predicates that evaluate to false. Computed in computeTargetState().
|
||||
///
|
||||
internal final var conflictingAlts: BitSet?
|
||||
internal var conflictingAlts: BitSet?
|
||||
|
||||
// Used in parser and lexer. In lexer, it indicates we hit a pred
|
||||
// while computing a closure operation. Don't make a DFA state from this.
|
||||
public final var hasSemanticContext = false
|
||||
public internal(set) var hasSemanticContext = false
|
||||
//TODO no default
|
||||
public final var dipsIntoOuterContext = false
|
||||
public internal(set) var dipsIntoOuterContext = false
|
||||
//TODO no default
|
||||
|
||||
///
|
||||
|
|
|
@ -105,22 +105,22 @@ public class ATNState: Hashable, CustomStringConvertible {
|
|||
///
|
||||
public final var atn: ATN? = nil
|
||||
|
||||
public final var stateNumber: Int = INVALID_STATE_NUMBER
|
||||
public internal(set) final var stateNumber: Int = INVALID_STATE_NUMBER
|
||||
|
||||
public final var ruleIndex: Int?
|
||||
public internal(set) final var ruleIndex: Int?
|
||||
// at runtime, we don't have Rule objects
|
||||
|
||||
public final var epsilonOnlyTransitions: Bool = false
|
||||
public private(set) final var epsilonOnlyTransitions: Bool = false
|
||||
|
||||
///
|
||||
/// Track the transitions emanating from this ATN state.
|
||||
///
|
||||
internal final var transitions = [Transition]()
|
||||
internal private(set) final var transitions = [Transition]()
|
||||
|
||||
///
|
||||
/// Used to cache lookahead during parsing, not used during construction
|
||||
///
|
||||
public final var nextTokenWithinRule: IntervalSet?
|
||||
public internal(set) final var nextTokenWithinRule: IntervalSet?
|
||||
|
||||
|
||||
public var hashValue: Int {
|
||||
|
|
|
@ -11,7 +11,7 @@ public class ArrayPredictionContext: PredictionContext {
|
|||
/// from _#EMPTY_ and non-empty. We merge _#EMPTY_ by using null parent and
|
||||
/// returnState == _#EMPTY_RETURN_STATE_.
|
||||
///
|
||||
public final var parents: [PredictionContext?]
|
||||
public private(set) final var parents: [PredictionContext?]
|
||||
|
||||
///
|
||||
/// Sorted for merge, no duplicates; if present,
|
||||
|
|
|
@ -23,7 +23,7 @@ public class DecisionInfo: CustomStringConvertible {
|
|||
///
|
||||
/// The decision number, which is an index into _org.antlr.v4.runtime.atn.ATN#decisionToState_.
|
||||
///
|
||||
public final var decision: Int
|
||||
public private(set) final var decision: Int
|
||||
|
||||
///
|
||||
/// The total number of times _org.antlr.v4.runtime.atn.ParserATNSimulator#adaptivePredict_ was
|
||||
|
|
|
@ -69,7 +69,7 @@ open class LexerATNSimulator: ATNSimulator {
|
|||
///
|
||||
public var charPositionInLine = 0
|
||||
|
||||
public final var decisionToDFA: [DFA]
|
||||
public private(set) final var decisionToDFA: [DFA]
|
||||
|
||||
internal var mode = Lexer.DEFAULT_MODE
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ open class ParserATNSimulator: ATNSimulator {
|
|||
|
||||
internal final unowned let parser: Parser
|
||||
|
||||
public final var decisionToDFA: [DFA]
|
||||
public private(set) final var decisionToDFA: [DFA]
|
||||
|
||||
///
|
||||
/// SLL, LL, or LL + exact ambig detection?
|
||||
|
|
|
@ -73,7 +73,7 @@ public class Transition {
|
|||
/// The target of this transition.
|
||||
///
|
||||
|
||||
public final var target: ATNState
|
||||
public internal(set) final var target: ATNState
|
||||
|
||||
init(_ target: ATNState) {
|
||||
|
||||
|
|
|
@ -31,27 +31,27 @@
|
|||
/// meaning that state was reached via a different set of rule invocations.
|
||||
///
|
||||
|
||||
public class DFAState: Hashable, CustomStringConvertible {
|
||||
public var stateNumber = -1
|
||||
public final class DFAState: Hashable, CustomStringConvertible {
|
||||
public internal(set) var stateNumber = -1
|
||||
|
||||
public var configs = ATNConfigSet()
|
||||
public internal(set) var configs = ATNConfigSet()
|
||||
|
||||
///
|
||||
/// `edges[symbol]` points to target of symbol. Shift up by 1 so (-1)
|
||||
/// _org.antlr.v4.runtime.Token#EOF_ maps to `edges[0]`.
|
||||
///
|
||||
public var edges: [DFAState?]!
|
||||
public internal(set) var edges: [DFAState?]!
|
||||
|
||||
public var isAcceptState = false
|
||||
public internal(set) var isAcceptState = false
|
||||
|
||||
///
|
||||
/// if accept state, what ttype do we match or alt do we predict?
|
||||
/// This is set to _org.antlr.v4.runtime.atn.ATN#INVALID_ALT_NUMBER_ when _#predicates_`!=null` or
|
||||
/// _#requiresFullContext_.
|
||||
///
|
||||
public var prediction = 0
|
||||
public internal(set) var prediction = 0
|
||||
|
||||
public var lexerActionExecutor: LexerActionExecutor!
|
||||
public internal(set) var lexerActionExecutor: LexerActionExecutor?
|
||||
|
||||
///
|
||||
/// Indicates that this state was created during SLL prediction that
|
||||
|
@ -59,7 +59,7 @@ public class DFAState: Hashable, CustomStringConvertible {
|
|||
/// _org.antlr.v4.runtime.atn.ParserATNSimulator#execATN_ invocations immediately jumped doing
|
||||
/// full context prediction if this field is true.
|
||||
///
|
||||
public var requiresFullContext = false
|
||||
public internal(set) var requiresFullContext = false
|
||||
|
||||
///
|
||||
/// During SLL parsing, this is a list of predicates associated with the
|
||||
|
@ -75,13 +75,13 @@ public class DFAState: Hashable, CustomStringConvertible {
|
|||
/// This list is computed by _org.antlr.v4.runtime.atn.ParserATNSimulator#predicateDFAState_.
|
||||
///
|
||||
|
||||
public var predicates: [PredPrediction]?
|
||||
public internal(set) var predicates: [PredPrediction]?
|
||||
|
||||
///
|
||||
/// Map a predicate to a predicted alternative.
|
||||
///
|
||||
|
||||
public class PredPrediction: CustomStringConvertible {
|
||||
public final class PredPrediction: CustomStringConvertible {
|
||||
public let pred: SemanticContext
|
||||
// never null; at least SemanticContext.NONE
|
||||
public let alt: Int
|
||||
|
|
Loading…
Reference in New Issue