Skip to content

z-rui/lexgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lexgen

Lexgen is a lexer generator tool for Go, which mimics the functionality of POSIX lex.

Usage

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:

  • %s and %x
  • Start conditions, BEGIN.
  • yymore, yyless, yytext (note: yytext is []byte).

Lexer interface

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.

About

Lexer generator in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors