Participle is a parser library for Go that lets developers define parsers in an idiomatic Go style. It uses annotated Go structs to describe grammar rules and produce the parsed AST at the same time. This approach feels familiar to Go developers because it resembles the way struct tags are used for formats such as JSON. The library supports a rich grammar syntax with captures, recursive captures, grouping, alternatives, repetition, lookahead, and literal matching. It also supports custom capture behavior, union-like parser structures, and custom parsing hooks for more advanced grammars. Participle is useful when developers want readable parser definitions without switching to a separate grammar file or external parser generator.
Features
- Defines grammars with annotated Go structs
- Produces AST structures directly from parser definitions
- Supports captures, recursive captures, groups, alternatives, and repetition
- Provides positive and negative lookahead syntax
- Supports custom capture logic and text unmarshaling
- Includes union type support and custom parser hooks