github.com/TekWizely/go-parsing/parser (go): Package parser implements the base components of a token analyzer, enabling the creation of hand-written parsers for generating Abstract Syntax Trees.  Some Features of this Parser:  Initiating a Parser  In addition to the `token.Nexter`, the Parse function also accepts a function which serves as the starting point for your parser:  The main Parser process will call into this function to initiate parsing.  You'll notice that the `Parser.Fn` return type is another `Parser.Fn`.  This is to allow for simplified flow control of your parser function.  Your parser function only needs to concern itself with matching the very next tokens(s) of input.  This alleviates the need to manage complex looping / restart logic.  Simply return from your method after (possibly) emitting an AST, and the Parser will manage the looping.  Switching contexts is as easy as returning a reference to another `Parser.Fn`.  You can shut down the main Parser loop from within your `Parser.Fn` by simply returning `nil`.  All previously emitted ASTs will still be available for pickup, but the parser will stop making any further `Parser.Fn` calls.  Your Parser function receives a `*Parser` when called and can use the following methods to inspect and match tokens:  Once you've processed one or more tokens, and built up an abstract syntax tree, you can emit it for further processing (for example, by an interpreter):  Sometimes, you may match a series of tokens that you simply wish to discard:  The Parser allows you to create save points and reset to them if you decide you want to re-try matching tokens in a different context:  A marker is good up until the next `Emit()` or `Clear()` action.  Before using a marker, confirm it is still valid:  Once you've confirmed a marker is still valid:  NOTE: Resetting a marker does not reset the parser function that was active when the marker was created. Instead it simply returns the function reference.  If you want to return control to the function saved in the marker, you can use this pattern:  When called, the `Parse` function will return an `ASTNexter` which provides a means of retrieving ASTs emitted from the parser:  See the `examples` folder for programs that demonstrate the parser (and lexer) functionality.
Keywords: golang|mit-license|multi-package|parsing-library