Lexer: meaning, definitions and examples

💻
Add to dictionary

lexer

 

[ ˈlɛksər ]

Noun
Context #1 | Noun

computer programming

A lexer is a software tool used for breaking input into pieces called tokens. It is an essential component of a compiler or interpreter, responsible for analyzing the source code and converting it into a stream of tokens for further processing.

Synonyms

lexical analyzer, scanner, tokenizer.

Which Synonym Should You Choose?

arrow down
Word Description / Examples
lexer

This term is primarily used in the context of programming and computer science. It's usually mentioned when discussing the early stages of compilation where source code is processed.

  • The lexer divides the source code into a series of tokens.
  • Before parsing, the code is passed through a lexer.
tokenizer

This term is used widely not only in programming but also in natural language processing (NLP). It refers to the process of breaking a stream of text into tokens, which can be words, phrases, or other meaningful units.

  • In text processing, the tokenizer splits input sentences into words.
  • The tokenizer in the application separates email addresses from plain text.
scanner

This word has a broader use case but is often applied in programming when referring to the process of reading and interpreting streams of characters. It's also used outside of programming in contexts like reading documents or barcodes.

  • The scanner reads the characters one by one and groups them into tokens.
  • Modern printers often come with built-in scanners.
lexical analyzer

This is a more formal term than 'lexer' and might be used in academic or technical discussions. It refers specifically to the process of analyzing sequences of characters in programming languages.

  • The lexical analyzer is responsible for converting the input code into meaningful tokens.
  • In many compilers, the lexical analyzer is implemented as a separate module.

Examples of usage

  • The lexer scans the source code and identifies keywords, operators, and identifiers.
  • After tokenizing the input, the lexer passes the tokens to the parser for syntax analysis.

Translations

Translations of the word "lexer" in other languages:

🇵🇹 analisador léxico

🇮🇳 लेक्सर

🇩🇪 Lexer

🇮🇩 lexer

🇺🇦 лексер

🇵🇱 lekser

🇯🇵 字句解析器 (じくかいせきき)

🇫🇷 analyseur lexical

🇪🇸 analizador léxico

🇹🇷 leksik analizör

🇰🇷 렉서

🇸🇦 محلل لغوي

🇨🇿 lexikální analyzátor

🇸🇰 lexikálny analyzátor

🇨🇳 词法分析器 (cí fǎ fēn xī qì)

🇸🇮 leksikalni analizator

🇮🇸 lexíkönnunarforrit

🇰🇿 лексикалық талдаушы

🇬🇪 ლექსიკური ანალიზატორი

🇦🇿 leksik analizator

🇲🇽 analizador léxico

Etymology

The term 'lexer' is a short form of 'lexical analyzer,' which dates back to the early days of compiler design in the 1950s. Lexers were introduced to separate the concerns of lexical analysis from other parsing tasks, leading to more modular and efficient compiler implementations.