From 4c1dc90064a73d7b57513c63c8fd68a418a9b212 Mon Sep 17 00:00:00 2001 From: parrt Date: Wed, 15 Mar 2017 09:03:50 -0700 Subject: [PATCH 1/2] tweak wildcard. Fixes #1213 --- .../antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg index b93e96c20..fb5883c02 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg @@ -530,7 +530,7 @@ else { Wildcard(w) ::= << this.state = ; - = }>matchWildcard(); + = }>this.matchWildcard(); >> // ACTION STUFF From d966702d63b1819d57d56b83c5233d9449f84bc2 Mon Sep 17 00:00:00 2001 From: parrt Date: Wed, 15 Mar 2017 09:33:15 -0700 Subject: [PATCH 2/2] add wildcard test. --- .../descriptors/ParserExecDescriptors.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/ParserExecDescriptors.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/ParserExecDescriptors.java index e1af2492d..3319c28ba 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/ParserExecDescriptors.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/ParserExecDescriptors.java @@ -240,8 +240,30 @@ public class ParserExecDescriptors { } + /** Match assignments, ignore other tokens with wildcard. */ + public static class Wildcard extends BaseParserTestDescriptor { + public String input = "x=10; abc;;;; y=99;"; + public String output = "x=10;\ny=99;\n"; + public String errors = null; + public String startRule = "a"; + public String grammarName = "T"; + + /** + grammar T; + a : (assign|.)+ EOF ; + assign : ID '=' INT ';' { + + } ; + ID : 'a'..'z'+ ; + INT : '0'..'9'+; + WS : (' '|'\n') -> skip; + */ + @CommentHasStringValue + public String grammar; + } + /** - * This test ensures that {@link ParserATNSimulator} does not produce a + * This test ensures that {@link org.antlr.v4.runtime.atn.ParserATNSimulator} does not produce a * {@link StackOverflowError} when it encounters an {@code EOF} transition * inside a closure. */