@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface ParseMethod
The first parameter must be java.io.PushBackReader, java.io.Reader, java.io.InputStream, java.lang.String, java.io.File or other compatible class instance. Other compatible class must have a public method returning either java.io.InputStream of java.io.Reader. For example java.net.Socket could be used, because it has a method getInputStream(). If the first parameter is other than java.lang.String the size parameter must be other than default (-1).
If this method has more than one parameter, the rest are used as parser context and must be annotated with @ParserContext. If class contains more than one parse method, the parser context parameters must be the same in every parse method.
Use start to define the start nonterminal
Use size to specify buffer size.
Use charSet to specify used charset.
Set upper=true to convert input to upper-case
Set lower=true to convert input to lower-case
whiteSpace Terminals which are marked white-space are listed in whiteSpace array. White-space terminals are not processed in grammar level. White-space terminals can have reducer. Reducers are called when white-space input is read. If such reducer returns value, that value is inserted in input.
wideIndex If true the goto and jrs instructions are replaced with goto_w and jsr_w. Set this flag if compiled method is big.
eof Set eof terminal to differ from normal. This is useful only in sub-grammar
syntaxOnly If syntaxOnly is set, the reducer methods are not used in parsing. This can be used to check syntax only.
Examples:
Usage of one @ParserContext parameter
| Modifier and Type | Required Element and Description |
|---|---|
String |
start |
| Modifier and Type | Optional Element and Description |
|---|---|
String |
charSet |
String |
eof |
boolean |
lower |
int |
size |
boolean |
syntaxOnly |
boolean |
upper |
boolean |
useOffsetLocatorException |
String[] |
whiteSpace |
boolean |
wideIndex |
public abstract String start
public abstract int size
public abstract String charSet
public abstract boolean upper
public abstract boolean lower
public abstract String eof
public abstract String[] whiteSpace
public abstract boolean wideIndex
public abstract boolean syntaxOnly
public abstract boolean useOffsetLocatorException