Documentation

MasterThesis.LOOP.Parser

LOOP parser #

This file defines a simple parser for the LOOP language, written using the standard Parsec library. The accepted syntax for a loop program is defined as follows: $$ \begin{array}{lclcl} \texttt{Ident} & \ni & x, y & & \\ \texttt{Com} & \ni & P, Q & ::= & \texttt{SKIP} \mid x \; \texttt{=} \; \texttt{0} \mid x \; \texttt{=} \; y \mid x \; \texttt{=} \; x \; \texttt{+} \; \texttt{1} \\ & & & & \mid P \texttt{;} Q \mid \texttt{LOOP} \; x \; \texttt{DO} \; P \; \texttt{END} \end{array} $$

Some example programs can be found in the Examples folder.

References #

This work is strongly based on the following resources:

Parses a variable.

Equations
Instances For
    Equations
    Instances For
      def lexeme {α : Type} (p : Lean.Parsec α) :

      Parses a syntactic construct followed by a sequence of blank or tab characters.

      Equations
      Instances For

        Parses a newline character.

        Equations
        Instances For

          Parses a program file.

          Equations
          Instances For

            Parses one or more commands.

            Parses a single command.

            Parses a SKIP command with 'SKIP' syntax.

            Equations
            Instances For

              Parses a zeroing command with 'x = 0' syntax.

              Equations
              Instances For

                Parses an assignment command with 'x = y' syntax.

                Equations
                Instances For

                  Parses an increment command with 'x += 1' syntax.

                  Equations
                  Instances For

                    Parses a sequential command

                    Parses a LOOP command with 'LOOP x DO P END' syntax.