KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > importer > rose > parser > RoseToken


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: RoseToken.java,v 1.2 2005/06/08 06:20:36 nickb Exp $
16  */

17 package org.eclipse.emf.importer.rose.parser;
18
19 /**
20  * This is the RoseToken class. Lexer uses this class to create a vector of tokens.
21  *
22  * @version 1.0, 04/08/98
23  * @author Alex Glebov, glebov@us.ibm.com
24  */

25 //************************************************************************
26
//* class RoseToken *
27
//************************************************************************
28
public class RoseToken
29 {
30   public final static int OBJECT = 0;
31   public final static int LIST = 1;
32   public final static int LEFT_PAREN = 2;
33   public final static int RIGHT_PAREN = 3;
34   public final static int VERTICAL_BAR = 4;
35   public final static int KEY = 5;
36   public final static int STRING = 6;
37   public final static int VALUE = 7;
38
39   protected int tokenType;
40   protected String JavaDoc tokenValue;
41   protected int lineNum;
42
43   public RoseToken(int tokenType, String JavaDoc tokenValue)
44   {
45     this.tokenType = tokenType;
46     this.tokenValue = tokenValue;
47   }
48
49   public int getType()
50   {
51     return tokenType;
52   }
53
54   public String JavaDoc getValue()
55   {
56     return tokenValue;
57   }
58
59   public String JavaDoc getToken()
60   {
61     if (tokenType == OBJECT)
62     {
63       return "object";
64     }
65     else if (tokenType == LIST)
66     {
67       return "list";
68     }
69     else if (tokenType == VALUE)
70     {
71       return "value";
72     }
73     else if (tokenType == LEFT_PAREN)
74     {
75       return "(";
76     }
77     else if (tokenType == RIGHT_PAREN)
78     {
79       return ")";
80     }
81     else if (tokenType == VERTICAL_BAR)
82     {
83       return "|";
84     }
85     else if (tokenType == KEY)
86     {
87       return "key: " + getValue();
88     }
89     else
90     {
91       return "string: " + getValue();
92     }
93   }
94 }
95
Popular Tags