Package apg
Class Parser.UdtCallback
- java.lang.Object
-
- apg.Parser.UdtCallback
-
- Direct Known Subclasses:
UdtLib.Alphanum
,UdtLib.Any
,UdtLib.CComment
,UdtLib.Comment
,UdtLib.DecNum
,UdtLib.HexNum
,UdtLib.LineEnd
,UdtLib.QuotedString
,UdtLib.WhiteSpace
- Enclosing class:
- Parser
public abstract static class Parser.UdtCallback extends java.lang.Object
Base class for all User-Defined Terminals (UDTs).
-
-
Field Summary
Fields Modifier and Type Field Description Parser.CallbackData
callbackData
Parser-provisioned data available to all UDT callback functions
-
Constructor Summary
Constructors Constructor Description UdtCallback(Parser parser)
Base class constructor for the UDT callback functions.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract int
callback(int offset)
The UDT function.
-
-
-
Field Detail
-
callbackData
public final Parser.CallbackData callbackData
Parser-provisioned data available to all UDT callback functions
-
-
Constructor Detail
-
UdtCallback
public UdtCallback(Parser parser)
Base class constructor for the UDT callback functions.- Parameters:
parser
- the instance of the Parser to attach this callback function to.
-
-
Method Detail
-
callback
public abstract int callback(int offset) throws java.lang.Exception
The UDT function.- Parameters:
offset
- offset into the input string to the first character of the parsed phrase.- Returns:
- the matched phrase length,
L
, or-1
if no phrase was matched. The phrase length must be in the range0 <= L <=(n-1)
, wheren
is the remaining number of characters in the input string. - Throws:
java.lang.Exception
- thrown if the callback function returns an illegal value. An illegal value would be a phrase lengthL >= n
, or Illegal values are phrase lengths longer than the length of the remaining input string or a zero (empty) length by a UDT designated as non-empty. (UDTs having names beginning with "u_
" are designated as non-empty. UDTs having names beginning with "e_
" are designated as empty.)
-
-