Merge pull request #2114 from ewanmellor/swift-let-precedencedfa
[Swift] Make DFA.precedenceDfa be a "let" rather than a "var".
This commit is contained in:
commit
3536a84b52
|
@ -27,7 +27,7 @@ public class DFA: CustomStringConvertible {
|
||||||
/// `true` if this DFA is for a precedence decision; otherwise,
|
/// `true` if this DFA is for a precedence decision; otherwise,
|
||||||
/// `false`. This is the backing field for _#isPrecedenceDfa_.
|
/// `false`. This is the backing field for _#isPrecedenceDfa_.
|
||||||
///
|
///
|
||||||
private final var precedenceDfa: Bool
|
private let precedenceDfa: Bool
|
||||||
|
|
||||||
///
|
///
|
||||||
/// mutex for DFAState changes.
|
/// mutex for DFAState changes.
|
||||||
|
@ -42,19 +42,19 @@ public class DFA: CustomStringConvertible {
|
||||||
self.atnStartState = atnStartState
|
self.atnStartState = atnStartState
|
||||||
self.decision = decision
|
self.decision = decision
|
||||||
|
|
||||||
var precedenceDfa: Bool = false
|
if let starLoopState = atnStartState as? StarLoopEntryState, starLoopState.precedenceRuleDecision {
|
||||||
if atnStartState is StarLoopEntryState {
|
let precedenceState = DFAState(ATNConfigSet())
|
||||||
if (atnStartState as! StarLoopEntryState).precedenceRuleDecision {
|
precedenceState.edges = [DFAState]()
|
||||||
precedenceDfa = true
|
precedenceState.isAcceptState = false
|
||||||
let precedenceState: DFAState = DFAState(ATNConfigSet())
|
precedenceState.requiresFullContext = false
|
||||||
precedenceState.edges = [DFAState]() //new DFAState[0];
|
|
||||||
precedenceState.isAcceptState = false
|
|
||||||
precedenceState.requiresFullContext = false
|
|
||||||
self.s0 = precedenceState
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.precedenceDfa = precedenceDfa
|
precedenceDfa = true
|
||||||
|
s0 = precedenceState
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
precedenceDfa = false
|
||||||
|
s0 = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -130,24 +130,6 @@ public class DFA: CustomStringConvertible {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
|
||||||
/// Sets whether this is a precedence DFA.
|
|
||||||
///
|
|
||||||
/// - parameter precedenceDfa: `true` if this is a precedence DFA; otherwise,
|
|
||||||
/// `false`
|
|
||||||
///
|
|
||||||
/// - throws: ANTLRError.unsupportedOperation if `precedenceDfa` does not
|
|
||||||
/// match the value of _#isPrecedenceDfa_ for the current DFA.
|
|
||||||
///
|
|
||||||
/// - note: This method no longer performs any action.
|
|
||||||
///
|
|
||||||
public final func setPrecedenceDfa(_ precedenceDfa: Bool) throws {
|
|
||||||
if precedenceDfa != isPrecedenceDfa() {
|
|
||||||
throw ANTLRError.unsupportedOperation(msg: "The precedenceDfa field cannot change after a DFA is constructed.")
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Return a list of all states in this DFA, ordered by state number.
|
/// Return a list of all states in this DFA, ordered by state number.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue