Skip to content

JusMave/Customed-Programming-Language-Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

The Micro Language

Informal description of Micro

A program of the Micro language has only integer data. The possible actionsare the following:

  • Input values of a list of variables (read).
  • Output/print the values of a list of expressions (write).
  • Assign (the value of) an expression to a variable.
  • Each expression is a sequence of the common arithmetic operations of integers: addition, minus, multiplication, integer division (result is an integer).

The grammar of a Micro programming language has the following features:

  • Comment starts with two dashes (–) and ends at the end of the line.
  • Each program starts with the word “begin” and ends with the word “end”.
  • Each statement ends with a “;”.
  • Each statement is either a read, or a write, or an assignment statement.

A sample program

   -- a simple micro program
   -- good luck. It is a comment

   begin
   read(x, y, z); -- input three integers
   a := x+y;
   b := 314;
   c := 1 + a * (b - 1) / 2;
   write(a, b, c, (a+b+c)/(x+y) );
   end

A grammar of Micro

< program> --> begin <statement-list> end
<statement-list> --> <statement> {<statement>}
<statement> --> <read-stmt> | <write-stmt> | <assign-stmt>
<assign-stmt> --> id := <expression>;
<read-stmt> --> read ( <id-list> );
<write-stmt> --> write ( <expression-list> );
<id-list> --> id | {, id }
<expression-list> --> <expression> {, }
<expression> --> ???

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages