~ubuntu-branches/ubuntu/vivid/weka/vivid

« back to all changes in this revision

Viewing changes to weka/core/parser/JFlex/EOFActions.java

  • Committer: Bazaar Package Importer
  • Author(s): Soeren Sonnenburg, Torsten Werner, Soeren Sonnenburg
  • Date: 2008-10-30 06:42:46 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081030064246-648zj038l155host
Tags: 3.5.8+cup1-1
[ Torsten Werner ]
* Update Section field in doc-base file.
* Add Class-Path attribute to jar file.

[ Soeren Sonnenburg ]
* Update my email address to sonne@debian.org.
* Update copyright.
* Remove build, java cup and jflex from orig.tar.gz.
* Add cup and jflex as build dependency.
* Patch weka source to use cup from debian.
* Patch weka shell wrapper to use java-6-sun or openjdk.
* Obtain documentation from svn.
* Build depend on texlive-latex-extra (required to generate documentation).
* Add javadoc as build target.
* Use java-wrappers to start weka.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
 
 * JFlex 1.4.1                                                             *
3
 
 * Copyright (C) 1998-2004  Gerwin Klein <lsf@jflex.de>                    *
4
 
 * All rights reserved.                                                    *
5
 
 *                                                                         *
6
 
 * This program is free software; you can redistribute it and/or modify    *
7
 
 * it under the terms of the GNU General Public License. See the file      *
8
 
 * COPYRIGHT for more information.                                         *
9
 
 *                                                                         *
10
 
 * This program is distributed in the hope that it will be useful,         *
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
13
 
 * GNU General Public License for more details.                            *
14
 
 *                                                                         *
15
 
 * You should have received a copy of the GNU General Public License along *
16
 
 * with this program; if not, write to the Free Software Foundation, Inc., *
17
 
 * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                 *
18
 
 *                                                                         *
19
 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
20
 
 
21
 
package weka.core.parser.JFlex;
22
 
 
23
 
import java.util.*;
24
 
 
25
 
 
26
 
/**
27
 
 * A simple table to store EOF actions for each lexical state.
28
 
 *
29
 
 * @author Gerwin Klein
30
 
 * @version JFlex 1.4.1, $Revision: 1.1 $, $Date: 2008/05/09 09:14:11 $
31
 
 */
32
 
public class EOFActions {
33
 
 
34
 
  /** maps lexical states to actions */
35
 
  private Hashtable /* Integer -> Action */ actions = new Hashtable();
36
 
  private Action defaultAction;
37
 
  private int numLexStates;
38
 
 
39
 
  public void setNumLexStates(int num) {
40
 
    numLexStates = num;
41
 
  }
42
 
 
43
 
  public void add(Vector stateList, Action action) {
44
 
 
45
 
    if (stateList != null && stateList.size() > 0) {
46
 
      Enumeration states = stateList.elements();
47
 
      
48
 
      while (states.hasMoreElements()) 
49
 
        add( (Integer) states.nextElement(), action );   
50
 
    }
51
 
    else {
52
 
      defaultAction = action.getHigherPriority(defaultAction);
53
 
      
54
 
      for (int i = 0; i < numLexStates; i++) {
55
 
        Integer state = new Integer(i);
56
 
        if ( actions.get(state) != null ) {
57
 
          Action oldAction = (Action) actions.get(state);
58
 
          actions.put(state, oldAction.getHigherPriority(action));
59
 
        }
60
 
      }
61
 
    }
62
 
  }
63
 
 
64
 
  public void add(Integer state, Action action) {
65
 
    if ( actions.get(state) == null )
66
 
      actions.put(state, action);
67
 
    else {
68
 
      Action oldAction = (Action) actions.get(state);
69
 
      actions.put(state, oldAction.getHigherPriority(action));
70
 
    }
71
 
  }
72
 
 
73
 
  public boolean isEOFAction(Object a) {
74
 
    if (a == defaultAction) return true;
75
 
 
76
 
    Enumeration e = actions.elements();
77
 
    while ( e.hasMoreElements() ) 
78
 
      if (a == e.nextElement()) return true;
79
 
 
80
 
    return false;
81
 
  }
82
 
 
83
 
  public Action getAction(int state) {
84
 
    return (Action) actions.get(new Integer(state));
85
 
  }
86
 
 
87
 
  public Action getDefault() {
88
 
    return defaultAction;
89
 
  }
90
 
 
91
 
  public int numActions() {
92
 
    return actions.size();
93
 
  }
94
 
}