1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 | package Torello.CSS;
import java.util.Vector;
/**
* This class may be instantiated by <B STYLE='color: red;'><I>both</I></B> the Tokenizer
* <B STYLE='color: red;'><I>and </I></B> the individual Static-Build Methods offered by each of
* the individual Token-Classes. This class is used to relay that a Parse-Error has occred during
* part of the Tokenization Process.
*/
public class TokenizeError
{
/**
* The last known location within the input Code-Point {@code int[]}-Array where a valid
* {@link CSSToken} instance was generated before the Parse-Error Occured.
*/
public final int sPos;
/**
* The exact location of the input Code-Point {@code int[]}-Array that was being analyzed when
* it was ultimately decided that a Parse-Error had unequivocally occured.
*/
public final int ePos;
/**
* The {@link CSSToken} class whose {@code 'consume'} method was being executed which uncovered
* this {@code TokenizeError}. Specifically, if the Class {@link Str} Method
* {@link Str#consume 'consume'} was running when the error was found then this {@code public}
* constant field would be assigned {@code Str.class}.
*/
public final Class<? extends CSSToken> parsingClass;
/** The CSS where the error occured. {@code subStr = new String(css, sPos, ePos-sPos); } */
public final String subStr;
/**
* The Tokenizer's various {@code 'cosnume'} methods will attempt to provide a thoughtfully
* worded Error-Message depicting what has gone wrong. Those message's {@code String}-text
* content will be saved to this {@code public} field.
*/
public final String message;
<T extends CSSToken> TokenizeError(
final int[] css,
final int sPos,
final int ePos,
final Class<? extends CSSToken> parsingClass,
final String message
)
{
this.sPos = sPos;
this.ePos = ePos;
this.subStr = new String(css, sPos, ePos-sPos);
this.parsingClass = parsingClass;
this.message = message;
}
void throwException()
{ throw new TokenizeException(toString()); }
public String toString()
{
return
"Class: [" + parsingClass.getSimpleName() + "] Build/Parse\n" +
"Input CSS-Text: [" + subStr + "]\n" +
"Message:\n\t" + message;
}
}
|