001: /***** BEGIN LICENSE BLOCK *****
002: * Version: CPL 1.0/GPL 2.0/LGPL 2.1
003: *
004: * The contents of this file are subject to the Common Public
005: * License Version 1.0 (the "License"); you may not use this file
006: * except in compliance with the License. You may obtain a copy of
007: * the License at http://www.eclipse.org/legal/cpl-v10.html
008: *
009: * Software distributed under the License is distributed on an "AS
010: * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
011: * implied. See the License for the specific language governing
012: * rights and limitations under the License.
013: *
014: * Copyright (C) 2001-2002 Jan Arne Petersen <jpetersen@uni-bonn.de>
015: * Copyright (C) 2002 Anders Bengtsson <ndrsbngtssn@yahoo.se>
016: * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org>
017: * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de>
018: *
019: * Alternatively, the contents of this file may be used under the terms of
020: * either of the GNU General Public License Version 2 or later (the "GPL"),
021: * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
022: * in which case the provisions of the GPL or the LGPL are applicable instead
023: * of those above. If you wish to allow use of your version of this file only
024: * under the terms of either the GPL or the LGPL, and not to allow others to
025: * use your version of this file under the terms of the CPL, indicate your
026: * decision by deleting the provisions above and replace them with the notice
027: * and other provisions required by the GPL or the LGPL. If you do not delete
028: * the provisions above, a recipient may use your version of this file under
029: * the terms of any one of the CPL, the GPL or the LGPL.
030: ***** END LICENSE BLOCK *****/package org.jruby.lexer.yacc;
031:
032: /**
033: *
034: * @author jpetersen
035: */
036: public final class LexState {
037: public static final LexState EXPR_BEG = new LexState("EXPR_BEG");
038: public static final LexState EXPR_END = new LexState("EXPR_END");
039: public static final LexState EXPR_ARG = new LexState("EXPR_ARG");
040: public static final LexState EXPR_CMDARG = new LexState(
041: "EXPR_CMDARG");
042: public static final LexState EXPR_ENDARG = new LexState(
043: "EXPR_ENDARG");
044: public static final LexState EXPR_MID = new LexState("EXPR_MID");
045: public static final LexState EXPR_FNAME = new LexState("EXPR_FNAME");
046: public static final LexState EXPR_DOT = new LexState("EXPR_DOT");
047: public static final LexState EXPR_CLASS = new LexState("EXPR_CLASS");
048:
049: private final String debug;
050:
051: // BEGIN NETBEANS MODIFICATIONS
052: private int ordinal;
053: static {
054: EXPR_BEG.ordinal = 0;
055: EXPR_END.ordinal = 1;
056: EXPR_ARG.ordinal = 2;
057: EXPR_CMDARG.ordinal = 3;
058: EXPR_ENDARG.ordinal = 4;
059: EXPR_MID.ordinal = 5;
060: EXPR_FNAME.ordinal = 6;
061: EXPR_DOT.ordinal = 7;
062: EXPR_CLASS.ordinal = 8;
063: }
064:
065: public int getOrdinal() {
066: return ordinal;
067: }
068:
069: public static LexState fromOrdinal(int ordinal) {
070: switch (ordinal) {
071: case 0:
072: return EXPR_BEG;
073: case 1:
074: return EXPR_END;
075: case 2:
076: return EXPR_ARG;
077: case 3:
078: return EXPR_CMDARG;
079: case 4:
080: return EXPR_ENDARG;
081: case 5:
082: return EXPR_MID;
083: case 6:
084: return EXPR_FNAME;
085: case 7:
086: return EXPR_DOT;
087: case 8:
088: return EXPR_CLASS;
089: }
090: return null;
091: }
092:
093: // END NETBEANS MODIFICATIONS
094:
095: private LexState(String debug) {
096: this .debug = debug;
097: }
098:
099: public boolean isExprBeg() {
100: return this == EXPR_BEG;
101: }
102:
103: public boolean isExprEnd() {
104: return this == EXPR_END;
105: }
106:
107: public boolean isExprArg() {
108: return this == EXPR_ARG;
109: }
110:
111: public boolean isExprCmdArg() {
112: return this == EXPR_CMDARG;
113: }
114:
115: public boolean isExprEndArg() {
116: return this == EXPR_ENDARG;
117: }
118:
119: public boolean isExprMid() {
120: return this == EXPR_MID;
121: }
122:
123: public boolean isExprFName() {
124: return this == EXPR_FNAME;
125: }
126:
127: public boolean isExprDot() {
128: return this == EXPR_DOT;
129: }
130:
131: public boolean isExprClass() {
132: return this == EXPR_CLASS;
133: }
134:
135: public boolean isArgument() {
136: return this == EXPR_ARG || this == EXPR_CMDARG;
137: }
138:
139: public String toString() {
140: return debug;
141: }
142: }
|