.L

L File

Lex Language Source File
Ask a question
QUICK ANSWER

An L file is a Lex or Flex source file - a plain-text specification for a lexical analyzer (tokenizer), used in compiler and interpreter development. Open it in any code editor; to build the scanner, run flex on it. The extension is also used for Lisp source and Unix man pages, so check the file content if unclear.

Developer: Mike Lesk and Eric Schmidt (Lex, Bell Labs); Vern Paxson (Flex) Category: Developer Files Open standard MIME: text/plain
OPENS ON Windows macOS Linux
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Sep 6, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the L file format?

A .l file is a plain-text lexical-analyzer specification written in the Lex language. It defines how an input character stream should be broken into tokens - the first step in building a compiler, interpreter, or text-processing tool.

The format was created at Bell Labs in 1975 by Mike Lesk and Eric Schmidt as part of the Unix toolchain. Today virtually all .l files are processed by Flex (Fast Lexical Analyzer), the GNU-era open-source successor developed by Vern Paxson, though the source syntax remains largely the same.

A .l file is divided into three sections separated by %% marker lines:

  • Definitions - named regex macros and %option directives
  • Rules - pairs of regular expressions and C action code that fire on a match
  • User code - optional helper C functions appended verbatim to the output

An optional %{ ... %} block near the top injects C declarations directly into the generated scanner. Running flex yourfile.l (or lex yourfile.l) produces lex.yy.c, a self-contained C source file implementing the scanner as a deterministic finite automaton. That output is compiled with a C compiler and typically linked with a Yacc/Bison grammar file to build a complete language processor.

Note that .l is also used for Lisp source files and Unix troff manual-page sources, so file context matters when identifying the type.

Security & safety

RISK: LOW

A .l Lex source is plain text and safe to open in an editor. The only caution: the rules contain C action code, and a malicious .l could embed harmful C that runs once compiled. Review .l files from untrusted sources before running flex and building them.

Format details

in a nutshell
FULL NAMELex Language Source Fileaka Lex source, Flex source file
DEVELOPERMike Lesk and Eric Schmidt (Lex, Bell Labs); Vern Paxson (Flex)since Lex, 1975 (Unix); standardized in POSIX (lex utility)
MIME TYPEtext/plain
TYPEPlain-text lexical-analyzer specification (source code)
STANDARDOpen · royalty-free
This extension is also used by…
  • Lisp source file (.l) - Some Lisp dialects/implementations use .l for source code; plain text, but a different language than Lex.
  • Unix man-page / troff source (.l) - Section-l (local) manual pages in nroff/troff source; documentation, not a lexer spec.
  • Interleaf / WordPerfect library (.l) - Legacy library or list files in older document systems; rare.

Programs that open L files

Windows3 apps
Notepad Open-source Open directly to view/edit the lexer specification.
Visual Studio Code Free Open the .l to read/edit; install a Lex/Flex syntax extension for highlighting.
Flex (win_flex via WinFlexBison) Open-source Run 'win_flex file.l' to generate the C scanner source on Windows.
macOS1 app
TextEdit / VS Code Free Open to read/edit; run 'flex file.l' in Terminal to build the scanner.
Linux2 apps
Flex Open-source Run 'flex file.l' to generate lex.yy.c, then compile with cc.
GNU Emacs / Vim / gedit Open-source Open the .l in any editor to read or modify the lexer rules.

Technical details

deep spec
Format typePlain-text lexical-analyzer specification (source code)
EncodingASCII / UTF-8 plain text; no binary header or magic bytes
File structureThree sections separated by `%%`: definitions, rules, and user C code
Section 1 - DefinitionsNamed regex macros and `%option` directives (e.g., `%option noyywrap`)
Section 2 - RulesPairs of regular-expression patterns and C action code blocks executed on match
Section 3 - User codeOptional C helper functions copied verbatim into the generated output file
C-code injection block`%{ ... %}` prologue near the top injects C declarations into the generated scanner
Primary output`lex.yy.c` - a C source file implementing a DFA-based scanner
MIME type`text/plain` (informal alias: `text/x-lex`)
Processing tools`lex` (AT&T/POSIX), `flex` (GNU), `win_flex` (Windows via WinFlexBison)
Typical file size1 KB - 100 KB
Scanner algorithmCompiles regex rules to a deterministic finite automaton (DFA) at build time
Common pairingCombined with a `.y` Yacc or Bison grammar file to build a complete compiler front-end
Platform supportUnix, Linux, macOS natively; Windows via MSYS2, Cygwin, or WinFlexBison
Extension ambiguity`.l` is also used for Lisp source files and Unix troff man-page source - file context required
ReleasedLex, 1975 (Unix); standardized in POSIX (lex utility)
Latest versionFlex 2.6.4 (2017) is the de-facto current implementation reading .l files
Open standardYes · royalty-free
Specificationpubs.opengroup.org

L conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with L files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about L files.

Frequently asked questions

What is a .L file?
It is a Lex/Flex source file - a plain-text specification of a lexical analyzer (tokenizer). Flex compiles it into C source for a scanner. '.l' is also used for Lisp and man pages.
How do I open a .l file?
Open it in any code editor (VS Code, Notepad++, Vim, Emacs). It is plain text.
How do I run or compile a .l file?
Run 'flex yourfile.l' to generate lex.yy.c, then compile that C file (e.g. 'cc lex.yy.c -lfl'). On Windows use win_flex from WinFlexBison.
What's the difference between a .l and a .y file?
.l is a Lex/Flex lexer spec (tokenizing); .y is a Yacc/Bison grammar (parsing). They are usually used together to build a compiler.
Is .l the same as a Lisp file?
Not necessarily. Some Lisp dialects use .l for source code, but in compiler tooling .l almost always means a Lex/Flex lexer specification. Check the file content.
Is Lex still used, or is it Flex now?
Flex is the modern, maintained implementation and reads the same .l files; the original AT&T Lex is largely historical, but the .l source format remains standard.

References

1POSIX lex utility specificationpubs.opengroup.org
2Flex - The Fast Lexical Analyzergithub.com

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.JPGJPEG Image
4.PARTPartial Download File
5.RPMSGRestricted Permission Message
6.MDMarkdown Document
7.DATProgram Data File (generic)
8.EXEWindows Executable (Portable Executable)
9.BINCD/DVD Disc Image (BIN/CUE)
10.DBSQLite Database File

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z