/* * JFLAP - Formal Languages and Automata Package * * * Susan H. Rodger * Computer Science Department * Duke University * August 27, 2009 * Copyright (c) 2002-2009 * All rights reserved. * JFLAP is open source software. Please see the LICENSE for terms. * */ package automata.turing; import grammar.Production; import java.util.ArrayList; import java.util.*; import automata.Automaton; import automata.State; import automata.Transition; /** * Converter for turing to unrestricted grammar * NEEDS to make abstraction (super class for both TuringToGrammar and PDAtoCFGconverter) * * @author Kyung Min (Jason) Lee * */ public class TuringToGrammarConverter { // Some String constants. private static final String SQUARE_SYMBOL=""+'\u25A1'; private static final String SQUARE="="; private static final String VAR_START="V("; private static final String VAR_END=")"; // Z private HashSet myAllReadableString; // |- finite set of symbols in the tape alphabet private HashSet myAllWritableString; /** * Constructor for converting TM to Unrestrcited grammar */ public TuringToGrammarConverter() { myAllReadableString=new HashSet (); myAllWritableString=new HashSet (); } public Production[] createProductionsForInit(State state, Transition[] tm) { // TODO Auto-generated method stub int id=state.getID(); ArrayList init=new ArrayList (); // for now init.add(new Production("S", VAR_START+SQUARE+SQUARE+VAR_END+"S")); init.add(new Production("S", "S"+VAR_START+SQUARE+SQUARE+VAR_END)); init.add(new Production("S", "T")); myAllReadableString.add(SQUARE); for (int i=0; i list=new ArrayList (); TMTransition trans=(TMTransition) transition; HashMap finalStateMap=new HashMap(); for (int i=0; i