Structured programming is a programming paradigm created to improve the clarity, quality and development time for computer programs. The main features of this paradigm is the intensive use of control flow statements and avoid ussage of goto statement that can lead to spaghetti code potential difficult to maintain.

Structured programming emerged in the late 1950s with the appearance of the ALGOL 58 and ALGOL 60 programming. We teach this paradigm due to it’s clarity and popularity. To learn this paradigm we create a special language designed for learning.

Level-1 Dialect

Level-1 is a minimalist structured programming language. It is statically typed 3’rd generation language. We have designed this language for education. The objective is to allow students to learn this language quickly and create a compiler using another language. This is the most easy to learn Level dialect. Also known as Level-1.

Hypothetical usability

  • Console applications
  • Simple algorithms
  • Compiler research

We plan to create several compilers. First compiler will be implemented from scratch using Rust. Maybe in the future new compilers can be implemented using other languages: C++, D, Assembly.


Level application consist of one main program and subroutines. Every program is stored in a file that is the main module. In a module we organize members in regions: Types are declared first then constants then variables and last the executable sections.

Level application has a main program section that hase the same name as the main module name. In the main module we can import other modules and libraries. The main module can define global variables that are visible in all module  executable sections.


We have selected some of most notable features we think Level 1 should have. Even if the language is stripped down to essential it is going to be a challenge to implement. This is because of the Exceptions and Memory Management model. Due to it’s procedural approach is still a high-level and modular language.

#Feature NameDescription
1ProjectWe can define a project structure;
2ModulesA module is a file  components that can be reused for multiple programs;
3ProceduresA sub-program. Subroutine with side-effects;
4FunctionsA sub-program that receive parameters and create one single result;
5User typesUser can define a type composition based on pre-defined types;
6Static typesConstants, variables and parameters must be declared with type information;
7Composite typesCollection of multiple elements of same type or different types;
8Optional argumentsWe can create optional parameters in program, procedures and functions;
9Arguments by nameEvery argument of functions or procedures can be pass by name or by position;
10Exception managementWe can prevent program errors by catching exceptions and analyze them;


We have try to avoid using one symbol to for multiple purposes. This is to reduce complexity of the compiler and also for improved learning experience. Most operators are based on single symbol. Some are based on 2 symbols.

In the next syntax description “…” represent content and “,,,” represents a sequence of elements. In descriptions vertical bar “|” represents alternative use when an operator have multiple purposes.

$GeneralGlobal constants | System variables | Static variables
+MathNumeric addition
MathSubtraction | Change sign (unary operator
*MathNumeric multiplication
/MathReal number division
\MathBackslash is used for rational numbers
%MathModulo operator
^MathPower operator. Example: x^n is the x to the power of n.
=PolymorphicAssignment operator | Clone operator
~BitwiseWe use “~” prefix for bit level operators: { ~not, ~or, ~and, ~xor }
>LogicalGreater then (strong comparison)
<LogicalLess then (strong comparison)
:GeneralDefine type | Association | Paired up
;GeneralThe end of statement | End of program or modle
.GeneralDecimal separator | Member of : {program, module, library, record}
,GeneralEnumeration for elements in a sequence
&StringsString concatenation | String to collection concatenation
<-StringsString injector operator. Used with format placeholder “#”
#StringsFormat placeholder, used like #s, #n or  #(x, ap:m.d). | Compiler directive.
|VectorVector comprehension: v = { x | x in <collection> and <expression> }
‘…’StringsASCII string literal: ‘this is an ASCII string’
“…”StringsString literal: “this isn’t my fault”
\StringsBackslash is used as escape character in strings \0 = NUL
(…)GeneralMath expressions | tuple | parameters | subroutine call | expressions
(,,,)TuplesMath n-Tuple collection of elements like (1,2,3,’a’,’b’,’c’)
[n,m]CompositeIdentify a matrix member using an 2 indexes m[i,j]
[n]CompositeIdentify a matrix member using an 1 index v[i]
[,,,]VectorVector literal [1,2,3] | Matrix [[1,2],[3,4]]
{,,,}OptionEnumeration of elements {Zeros = 0, Unos = 1, Dos = 2}
@PointerPointer declaration. Use like: variable name: @type;
?PointerGet address of variable to assign-it to a pointer use like: pointer = ?variable
!CommentSingle line comment or end of line comment;

Digraph Operators

We call operators based on two symbols digraphs. In the description of digraph operators we use “…” to represent content. We use “,,,” for enumerated elements. In descriptions sometimes we use vertical bar “|” for operators that can have multiple purposes depending on the context.

(..)RangeRange operator (n..m) define a subtype of
[..]SliceVector slicing operator [n..m], where n>=0 and m  < length
=>FunctionDeclare function result type
:=AssignAssign value to variable | Modify variable
<>LogicalIs not equal | disjunctive
==LogicalIs equal to comparison | Deep comparison
>=LogicalGreater then or equal to | Numeric relation
<=LogicalLess then or equal to | Numeric relation
+=ModifierIn-place modifiers ( -=, +=, /=, *=, %=, ^= )
<<Bit/mathShift bits to the left
>>Bit/mathShift bits to the right
CommentsSingle line comment (not an operator)
{*…*}CommentsMultiple line comment | Expression comment

Program statements

A program is created from small structures that are expressions specific to a programming language that are called statements. A statement is one or more lines of text that starts at beginning of the line and ends using “;”. Statement can start with spaces and contains keywords, identifiers and literals connected with operators.

  • Keywords: are English words that are reserved by Level and have a predefined purpose;
  • Identifiers: are names for elements created by the users to define a program ;
  • Literals: are sequences of numbers and symbols representing data;
  • Symbolic operators: are based on one or two special characters;
  • Keyword operators: are specific to logical expressions;

Simple statements

Simple statements are using one single line or several lines terminated with one “;” symbol.

Some simple statements:

  • white space: can contain spaces, tabs and empty line terminated with LF or CR/LF;
  • line comment: contains 0 or several spaces followed by operator “!” and a short text;
  • statement comment: is a text fragment following a statement with “!” to the end of the line;
  • pass: has the form “pass;” has significance of “success”. It is recommended as a region placeholder.


  pass; ! this is an empty statement that does nothing

Composite statements

Composite statements are blocks of code also named code sections. These sections contain other statements that can be simple or composite statements. This is a nested structure or parent/child hierarchical structure. A composite section is ending with “end” keyword.

Procedure Main

In the next example we create a program having a single _main_ procedure . Procedure main is mandatory section in any program. A procedure contains simple statements. We use a _do_ statement to demonstrate one anonymous section.

procedure main is
  r:Integer; !local result variable 
  ! Nested anonymous section
  let !start do statement
    i=10, x=15: Integer; !two local variable
end procedure;

Level comments

We create several comment notations to allow developers to create great documentation for a level program. In fact the main goal of level is to offer great code readability. This require good comments for every code section.

FORTRAN comments

  1. Single line comment start with “!” at beginning of new line.
  2. End of statement comment after “; !” at the end of line.
  3. End of line comment for multi-line statement between “!” and the end of line.

Ada comments

Simple comments can be done using 3 alternative forms:

  1. Single line comment starts with “–” at beginning of line.
  2. Full line separator starts with “–” and continue with “-” to the end of line.
  3. End of statement comment after “; –” at the end of line.

Block comments (Sage)

A block comment is a text enclosed using following operator: {*…*}. Block comments can support a text fragment spanning one or several lines including other block comments. This form of comments is also good to make comments inside expressions. This comment style is Sage Code style and not found in other languages.

{* comments *};
{* multi line comment
   can span multiple rows.

Comment Usability

With block comments one can comment segment of code or parts of a complex expression to experiment with code simplification for debug purposes. Block comments can be nested with other comments. This notation is specific to Level and not used in any other language.


A separator is a on line comment that starts with two dash comment and continue with dashes to the end of the line.  End of the line symbol “;” is not necessary for a comment line. We can use separator to highlight a larger set of comment lines to create a block like documentation before the method specification.

! This is a separator comment very common in Level
! We can use this kind of comments to document the code

Code indentation

In the written form of many languages, an indentation is an empty space at the beginning of a line to signal the start of a new paragraph. Many computer languages have adopted this technique to designate “paragraphs” or other logical blocks in the program.

Paragraph indentation levels:

This paragraph is indented by 0 spaces. indented level 0
  This paragraph is indented by 2 spaces. indented level 1
    This paragraph is indented by 4 spaces. indented level 2
      This paragraph is indented by 6 spaces. indented level 3
        This paragraph is indented by 8 spaces. indented level 4

Indentation rules

  • Level code use mono-space font that means every letter has the same width: “DejaVu Sans Serif”
  • Level uses 2xN spaces for code indentation from left to right where N=level of indentation
  • Level single line comment (–) start at begging of a line and is not indented
  • Level multi line comments can start at the indentation level N=0 or current indentation level with sibling code
  • Level rules for code indentation are mandatory and verified by the compiler.

Program indentation

  • The program keyword, region keywords, begin and end are aligned on left side with 0 indentation;
  • Between the begin and end all members are indented using 2xN spaces where N is the level of indentation;
  • Content of every code region must be indented from left 2xN spaces depending on the number of nested blocks;
  • Region definition keywords are using same indentation level as the section keyword;


! We use bang system for single line comment
-- declare module members
procedure test() is 
  pass; !This statement is indented by 2 spaces 
  if TRUE then 
    pass; !This statement is indented by 4 spaces 
    fail; !This statement is indented by 4 spaces 
  end if; 
  pass; !This statement is indented by 2 spaces 
end procedure;

procedure main is
  -- declare local variables
  -- local sum() function
  function sum(a, b:Integer) => Integer is
    return 0;
  end function;

-- start executable region
  test; !call procedure test
  r_var := sum(1,2) !call function sum()
-- catch exceptions in recover region
  when exception.code==0 then
    fail;   !this makes program to fail
  when exception.code>100 then
    resume; !this makes program to resume
-- close resources and create reporting logs
  pass; !this statement is indented by 2 spaces
end procedure;


You need to login to view the rest of the content. Please . Not a Member? Join Us