01: /*
02: *******************************************************************************
03: * Copyright (C) 2002-2004, International Business Machines Corporation and *
04: * others. All Rights Reserved. *
05: *******************************************************************************
06: */
07: package com.ibm.icu.dev.tool.localeconverter;
08:
09: public class TokenTransition extends ComplexTransition {
10: public static final TokenTransition GLOBAL = new TokenTransition(
11: SUCCESS);
12: public static final String SEPARATOR_CHARS = ";"
13: + SpaceTransition.SPACE_CHARS;
14:
15: public TokenTransition(int success) {
16: super (success);
17: //{{INIT_CONTROLS
18: //}}
19: }
20:
21: public boolean accepts(int c) {
22: return (c > 0)
23: && !EOLTransition.GLOBAL.accepts(c)
24: && !SpaceTransition.GLOBAL.accepts(c)
25: && ((SEPARATOR_CHARS.indexOf((char) c) < 0)
26: || SymbolTransition.GLOBAL.accepts(c)
27: || QuoteTransition.GLOBAL.accepts(c) || EscapeTransition.GLOBAL
28: .accepts(c));
29: }
30:
31: protected Lex.Transition[][] getStates() {
32: return states;
33: }
34:
35: private static final Lex.Transition[][] states = {
36: { //state 0:
37: new SymbolTransition(-1),
38: new QuoteTransition(-1),
39: new EscapeTransition(-1),
40: new Lex.StringTransition(EOLTransition.EOL_CHARS,
41: Lex.IGNORE_PUTBACK, -2),
42: new Lex.StringTransition(SEPARATOR_CHARS,
43: Lex.IGNORE_PUTBACK, -3),
44: new Lex.EOFTransition(-4),
45: new Lex.DefaultTransition(Lex.ACCUMULATE_CONSUME,
46: -1) },
47: { //state 1:
48: new SymbolTransition(-1),
49: new QuoteTransition(-1),
50: new EscapeTransition(-1),
51: new Lex.StringTransition(EOLTransition.EOL_CHARS,
52: Lex.IGNORE_PUTBACK, SUCCESS),
53: new Lex.StringTransition(SEPARATOR_CHARS,
54: Lex.IGNORE_PUTBACK, SUCCESS),
55: new Lex.EOFTransition(SUCCESS),
56: new Lex.DefaultTransition(Lex.ACCUMULATE_CONSUME,
57: -1) },
58: { //state 2: failure - unexpected EOL
59: new Lex.ParseExceptionTransition("unexpected EOL in token") },
60: { //state 3: failure
61: new Lex.ParseExceptionTransition(
62: "unexpected seperator character in token") }, { //state 4: failure
63: new Lex.ParseExceptionTransition("unexpected EOF in token") }, };
64: //{{DECLARE_CONTROLS
65: //}}
66: }
|