Lexgen is a lexer generator tool for Go, which mimics the functionality of POSIX lex.
Specify the lex rules in the following format:
prologue
%%
defs
%%
rules
Prologue is copied verbatim (which should usually start with a package statement),
except that some imports may be inserted.
The defs and rules sections are almost identical to POSIX lex. The following features are supported:
%sand%x- Start conditions,
BEGIN. yymore,yyless,yytext(note:yytextis[]byte).
The generated lexer exposes a method Lex(yylval *yySymType) int.
The user should define yySymType (usually it is generated by the parser
generator) to hold the semantic value of a token.
The return value indicates the "major" value of the token.