1. Introduction

A parser is a program or a function that can interpret the contents of an expression. Parsers are for example used in mathematical applications and programming languages. For mathematical applications a parser must be able to evaluate expressions like "2+3*(5.3-2.1)" and return the answer. And in programming languages a parser must be able to recognize commands like "IF" and "THEN" and handle them.

Normally an expression is entered as a string (a list of characters) into the computer. There are different methods on how to analyse and interpret and expression, see fow example Wikipedia.org for more background information. I will explain here a recursive parsing method for expressions as used for the math program SpeQ. The examples in this tutorial are written with IBasic and therefore use IBasic syntax. It is recommended to have a basic knowledge of IBasic or programming in general.

When facing the problem you can consider expressions like the following:
"2 + 3"
"2 + 3 + 4 + 5"
"2 + 3 - 4 - 5"
"4.2 * (2 + 3.5) ^ 2"

And when the parser is more advanced it can be able to evaluate mathematical functions and variables also:
"2 * Sin(0.25 * Pi)"
"Sqrt(36) / 2"


Copyright 2006 SpeQ Mathematics