Workshop: A practical approach to parsing

This is a page for a workshop at MCH2022 about parsing. It serves as both an interactive page to be used during the workshop and as an introduction to parsing. Use the show buttons to reveal the explainatory texts.

What is 3 + 4?

(type '=' in the input field above to see the answer.)

What is 3 + 2 * 2 - 1? 9 or 6?

What is 12 / 2/2? 12 or 3?

Abstract syntax tree

Railroad diagrams or production rules

Terminals

Grammar:

Input:

Output:

Literals and keywords

Grammar:

Input:

Output:

Non-terminals

Grammar:

Input:

Output:

Add and substract

Grammar:

Input:

Output:

Syntax tree labeling

Grammar:

Input:

Output:

Left and right recursion

Grammar:

Input:

Output:

Bar symbol

Grammar:

Input:

Output:

Extensions: SEQ, OPT, CHAIN, and LIST

Grammar:

Input:

Output:

Exercise: Tabloit

Using IParse Studio write down the grammar for Tabloid: The Clickbait Headline Programming Language. If you want to extend the language, you might need to extend the interpreter in the JavaScript file interpreter.js. The best way to do this, is to clone https://github.com/FransFaase/MCH2022ParserWorkshop and open the doc/IParseStudio.html file in browser.

Interpreting parser

Grammar:

Input:

Output:

Demonstration: C-grammar

Load this C-grammar into IParse Studio and let it parse this preprocessed C-program.

Target application

Version history

Resources


Acknowledgements

The code for showing the syntax tree is based on Syntactic Tree Viewer by Christos Christodoulopoulos, which makes use of d3.js and itself is inspired by D3.js Drag and Drop Zoomable Tree by Rob Schmuecker.

Author: Frans Faase
Personal website
email address