parsing Getting started with parsing What you need for parsing


In performing parsing, before starting, the grammar for the language needs to be specified. A source of tokens is also needed for the parser.

The parser could be hand-written code, or a parser generator tool could be used. If a parser generator tool is used, then that tool will need to be downloaded and installed if it has not already been included in your platform.

Grammar definitions

A grammar for a parser would normally need to be written in a context free form. A notation like BNF (Backus-Naur Form) or EBNF (Extended Back-Naur Form) is often used for this. Other notations commonly used to describe programming languages might be railroad diagrams.

Lexical Analysis

Tokens are normally provided for the parser by a lexical analyser (or scanner). More details can be found in the documentation for a lexical analyser (TBC).

Parsing Techniques

To hand-code a parser, an appropriate algorithm would need to be chosen that suits both the language been parsed and the means of implementation. Parsing algorithms are classified into the two types of top-down parsing and bottom-up parsing. A (recursive) top-down parser is easier for a beginner to learn when starting to write parsers.

Parser Generator Tools

The most common way of creating a parser is to use a parser generator tool. There are many such tools, but some of the most commonly used are: