1 8 9 package net.sourceforge.chaperon.process; 10 11 import java.io.Serializable ; 12 13 19 public class LexicalAutomaton implements Serializable 20 { 21 private int lexemecount = 0; 22 23 private String [] symbols; 25 26 private PatternAutomaton[] definitions; 28 29 34 public LexicalAutomaton(int lexemecount) 35 { 36 this.lexemecount = lexemecount; 37 symbols = new String [lexemecount]; 38 definitions = new PatternAutomaton[lexemecount]; 39 } 40 41 47 public void setLexemeSymbol(int index, String symbol) 48 { 49 if ((index<0) || (index>=lexemecount)) 50 throw new IndexOutOfBoundsException (); 51 52 symbols[index] = symbol; 53 } 54 55 62 public String getLexemeSymbol(int index) 63 { 64 if ((index<0) || (index>=lexemecount)) 65 throw new IndexOutOfBoundsException (); 66 67 return symbols[index]; 68 } 69 70 76 public void setLexemeDefinition(int index, PatternAutomaton definition) 77 { 78 if ((index<0) || (index>=lexemecount)) 79 throw new IndexOutOfBoundsException (); 80 81 definitions[index] = definition; 82 } 83 84 91 public PatternAutomaton getLexemeDefinition(int index) 92 { 93 if ((index<0) || (index>=lexemecount)) 94 throw new IndexOutOfBoundsException (); 95 96 return definitions[index]; 97 } 98 99 104 public int getLexemeCount() 105 { 106 return lexemecount; 107 } 108 } 109 | Popular Tags |