Syntax

Syntax 

Changing syntax of programming languages

1. Reversed assignment operator  a + b -> a

Allows assignment to flow from left to right like we write

in more natural direction

2. Tagging keywords  {while} ... {/while}

This allows to easy introduce new keywords into language

and to easy find mistakes in control flow of programs

3. Reversed object notation  b@agi  instead of agi.b

4. Reversed function declaration  {fun} a b -> f  and  call  a b -> f
 
These two changes allow to combine input and output in one line

which is also more natural
5. New for loop syntax {for} 0 -> i++ < n 
 
Pseudo Code Examples

Classes and Functions

{module}

    {class} mind  	! comment

        [p1, p2, ... , pn] -> parameters	! reversed assignment

        {fun} array -> algorithm	! function declaration

            ! processing parameters

            return results

        {/fun} ! tagged keywords

    {/class}


    {fun}	! main function

        agi -> mind	! adding object agi to class mind

        in -> parameters@agi -> algorithm@agi -> out

        ! combined input and output and function call

        ! with new reversed object notation using @             

    {/fun}

{/module}	! nameless module and main function


Loops and Functions

{module} primes 

        {fun} n -> Eratosthenes       ! subroutine declaration
             
            primes [ n ], 1 ->  l         ! assignment operator

            0 -> i, 3 -> index_square         ! proc sift

            first, last, factor ! proc mark sieve

            {for} 0 -> k++ < n       ! fill with true, new loop syntax

                true -> primes[k] 

            {/for}   
                
         
            {while} index_square < n         !proc sift

                {if} primes[i]             !proc mark sieve

                    0 + index_square -> first
                    0 + n  -> last 
                    i + i + 3  -> factor
                    false  -> primes[first] 

                    {while} last - first > factor 

                        first + factor  -> first
                        false  -> primes[first]

                    {/while}
                    
                {/if}              ! proc mark sieve

                i + 1  -> i
                2 * i * (i + 3) + 3  -> index_square

            {/while}          ! proc sift

            ' 2'  -> out  ! print out

            {for} 0 -> i++ < n        ! print out, new loop syntax

                {if} primes[i] 

                    {if} 2 * i + 3 > n 
                        break
                    {/if}

                    ' ' 2 * i + 3  -> out
                    l + 1  -> l

                    {if} l % 10 == 0 
                        '\n'  -> out
                    {/if}   
          
                {/if}        ! if

            {/for}         ! print out

            '\n number : '  l  -> out

        {/fun}            ! erato fun

     
        {fun}  ! main function
 
        1000 -> Eratosthenes           ! subroutine call

        {/fun}

{/module}


File System

f -> (name, type, options)	file definition

f -> open	

f -> close

f -> var	read from file

var -> f	write to file


Concurrent Function

{cofun} a b -> f1  ! function declaration
			. . .
{/cofun}

{cofun} c d -> f2 ...

{cofun} g h -> f3 ...

! run in parallel

a1 b1 -> f1 | c1 d1 -> f2 | g1 h1 -> f3


Implementation

This pseudo code could be implemented

as a dynamically typed and interpreted language

written in C++ and named Tellur (Earth in Latin)

Comments

Popular posts from this blog

Hybrid Markup Language

Stream - Syntax-Oriented Language

iTeraTor Universal Data Language