KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ticket39 > PartitioningBug


1 /* This file is part of SableCC ( http://sablecc.org ).
2  *
3  * Copyright 2007 Etienne M. Gagnon <egagnon@j-meg.com>
4  * Copyright 2007 Raymond Audet <raymond.audet@gmail.com>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package ticket39;
20
21 import org.junit.Test;
22 import org.sablecc.sablecc.alphabet.AdjacencyRealm;
23 import org.sablecc.sablecc.alphabet.Realms;
24 import org.sablecc.sablecc.automaton.Dfa;
25 import org.sablecc.sablecc.automaton.MinimalDfa;
26 import org.sablecc.sablecc.automaton.Nfa;
27
28 public class PartitioningBug {
29
30     @Test
31     public void bug() {
32
33         AdjacencyRealm<Character JavaDoc> charRealm = Realms.getCharacter();
34
35         Nfa<Character JavaDoc> any = new Nfa<Character JavaDoc>(charRealm.createInterval('A',
36                 'Z'));
37         Nfa<Character JavaDoc> e = new Nfa<Character JavaDoc>(charRealm.createInterval('E'));
38         Nfa<Character JavaDoc> t = new Nfa<Character JavaDoc>(charRealm.createInterval('T'));
39         Nfa<Character JavaDoc> i = new Nfa<Character JavaDoc>(charRealm.createInterval('I'));
40         Nfa<Character JavaDoc> n = new Nfa<Character JavaDoc>(charRealm.createInterval('N'));
41
42         Dfa<Character JavaDoc> allButEtienne = any.zeroOrMore().subtract(
43                 e.concatenateWith(t).concatenateWith(i).concatenateWith(e)
44                         .concatenateWith(n).concatenateWith(n).concatenateWith(
45                                 e));
46
47         // Line that causes the bug
48
new MinimalDfa<Character JavaDoc>(allButEtienne);
49     }
50 }
51
Popular Tags