diff --git a/runtime/Swift/Antlr4/org/antlr/v4/runtime/tree/Trees.swift b/runtime/Swift/Antlr4/org/antlr/v4/runtime/tree/Trees.swift index 05e4fb559..1773e9a20 100644 --- a/runtime/Swift/Antlr4/org/antlr/v4/runtime/tree/Trees.swift +++ b/runtime/Swift/Antlr4/org/antlr/v4/runtime/tree/Trees.swift @@ -121,6 +121,10 @@ public class Trees { if let ruleNode = t as? RuleNode { let ruleIndex: Int = ruleNode.getRuleContext().getRuleIndex() let ruleName: String = ruleNames![ruleIndex] + let altNumber = (t as! RuleContext).getAltNumber() + if altNumber != ATN.INVALID_ALT_NUMBER { + return "\(ruleName):\(altNumber)" + } return ruleName } else { if let errorNode = t as? ErrorNode {