Lex (software)

« Back to Glossary Index

Open source and Versions
– Some versions of Lex are now open-source.
– Open-source versions of Lex are distributed with open-source operating systems like OpenSolaris and Plan 9 from Bell Labs.
– The popular open-source version of Lex is called flex.
– Flex is not derived from proprietary coding.
– Flex is known as the fast lexical analyzer.

Structure of a Lex file
– Lex files are divided into three sections: definitions, rules, and C code.
– The definitions section defines macros and imports header files written in C.
– C code can be written in the definitions section and will be copied into the generated source file.
– The rules section associates regular expression patterns with C statements.
– When the lexer sees text matching a pattern, it executes the associated C code.

Example of a Lex file
– An example Lex file for the flex version of Lex recognizes strings of numbers and prints them out.
– The file has a definitions section, a rules section, and a C code section.
– The rules section uses regular expressions to match strings of digits.
– The C code section contains the main function that calls the lexer.
– The input given to flex will be converted into a C file called lex.yy.c.

Using Lex with other programming tools
– Lex can be used with parser generators like Yacc or Bison.
– Lex limits rules to those describable by regular expressions.
– Parser generators use a formal grammar to parse an input stream.
– Lex is often used to produce a token-stream for parser generators.
– Scannerless parsing refers to parsing the input character-stream directly, without a distinct lexer.

Lex and make
– Make is a utility used to maintain programs involving Lex.
– Make assumes that a file with the extension ‘.l’ is a Lex source file.
– The make internal macro LFLAGS can be used to specify Lex options for make.
– Lex can be integrated into the make workflow for automatic compilation.
– Make simplifies the build process for Lex programs.

Lex (software) (Wikipedia)

Lex is a computer program that generates lexical analyzers ("scanners" or "lexers").

Lex
Original author(s)Mike Lesk, Eric Schmidt
Initial release1975; 49 years ago (1975)
Repository
Written inC
Operating systemUnix, Unix-like, Plan 9
PlatformCross-platform
TypeCommand
LicensePlan 9: MIT License

Lex is commonly used with the yacc parser generator. Lex, originally written by Mike Lesk and Eric Schmidt and described in 1975, is the standard lexical analyzer generator on many Unix systems, and an equivalent tool is specified as part of the POSIX standard.

Lex reads an input stream specifying the lexical analyzer and writes source code which implements the lexical analyzer in the C programming language.

In addition to C, some old versions of Lex could generate a lexer in Ratfor.

« Back to Glossary Index

Submit your RFP

We can't wait to read about your project. Use the form below to submit your RFP!

Gabrielle Buff
Gabrielle Buff

Just left us a 5 star review

google

Great customer service and was able to walk us through the various options available to us in a way that made sense. Would definitely recommend!

google

Stoute Web Solutions has been a valuable resource for our business. Their attention to detail, expertise, and willingness to help at a moment's notice make them an essential support system for us.

google

Paul and the team are very professional, courteous, and efficient. They always respond immediately even to my minute concerns. Also, their SEO consultation is superb. These are good people!

google

Paul Stoute & his team are top notch! You will not find a more honest, hard working group whose focus is the success of your business. If you’re ready to work with the best to create the best for your business, go Stoute Web Solutions; you’ll definitely be glad you did!

google

Wonderful people that understand our needs and make it happen!

google

Paul is the absolute best! Always there with solutions in high pressure situations. A steady hand; always there when needed; I would recommend Paul to anyone!

facebook
Vince Fogliani
recommends

The team over at Stoute web solutions set my business up with a fantastic new website, could not be happier

facebook
Steve Sacre
recommends

If You are looking for Website design & creativity look no further. Paul & his team are the epitome of excellence.Don't take my word just refer to my website "stevestours.net"that Stoute Web Solutions created.This should convince anyone that You have finally found Your perfect fit

facebook
Jamie Hill
recommends

Paul and the team at Stoute Web are amazing. They are super fast to answer questions. Super easy to work with, and knows their stuff. 10,000 stars.

facebook

Paul and the team from Stoute Web solutions are awesome to work with. They're super intuitive on what best suits your needs and the end product is even better. We will be using them exclusively for our web design and hosting.

facebook
Dean Eardley
recommends

Beautifully functional websites from professional, knowledgeable team.

google

Along with hosting most of my url's Paul's business has helped me with website development, graphic design and even a really cool back end database app! I highly recommend him as your 360 solution to making your business more visible in today's social media driven marketplace.

yelp

I hate dealing with domain/site hosts. After terrible service for over a decade from Dreamhost, I was desperate to find a new one. I was lucky enough to win...

google

Paul Stoute has been extremely helpful in helping me choose the best package to suite my needs. Any time I had a technical issue he was there to help me through it. Superb customer service at a great value. I would recommend his services to anyone that wants a hassle free and quality experience for their website needs.

google

Paul is the BEST! I am a current customer and happy to say he has never let me down. Always responds quickly and if he cant fix the issue right away, if available, he provides you a temporary work around while researching the correct fix! Thanks for being an honest and great company!!

google

Paul Stoute is absolutely wonderful. Paul always responds to my calls and emails right away. He is truly the backbone of my business. From my fantastic website to popping right up on Google when people search for me and designing my business cards, Paul has been there every step of the way. I would recommend this company to anyone.

yelp

I can't say enough great things about Green Tie Hosting. Paul was wonderful in helping me get my website up and running quickly. I have stayed with Green...