Home

Awesome

BASIC INTERPRETER

This project is a basic interpreter for a very simple language.

Language Rules

The syntax for this language is defined by the following grammar:

<stmts> -> <stmt> | <stmt><eos> | <stmt><eos><stmts>

<stmt> -> <var> : <expr> | display<msp><var> <eos> -> <lf> | <cr><lf>

<var> -> A | B | C | D | E <expr> -> <term> | <term> + <term> | <term> - <term> | <term> * <term> | <term> / <term> <msp> -> <sp> | <sp><msp>

<term> -> <var> | <const>

<const> -> <digit> | <digit><const>

<digit> -> 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0

Note:

<sp> => space character <lf> => line feed character <cr> => carriage return character

Also,

Set Up

Pre-requisites

Instructions:

Sample Program

File content:

A:1 B:A+0 display A

Output: 1

More sample programs in the samples directory.