Skip to content

Zemux1613/WhileInterpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grammar

While programmes are inductively defined as follows:

  1. xi := xj + c, xi += i and print x are while programm.
  2. If P1 and P2 are while programms, then P1;P2 is a while programm.
  3. If P1 is a while programm, then while xi != 0 do P1 end is a while programm.

Derived from this inductive definition, a context-free grammar for while-programmes is the following:

G = (N, A, P, programm) with
N = {programm, operator, i},
A = {-, +, :=, ;, while, do, end, x, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, print},
P = {
programm -> xi = xi operator i | xi += i | programm;programm | while xi != 0 do programm end | print xi;
i -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 1i | 2i | 3i | 4i | 5i | 6i | 7i | 8i | 9i;
operator -> + | -
}

Parsing

https://en.wikipedia.org/wiki/Parsing

asd

Research