diff options
author | Emmanuel Bourg <ebourg@apache.org> | 2018-07-19 09:54:20 +0200 |
---|---|---|
committer | Emmanuel Bourg <ebourg@apache.org> | 2018-07-19 09:54:20 +0200 |
commit | 1d0464db4ec5e5c20b2ae62bb3c4eceaa6840bde (patch) | |
tree | 306aeb163fd60d37ad750838c735c6ea220d1ac1 /tool-testsuite/test/org/antlr/v4/test/tool/TestATNParserPrediction.java | |
parent | a098ea9f9fbd729a7b854028fb07aca8931af702 (diff) |
New upstream version 4.6
Diffstat (limited to 'tool-testsuite/test/org/antlr/v4/test/tool/TestATNParserPrediction.java')
-rw-r--r-- | tool-testsuite/test/org/antlr/v4/test/tool/TestATNParserPrediction.java | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNParserPrediction.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNParserPrediction.java index 5e5731c..3049fd8 100644 --- a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNParserPrediction.java +++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNParserPrediction.java @@ -1,31 +1,7 @@ /* - * [The "BSD license"] - * Copyright (c) 2012 Terence Parr - * Copyright (c) 2012 Sam Harwell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. */ package org.antlr.v4.test.tool; @@ -41,12 +17,12 @@ import org.antlr.v4.runtime.atn.LexerATNSimulator; import org.antlr.v4.runtime.atn.PredictionContextCache; import org.antlr.v4.runtime.dfa.DFA; import org.antlr.v4.runtime.misc.IntegerList; -import org.antlr.v4.test.runtime.java.BaseTest; import org.antlr.v4.tool.DOTGenerator; import org.antlr.v4.tool.Grammar; import org.antlr.v4.tool.LeftRecursiveRule; import org.antlr.v4.tool.LexerGrammar; import org.antlr.v4.tool.Rule; +import org.junit.Before; import org.junit.Test; import java.util.Arrays; @@ -58,7 +34,13 @@ import static org.junit.Assert.assertTrue; // NOTICE: TOKENS IN LEXER, PARSER MUST BE SAME OR TOKEN TYPE MISMATCH // NOTICE: TOKENS IN LEXER, PARSER MUST BE SAME OR TOKEN TYPE MISMATCH -public class TestATNParserPrediction extends BaseTest { +public class TestATNParserPrediction extends BaseJavaToolTest { + @Before + @Override + public void testSetUp() throws Exception { + super.testSetUp(); + } + @Test public void testAorB() throws Exception { LexerGrammar lg = new LexerGrammar( "lexer grammar L;\n" + @@ -520,7 +502,7 @@ public class TestATNParserPrediction extends BaseTest { LexerATNSimulator lexInterp = new LexerATNSimulator(lexatn,new DFA[] { new DFA(lexatn.modeToStartState.get(Lexer.DEFAULT_MODE)) },new PredictionContextCache()); IntegerList types = getTokenTypesViaATN(inputString, lexInterp); - System.out.println(types); +// System.out.println(types); semanticProcess(lg); g.importVocab(lg); @@ -532,15 +514,15 @@ public class TestATNParserPrediction extends BaseTest { DOTGenerator dot = new DOTGenerator(g); Rule r = g.getRule("a"); - if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index])); +// if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index])); r = g.getRule("b"); - if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index])); +// if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index])); r = g.getRule("e"); - if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index])); +// if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index])); r = g.getRule("ifstat"); - if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index])); +// if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index])); r = g.getRule("block"); - if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index])); +// if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index])); // Check ATN prediction // ParserATNSimulator interp = new ParserATNSimulator(atn); @@ -576,7 +558,7 @@ public class TestATNParserPrediction extends BaseTest { for (int i=0; i<inputString.length; i++) { // Check DFA IntegerList types = getTokenTypesViaATN(inputString[i], lexInterp); - System.out.println(types); +// System.out.println(types); TokenStream input = new IntTokenStream(types); try { interp.adaptivePredict(input, decision, ParserRuleContext.EMPTY); |