KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > ParsingFrame


1 package jfun.parsec;
2
3 import jfun.util.Misc;
4
5 /**
6  * This class represents an error frame during parsing.
7  * <p>
8  * @author Ben Yu
9  * Dec 4, 2005 2:25:47 PM
10  */

11 public class ParsingFrame {
12   private final String JavaDoc module;
13   private final int ind;
14   private final Pos pos;
15   private final Parser parser;
16   /**
17    * To create a ParsingFrame object.
18    * @param module the module name.
19    * @param ind the index of the character within the source.
20    * @param pos the position of the character.
21    * @param parser the parser executed.
22    */

23   public ParsingFrame(String JavaDoc module, int ind, Pos pos,
24       Parser parser) {
25     this.ind = ind;
26     this.module = module;
27     this.parser = parser;
28     this.pos = pos;
29   }
30   /**
31    * Get the index of the character within the source.
32    */

33   public int getIndex() {
34     return ind;
35   }
36   /**
37    * Get the module name.
38    */

39   public String JavaDoc getModule() {
40     return module;
41   }
42   /**
43    * Get the Parser object executed.
44    */

45   public Parser getParser() {
46     return parser;
47   }
48   /**
49    * Get the position within the source.
50    */

51   public Pos getPosition() {
52     return pos;
53   }
54   public String JavaDoc toString(){
55     return module+" - " + pos+": "+parser.getName();
56   }
57   public boolean equals(Object JavaDoc obj) {
58     if(obj instanceof ParsingFrame){
59       final ParsingFrame other = (ParsingFrame)obj;
60       return ind==other.ind &&
61         Misc.equals(module, other.module);
62     }
63     else return false;
64   }
65   public int hashCode() {
66     return Misc.hashcode(module)*31+ind;
67   }
68 }
69
Popular Tags