public static void main(String[] arguments) { Alphabet alphabet = null; Alphabet pushDownAlphabet = null; NonterminalSymbolSet nonterminalSymbolSet = null; TerminalSymbolSet terminalSymbolSet = null; try { alphabet = new DefaultAlphabet( new DefaultSymbol("2"), new DefaultSymbol("3")); // $NON-NLS-1$ //$NON-NLS-2$ pushDownAlphabet = new DefaultAlphabet( new DefaultSymbol("4"), new DefaultSymbol("5")); // $NON-NLS-1$ //$NON-NLS-2$ nonterminalSymbolSet = new DefaultNonterminalSymbolSet( new DefaultNonterminalSymbol("A"), new DefaultNonterminalSymbol( //$NON-NLS-1$ "B")); //$NON-NLS-1$ terminalSymbolSet = new DefaultTerminalSymbolSet( new DefaultTerminalSymbol("e"), new DefaultTerminalSymbol("f")); // $NON-NLS-1$ //$NON-NLS-2$ } catch (AlphabetException exc) { exc.printStackTrace(); System.exit(1); } catch (NonterminalSymbolSetException exc) { exc.printStackTrace(); System.exit(1); } catch (TerminalSymbolSetException exc) { exc.printStackTrace(); System.exit(1); } PreferenceManager preferences = PreferenceManager.getInstance(); System.out.println(preferences.getNonterminalSymbolSetItem()); System.out.println(preferences.getTerminalSymbolSetItem()); preferences.setNonterminalSymbolSetItem( new NonterminalSymbolSetItem(nonterminalSymbolSet, nonterminalSymbolSet)); preferences.setTerminalSymbolSetItem( new TerminalSymbolSetItem(terminalSymbolSet, terminalSymbolSet)); System.out.println(preferences.getNonterminalSymbolSetItem()); System.out.println(preferences.getTerminalSymbolSetItem()); }
/** * The main method. * * @param arguments The arguments. */ public static void main(String[] arguments) { try { NonterminalSymbolSet nonterminalSymbolSet = new DefaultNonterminalSymbolSet( new DefaultNonterminalSymbol("E"), new DefaultNonterminalSymbol( //$NON-NLS-1$ "F"), new DefaultNonterminalSymbol("G")); // $NON-NLS-1$ //$NON-NLS-2$ TerminalSymbolSet terminalSymbolSet = new DefaultTerminalSymbolSet( new DefaultTerminalSymbol("a"), new DefaultTerminalSymbol("b"), // $NON-NLS-1$ //$NON-NLS-2$ new DefaultTerminalSymbol("c")); // $NON-NLS-1$ JFrame jFrame = new JFrame("ProductionWordPanelTest"); // $NON-NLS-1$ StyledProductionWordParserPanel styledProductionWordParserPanel = new StyledProductionWordParserPanel(); styledProductionWordParserPanel.setNonterminalSymbolSet(nonterminalSymbolSet); styledProductionWordParserPanel.setTerminalSymbolSet(terminalSymbolSet); styledProductionWordParserPanel.addParseableChangedListener( new ParseableChangedListener<ProductionWord>() { public void parseableChanged(ProductionWord newProductionWord) { if (newProductionWord != null) { System.out.println(newProductionWord.toString()); } } }); jFrame.add(styledProductionWordParserPanel); jFrame.setBounds(300, 300, 400, 300); jFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); jFrame.setVisible(true); } catch (NonterminalSymbolSetException exc) { exc.printStackTrace(); } catch (TerminalSymbolSetException exc) { exc.printStackTrace(); } }