forked from jasder/antlr
[Swift] Make DFA.precedenceDfa be a "let" rather than a "var".
Make DFA.precedenceDfa be a "let" rather than a "var", and remove setPrecedenceDfa. This field never varies after construction. The code in setPrecedenceDfa was carried over from the Java runtime, but it only threw an exception, and was deprecated. There's no need for that in the Swift runtime.
This commit is contained in:
parent
b4c34da1f0
commit
b548999b16
|
@ -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,25 +130,7 @@ 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.
|
||||||
///
|
///
|
||||||
public func getStates() -> Array<DFAState> {
|
public func getStates() -> Array<DFAState> {
|
||||||
|
|
Loading…
Reference in New Issue