parser

parser — noun

1. a tool, program, or person that takes a piece of text or code and breaks it into

1.nounC1
Definition

a tool, program, or person that takes a piece of text or code and breaks it into smaller parts so that the structure and meaning of each part can be checked.

Example

Marcus wrote a small parser to read the JSON files his app downloaded each night.

wrote a parser to read [format]

The parser threw an error when it reached a missing comma on line 47.

the parser threw an error

Common collocations
  • write a parser
  • build a parser
  • the parser fails
  • JSON parser
  • HTML parser
  • XML parser
  • command-line parser
Synonyms
  • analyzer

    broader; any tool that examines data, not just for structure

  • interpreter

    in computing, runs the parsed code rather than just checking its shape

  • lexer

    narrower; splits input into tokens, which a parser then groups into structures

Grammar Patterns

a parser for [language/format]

Usage Note

Almost always refers to a piece of software in modern use; the older sense of a person who parses sentences in school grammar lessons is now rare. Often paired with the format it handles: HTML parser, JSON parser, XML parser.

Common Mistakes

I used a parser to write the code.
I used a parser to read the code.
a parser reads and analyzes input; it does not generate code.
The parser is a kind of compiler.
The parser is one part of a compiler.
a compiler usually contains a parser as a step, but the two are not the same thing.

Word family

  • parse
    verbC1
  • parsing
    nounC1
  • parsable
    adjectiveC2
  • unparseable
    adjectiveC2

Synonym discussion

Sense: noun/1

These four words name different stages of how software handles code or text. A lexer scans raw input and groups characters into tokens like keywords, numbers, and punctuation; it does not care about how those tokens fit together. A parser takes the tokens from a lexer and checks whether they form a valid structure, building a tree that shows how each piece relates to the others. An interpreter goes one step further: it walks through that structure and actually runs the instructions, line by line. A compiler also uses a parser inside it, but instead of running the code, it translates the whole program into another form, such as machine code, which a computer can run later. So if you write 'x = 3 + 4', the lexer sees four tokens, the parser sees an assignment with an addition inside, the interpreter would set x to 7 right away, and a compiler would produce a file that does the same thing every time it is launched.

Common collocations

Nouns

  • JSON parser
  • HTML parser
  • XML parser
  • command-line parser
  • parser error
  • parser library

Phrases

  • write a parser
  • build a parser
  • the parser fails
  • run through the parser

Prepositions

  • parser for
  • parser in

Etymology

LatinMiddle FrenchEnglish

From the verb 'parse', which entered English in the 1500s in Latin grammar schools, where pupils were asked to name each word in a sentence by its part of speech. 'Parse' itself comes from the Latin question 'pars orationis?' meaning 'which part of speech?'. The '-er' ending names a person or thing that does the action, so a parser was first a pupil or teacher doing this exercise. From the late 1900s, computer scientists borrowed the word for software that does a similar job on programming code, and this is now its main meaning.