Dictionary entry

lex

verb, nouncomputingtechnical

Last updated

UK/leks/
US/leks/

Meanings

  1. verbtransitive or intransitivecomputingtechnical

    In computing, to scan a stream of characters and split it into meaningful tokens, as a first step before parsing.

    Grammar: Can take an object (lex the input) or be used without one (the program lexes before parsing).

    Patterns

    • lex something
    • lex a stream
    • lex before parsing

    The compiler first lexes the source file, turning characters into tokens.

    Before parsing, the program must lex the input and remove comments.

    This function lexes the text and returns a list of tokens.

  2. nouncountabletechnicalspecialist

    A single inflected word form, such as 'run' or 'runs', considered as a unit; a lexeme is the abstract set of such forms.

    Grammar: Common in linguistics; the plural is 'lexes'.

    Patterns

    • a lex
    • the lex of a word

    In that theory, 'go' and 'went' are two different lexes of the same lexeme.

    Each lex in the dictionary entry is listed separately.

  3. nouncountablelegalformalold-fashioned

    A law, especially in ancient Rome or medieval Europe; often used in the names of specific legal codes.

    Grammar: Chiefly historical or legal; usually appears in fixed Latin phrases.

    Patterns

    • the lex
    • lex something

    The lex was inscribed on bronze tablets for all citizens to see.

    Medieval scholars studied the lex as part of Roman law.

Word forms

third person singularlexes
past tenselexed
past participlelexed
-ing formlexing
plurallexes

Common combinations

lex a string
The routine lexes a string of digits into number tokens.
lex the input
You should lex the input before you try to parse it.
lexer and parser
Most compilers separate the lexer and parser into different modules.
lexical analysis
Lexical analysis is the formal name for what it means to lex.

Synonyms and how they differ

tokenize
More common in programming; it means the same as 'lex' but often implies splitting into tokens without the formal parsing context.
scan
Broader: scanning can mean any systematic reading, while 'lex' specifically produces tokens for a parser.

Word family

lexer noun
A program or tool that performs lexing.
lexical adjective
Relating to words or vocabulary, especially in a language or a computer language.
lexeme noun
The abstract unit of meaning that a set of inflected forms (lexes) share.

Commonly confused: lex or lexis? lex or lexicon?

lex vs lexis

In linguistics, 'lexis' means the vocabulary of a language, while 'lex' is a single word form or the act of tokenizing.

lex vs lexicon

A lexicon is a dictionary or the full vocabulary of a language; 'lex' is not a dictionary but a unit or a process.

Practice

In compiler design, what does a program do when it lexes the source code?

Make it your own

Write a sentence using “lex”, then check it and compare it with the examples above.

Your sentence stays on this page and is not sent anywhere.

Explore more words