-
Notifications
You must be signed in to change notification settings - Fork 9
/
Terminal$NumericValue.java
62 lines (52 loc) · 1.6 KB
/
Terminal$NumericValue.java
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
/* -----------------------------------------------------------------------------
* Terminal$NumericValue.java
* -----------------------------------------------------------------------------
*
* Producer : com.parse2.aparse.Parser 2.2
* Produced : Fri Aug 17 11:27:55 CEST 2012
*
* -----------------------------------------------------------------------------
*/
package org.murillo.abnf;
import java.util.ArrayList;
import java.util.regex.Pattern;
public class Terminal$NumericValue extends Rule
{
private Terminal$NumericValue(String spelling, ArrayList<Rule> rules)
{
super(spelling, rules);
}
public static Terminal$NumericValue parse(
ParserContext context,
String spelling,
String regex,
int length)
{
context.push("NumericValue", spelling + "," + regex);
boolean parsed = true;
Terminal$NumericValue numericValue = null;
try
{
String value =
context.text.substring(
context.index,
context.index + length);
if ((parsed = Pattern.matches(regex, value)))
{
context.index += length;
numericValue = new Terminal$NumericValue(value, null);
}
}
catch (IndexOutOfBoundsException e) {parsed = false;}
context.pop("NumericValue", parsed);
return numericValue;
}
public Object accept(Visitor visitor)
{
return visitor.visit(this);
}
}
/* -----------------------------------------------------------------------------
* eof
* -----------------------------------------------------------------------------
*/