Dictionary entry
lex
Last updated
Meanings
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.
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.
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 singular | lexes |
|---|---|
| past tense | lexed |
| past participle | lexed |
| -ing form | lexing |
| plural | lexes |
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
Word family
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?
Choose one answer.
Lexing is the first stage, splitting characters into tokens; checking grammar is parsing, not lexing, and translating is later code generation.
Make it your own
Write a sentence using “lex”, then check it and compare it with the examples above.