This page will explain how to construct a parser and how to use that parser.
Currently katydid supports several parsers:
- reflected go structures
Constructing a Parser
A parser parses a specific serialization format or other parsable text or bytes. We need to put our unparsed text, bytes or other structure into a parser so that it can be validated by relapse or transcoded to some other format.
We can also construct a protocol buffer parser.
We can even construct a parser for a reflected go structure.
Walking the Tree
If you want to use a parser for you own use case, here is a simple walk function.
We should always first call the Next method and check the error. Next we can retrieve a value, which can be of type int, double, uint, string, bytes or a bool. Lastly we can check whether the current position is a terminating leaf in the tree or if we can go down the tree and finally come back up. Please see the godoc for the parser.Interface and parser.Value.