What is a parser and what does it do?
For example, what would an HTML parser do in python?

Recommended Answers

All 4 Replies

Member Avatar for iamthwee

They're special functions designed to make your life EASIER for reading and writing, in this example, HTML.

They're special functions designed to make your life EASIER for reading and writing, in this example, HTML.

Paser can thought of a computer program whch is used to translate one form of information to another form of information.

Thanks,
Maniraj Patri

Parsing often means "perform syntax analysis" on a program or a text. It means check if a text obeys given grammar rules and extract the corresponding information. For example, suppose that you define the rule that the structure of a question in english is auxiliary verb + subject + main verb + rest . Then the output of the statement parse("Are they playing football?") could be a hierarchy of tuples, or other objects, like this

("question",
    ("auxiliary verb", "are"),
    ("subject", "they"),
    ("verb", "playing"),
    ("rest", "football"),
)

Programs and compilers handle such trees more easily than raw text.

commented: Thanks a lot +1

Thanks for the help..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.