org.antlr.test
Class TestSemanticPredicates
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.antlr.test.BaseTest
org.antlr.test.TestSemanticPredicates
- All Implemented Interfaces:
- junit.framework.Test
public class TestSemanticPredicates
- extends BaseTest
Method Summary |
void |
_template()
|
protected void |
checkDecision(Grammar g,
int decision,
java.lang.String expecting,
int[] expectingUnreachableAlts,
int[] expectingNonDetAlts,
java.lang.String expectingAmbigInput,
int[] expectingInsufficientPredAlts,
int[] expectingDanglingAlts,
int expectingNumWarnings,
boolean hasPredHiddenByAction)
|
protected GrammarInsufficientPredicatesMessage |
getGrammarInsufficientPredicatesMessage(java.util.List warnings)
|
protected GrammarNonDeterminismMessage |
getNonDeterminismMessage(java.util.List warnings)
|
protected java.lang.String |
str(int[] elements)
|
void |
testAndPredicates()
|
void |
testDefaultPredNakedAltIsLast()
|
void |
testDefaultPredNakedAltNotLast()
|
void |
testGatedPred()
|
void |
testGatedPredDoesNotForceAllToBeGated()
|
void |
testGatedPredDoesNotForceAllToBeGated2()
|
void |
testGatedPredHoistsAndCanBeInStopState()
|
void |
testGatedPredInCyclicDFA()
|
void |
testGatedPredNotActuallyUsedOnEdges()
|
void |
testHoist2()
|
void |
testHoistCorrectContext()
|
void |
testIgnorePredFromLL2AltLastAltIsDefaultTrue()
|
void |
testIgnorePredFromLL2AltPredUnionNeeded()
|
void |
testIgnoresHoistingDepthGreaterThanZero()
|
void |
testIgnoresPredsHiddenByActions()
|
void |
testIgnoresPredsHiddenByActionsOneAlt()
|
void |
testIncompleteSemanticHoistedContext()
The following grammar should yield an error that rule 'a' has
insufficient semantic info pulled from 'b'. |
void |
testIncompleteSemanticHoistedContext2()
The following grammar should yield an error that rule 'a' has
insufficient semantic info pulled from 'b'. |
void |
testIncompleteSemanticHoistedContextInFOLLOW()
|
void |
testIncompleteSemanticHoistedContextInFOLLOWDueToHiddenPred()
|
void |
testIncompleteSemanticHoistedContextInFOLLOWk2()
|
void |
testIncompleteSemanticHoistedContextk2()
|
void |
testLeftRecursivePred()
|
void |
testLexerMatchesLongestMinusPred()
|
void |
testLexerMatchesLongestThenTestPred()
|
void |
testLL_1_Pred_forced_k_1()
|
void |
testLL_1_Pred()
|
void |
testLL_2_Pred()
|
void |
testMatchesLongestThenTestPred()
|
void |
testORGatedPred()
|
void |
testOrPredicates()
|
void |
testPredGets2SymbolSyntacticContext()
|
void |
testPredicatedLoop()
|
void |
testPredicatedToStayInLoop()
|
void |
testPredsButSyntaxResolves()
|
void |
testPredsUsedAfterK2FailsNoRecursionOverflow()
|
void |
testPredsUsedAfterRecursionOverflow()
|
void |
testPredWithArbitraryLookahead()
|
void |
testPredWithK1()
|
void |
testSemanticContextPreventsEarlyTerminationOfClosure()
|
void |
testTooFewSemanticPredicates()
|
void |
testUniquePredicateOR()
For a DFA state with lots of configurations that have the same
predicate, don't just OR them all together as it's a waste to
test a||a||b||a||a etc... |
Methods inherited from class org.antlr.test.BaseTest |
antlr, checkGrammarSemanticsError, checkGrammarSemanticsWarning, compile, eraseFiles, execLexer, execParser, execTreeParser, execTreeParser, getFirstLineOfException, mkdir, newTool, newTool, rawExecRecognizer, rawGenerateAndBuildRecognizer, realElements, realElements, setUp, writeFile, writeLexerTestFile, writeTemplateTestFile, writeTestFile, writeTreeAndTreeTestFile, writeTreeTestFile |
Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString |
Methods inherited from class junit.framework.Assert |
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
TestSemanticPredicates
public TestSemanticPredicates()
- Public default constructor used by TestRig
testPredsButSyntaxResolves
public void testPredsButSyntaxResolves()
throws java.lang.Exception
- Throws:
java.lang.Exception
testLL_1_Pred
public void testLL_1_Pred()
throws java.lang.Exception
- Throws:
java.lang.Exception
testLL_1_Pred_forced_k_1
public void testLL_1_Pred_forced_k_1()
throws java.lang.Exception
- Throws:
java.lang.Exception
testLL_2_Pred
public void testLL_2_Pred()
throws java.lang.Exception
- Throws:
java.lang.Exception
testPredicatedLoop
public void testPredicatedLoop()
throws java.lang.Exception
- Throws:
java.lang.Exception
testPredicatedToStayInLoop
public void testPredicatedToStayInLoop()
throws java.lang.Exception
- Throws:
java.lang.Exception
testAndPredicates
public void testAndPredicates()
throws java.lang.Exception
- Throws:
java.lang.Exception
testOrPredicates
public void testOrPredicates()
throws java.lang.Exception
- Throws:
java.lang.Exception
testIgnoresHoistingDepthGreaterThanZero
public void testIgnoresHoistingDepthGreaterThanZero()
throws java.lang.Exception
- Throws:
java.lang.Exception
testIgnoresPredsHiddenByActions
public void testIgnoresPredsHiddenByActions()
throws java.lang.Exception
- Throws:
java.lang.Exception
testIgnoresPredsHiddenByActionsOneAlt
public void testIgnoresPredsHiddenByActionsOneAlt()
throws java.lang.Exception
- Throws:
java.lang.Exception
testHoist2
public void testHoist2()
throws java.lang.Exception
- Throws:
java.lang.Exception
testHoistCorrectContext
public void testHoistCorrectContext()
throws java.lang.Exception
- Throws:
java.lang.Exception
testDefaultPredNakedAltIsLast
public void testDefaultPredNakedAltIsLast()
throws java.lang.Exception
- Throws:
java.lang.Exception
testDefaultPredNakedAltNotLast
public void testDefaultPredNakedAltNotLast()
throws java.lang.Exception
- Throws:
java.lang.Exception
testLeftRecursivePred
public void testLeftRecursivePred()
throws java.lang.Exception
- Throws:
java.lang.Exception
testIgnorePredFromLL2AltLastAltIsDefaultTrue
public void testIgnorePredFromLL2AltLastAltIsDefaultTrue()
throws java.lang.Exception
- Throws:
java.lang.Exception
testIgnorePredFromLL2AltPredUnionNeeded
public void testIgnorePredFromLL2AltPredUnionNeeded()
throws java.lang.Exception
- Throws:
java.lang.Exception
testPredGets2SymbolSyntacticContext
public void testPredGets2SymbolSyntacticContext()
throws java.lang.Exception
- Throws:
java.lang.Exception
testMatchesLongestThenTestPred
public void testMatchesLongestThenTestPred()
throws java.lang.Exception
- Throws:
java.lang.Exception
testPredsUsedAfterRecursionOverflow
public void testPredsUsedAfterRecursionOverflow()
throws java.lang.Exception
- Throws:
java.lang.Exception
testPredsUsedAfterK2FailsNoRecursionOverflow
public void testPredsUsedAfterK2FailsNoRecursionOverflow()
throws java.lang.Exception
- Throws:
java.lang.Exception
testLexerMatchesLongestThenTestPred
public void testLexerMatchesLongestThenTestPred()
throws java.lang.Exception
- Throws:
java.lang.Exception
testLexerMatchesLongestMinusPred
public void testLexerMatchesLongestMinusPred()
throws java.lang.Exception
- Throws:
java.lang.Exception
testGatedPred
public void testGatedPred()
throws java.lang.Exception
- Throws:
java.lang.Exception
testGatedPredHoistsAndCanBeInStopState
public void testGatedPredHoistsAndCanBeInStopState()
throws java.lang.Exception
- Throws:
java.lang.Exception
testGatedPredInCyclicDFA
public void testGatedPredInCyclicDFA()
throws java.lang.Exception
- Throws:
java.lang.Exception
testGatedPredNotActuallyUsedOnEdges
public void testGatedPredNotActuallyUsedOnEdges()
throws java.lang.Exception
- Throws:
java.lang.Exception
testGatedPredDoesNotForceAllToBeGated
public void testGatedPredDoesNotForceAllToBeGated()
throws java.lang.Exception
- Throws:
java.lang.Exception
testGatedPredDoesNotForceAllToBeGated2
public void testGatedPredDoesNotForceAllToBeGated2()
throws java.lang.Exception
- Throws:
java.lang.Exception
testORGatedPred
public void testORGatedPred()
throws java.lang.Exception
- Throws:
java.lang.Exception
testIncompleteSemanticHoistedContext
public void testIncompleteSemanticHoistedContext()
throws java.lang.Exception
- The following grammar should yield an error that rule 'a' has
insufficient semantic info pulled from 'b'.
- Throws:
java.lang.Exception
testIncompleteSemanticHoistedContextk2
public void testIncompleteSemanticHoistedContextk2()
throws java.lang.Exception
- Throws:
java.lang.Exception
testIncompleteSemanticHoistedContextInFOLLOW
public void testIncompleteSemanticHoistedContextInFOLLOW()
throws java.lang.Exception
- Throws:
java.lang.Exception
testIncompleteSemanticHoistedContextInFOLLOWk2
public void testIncompleteSemanticHoistedContextInFOLLOWk2()
throws java.lang.Exception
- Throws:
java.lang.Exception
testIncompleteSemanticHoistedContextInFOLLOWDueToHiddenPred
public void testIncompleteSemanticHoistedContextInFOLLOWDueToHiddenPred()
throws java.lang.Exception
- Throws:
java.lang.Exception
testIncompleteSemanticHoistedContext2
public void testIncompleteSemanticHoistedContext2()
throws java.lang.Exception
- The following grammar should yield an error that rule 'a' has
insufficient semantic info pulled from 'b'. This is the same
as the previous case except that the D prevents the B path from
"pinching" together into a single NFA state.
This test also demonstrates that just because B D could predict
alt 1 in rule 'a', it is unnecessary to continue NFA->DFA
conversion to include an edge for D. Alt 1 is the only possible
prediction because we resolve the ambiguity by choosing alt 1.
- Throws:
java.lang.Exception
testTooFewSemanticPredicates
public void testTooFewSemanticPredicates()
throws java.lang.Exception
- Throws:
java.lang.Exception
testPredWithK1
public void testPredWithK1()
throws java.lang.Exception
- Throws:
java.lang.Exception
testPredWithArbitraryLookahead
public void testPredWithArbitraryLookahead()
throws java.lang.Exception
- Throws:
java.lang.Exception
testUniquePredicateOR
public void testUniquePredicateOR()
throws java.lang.Exception
- For a DFA state with lots of configurations that have the same
predicate, don't just OR them all together as it's a waste to
test a||a||b||a||a etc... ANTLR makes a unique set and THEN
OR's them together.
- Throws:
java.lang.Exception
testSemanticContextPreventsEarlyTerminationOfClosure
public void testSemanticContextPreventsEarlyTerminationOfClosure()
throws java.lang.Exception
- Throws:
java.lang.Exception
_template
public void _template()
throws java.lang.Exception
- Throws:
java.lang.Exception
checkDecision
protected void checkDecision(Grammar g,
int decision,
java.lang.String expecting,
int[] expectingUnreachableAlts,
int[] expectingNonDetAlts,
java.lang.String expectingAmbigInput,
int[] expectingInsufficientPredAlts,
int[] expectingDanglingAlts,
int expectingNumWarnings,
boolean hasPredHiddenByAction)
throws java.lang.Exception
- Throws:
java.lang.Exception
getNonDeterminismMessage
protected GrammarNonDeterminismMessage getNonDeterminismMessage(java.util.List warnings)
getGrammarInsufficientPredicatesMessage
protected GrammarInsufficientPredicatesMessage getGrammarInsufficientPredicatesMessage(java.util.List warnings)
str
protected java.lang.String str(int[] elements)