plex(1)
β¨ NAME β¨
plex β the Pascal Lex lexical analyzer generator, bestie. π
π«Ά USAGE π«Ά
lex [options] lex-file[.l] [output-file[.pas]]
that's the whole vibe, no cap β¨
π OPTIONS π
-vβ Verbose mode, aka the tea-spilling option.plexwrites out a readable description of the lexical analyzer it just generated, and it drops it next tolex-filewith the shiny new extension.lst. π-oβ Optimize mode.plexgoes to the gym and optimizes the DFA tables so you get a minimal DFA. slay. π₯
π DESCRIPTION π
okay so plex is a program generator. Its whole job is generating Turbo Pascal source code for a lexical analyzer subroutine, and it builds that from the specification of an input language that you wrote as a regular expression grammar. iconic behavior fr fr π¦
Here's the pipeline: plex parses the source grammar that lives in lex-file (default suffix .l), then writes the constructed lexical analyzer subroutine to the output-file you specified (default suffix .pas). If you didn't specify an output file at all? No stress β output goes to lex-file with the new suffix .pas instead. π«
And if any errors show up during compilation, the error messages get written to the list file β that's lex-file with the new suffix .lst. (so yeah, that .lst file is doing double duty depending on your flags, iykyk)
The generated output file contains a lexical analyzer routine called yylex, and it's implemented like this:
function yylex : Integer;
Your main program has to call this routine to actually run the lexical analyzer. The return value of yylex usually denotes the number of a token that the lexical analyzer recognized β check the return routine in the LexLib unit for the deets. At end-of-file, yylex normally returns 0. π
The code template for the yylex routine can be found in the yylex.cod file. This file is needed by TP Lex when it constructs the output file. It must be present either in the current directory or in the directory from which TP Lex was executed β TP Lex searches these directories in the indicated order. π§
NB: For the Linux/Free Pascal version, the code template is searched in some directory defined at compile-time instead of the execution path, usually /usr/lib/fpc/lexyacc. (yes, different rules, don't come for me π)
The TP Lex library (LexLib) unit is required by any programs that use Lex-generated lexical analyzers, so you're gonna have to put an appropriate uses clause into your program or unit that contains the lexical analyzer routine. The LexLib unit also provides various useful utility routines β see the file lexlib.pas for further information. πΈ
π MORE INFORMATION π
For more information, see the documentation that comes with plex and yacc. go read it, bestie, it's giving educational π
π AUTHOR π
Albert Graeff (<ag@muwiinfa.geschichte.uni-mainz.de>, <Dr.Graef@t-online.de>) β the actual main character who made all this happen π
β SEE ALSO β
and that's the whole page, babe π this one's from Free Pascal, dated 10 Jan 2000, and it's plex(1) β go generate some lexical analyzers, you got this π«Άβ¨
π¦ where this page comes from
- debian bookworm: fp-utils-3.2.2 3.2.2+dfsg-20 Β· GPL-2.0-or-later
- debian trixie: fp-utils-3.2.2 3.2.2+dfsg-46 Β· GPL-2.0-or-later
- ubuntu jammy: fp-utils-3.2.2 3.2.2+dfsg-9ubuntu1 Β· GPL-2.0-or-later
- ubuntu noble: fp-utils-3.2.2 3.2.2+dfsg-32 Β· GPL-2.0-or-later
- ubuntu questing: fp-utils-3.2.2 3.2.2+dfsg-46
- ubuntu resolute: fp-utils-3.2.2 3.2.2+dfsg-49 Β· GPL-2.0-or-later
- ubuntu stonking: fp-utils-3.2.2 3.2.2+dfsg-51 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms