posix compatible lex utility which compiles to ~60KB
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
rofl0r 83dc48ff03 bump version to 2.15 2 years ago
.gitignore update .gitignore 2 years ago
Makefile use tiny lz77 decompressor for form templates 2 years ago
README add README 2 years ago
allprint.c allprint: bump to latest opensolaris 2 years ago
form2hdr.c use tiny lz77 decompressor for form templates 2 years ago
header.c turn ldefs.c into a header 2 years ago
ldefs.h turn ldefs.c into a header 2 years ago
lex.1 add -o outputfile option for flex compat 2 years ago
libmain.c libmain: bump to latest opensolaris 2 years ago
lsearch.c import heirloom lex from CVS 2 years ago
lzcomp.h use tiny lz77 decompressor for form templates 2 years ago
main.c use tiny lz77 decompressor for form templates 2 years ago
nceucform axe -Y option and put all external files into the lex binary 2 years ago
ncform axe -Y option and put all external files into the lex binary 2 years ago
nrform axe -Y option and put all external files into the lex binary 2 years ago
once.h turn ldefs.c into a header 2 years ago
parser.y turn ldefs.c into a header 2 years ago
reject.c import heirloom lex from CVS 2 years ago
search.h import heirloom lex from CVS 2 years ago
sgs.h bump version to 2.15 2 years ago
sub1.c turn ldefs.c into a header 2 years ago
sub2.c turn ldefs.c into a header 2 years ago
sub3.c turn ldefs.c into a header 2 years ago
wcio.c wcio.c: include ldefs.h instead of using a wrong error() prototype 2 years ago
yyless.c import heirloom lex from CVS 2 years ago
yywrap.c import heirloom lex from CVS 2 years ago

README

lex
===

a POSIX compatible lex implementation.

about
-----

latest version taken from heirloom (which in turn is a modified version of
opensolaris'), with a number of improvements.

- stand-alone makefile
- parser.y modified to compile with posix yacc
- added -o outputfile command line option
- packed external "driver" files into executable
(this makes the lex binary completely dependency-less)
- limited support for some bison features
- some tweaks for smaller binary size

opensolaris repos and illumos have been harvested for improvements, but there
were almost none (almost exclusively lint-related cosmetics). as illumos seems
to use flex as main lex program, it is unlikely it will see further
improvements there.

in fact, the heirloom version used here has been skillfully ported to support
64bit, so it is actually superior to its predecessor, which still has
pointer-to-int truncation issues.

purpose
-------

lex is a standard utility mandated by POSIX, so it's supposed to be available on
every POSIX system.

usually, `GNU flex` is used for this purpose.
however flex is like most GNU tools feature-packed and thus quite bloated.
including documentation, it takes up about 1.3MB of disk space (0.7MB w/o).
flex has the additional disadvantage of requiring GNU m4.

some people even prefer to hand-craft their lexer, because they consider
GNU flex to be too heavy-weight as a dependency.

this version of lex compiles to a ~70KB binary with musl libc, and in less than a
second on PCs built during the last 10 years.

unfortunately, many projects requiring a lexer already use lots of flex features
(probably due to the lack of an alternative - until now), so someone routinely
building packages from source will likely need to have flex installed anyway.
however, a casual user or developer might well find that POSIX lex is more than
sufficient for his project, and opt for this implementation, or prefer to have
a tiny statically linked lex binary he can use on all his linux systems without
having to carry around an additional bag of required files.

license
-------

the opensolaris CDDL license applies to this project.