From 0c835a248aa1272e7cd79be588993fbf1583daf6 Mon Sep 17 00:00:00 2001 From: janyou Date: Wed, 14 Dec 2016 11:58:53 +0800 Subject: [PATCH] Fixes #1298 --- .../runtime/descriptors/ParseTreesDescriptors.java | 2 +- .../org/antlr/v4/runtime/ParserRuleContext.swift | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/ParseTreesDescriptors.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/ParseTreesDescriptors.java index feb32081f..6925fc8eb 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/ParseTreesDescriptors.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/ParseTreesDescriptors.java @@ -112,7 +112,7 @@ public class ParseTreesDescriptors { @Override public boolean ignore(String targetName) { - return !targetName.matches("Java|Python2|Python3|Node"); + return !targetName.matches("Java|Python2|Python3|Node|Swift"); } } diff --git a/runtime/Swift/Antlr4/org/antlr/v4/runtime/ParserRuleContext.swift b/runtime/Swift/Antlr4/org/antlr/v4/runtime/ParserRuleContext.swift index 1e36ac7a1..13c91d6ef 100644 --- a/runtime/Swift/Antlr4/org/antlr/v4/runtime/ParserRuleContext.swift +++ b/runtime/Swift/Antlr4/org/antlr/v4/runtime/ParserRuleContext.swift @@ -79,6 +79,18 @@ open class ParserRuleContext: RuleContext { self.start = ctx.start self.stop = ctx.stop + + // copy any error nodes to alt label node + if ctx.children != nil{ + self.children = Array() + // reset parent pointer for any error nodes + for child: ParseTree in ctx.children! { + if child is ErrorNode{ + self.children?.append(child) + ( (child as! ErrorNode)).parent = self + } + } + } } public init(_ parent: ParserRuleContext?, _ invokingStateNumber: Int) {