Skip to content

A new language with a new vision of programming. Follow the pipe !

License

Notifications You must be signed in to change notification settings

iasebsil83/Pipe_lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pipe Lang

Discover a new way of coding, following the pipe...

 

 

I] Description

Have you ever though about coding in another way than only from up to down, line by line, execution after execution ? What about a program that is not always following the same direction, but the one you told him to do.

That's exactly the reason why the Pipe programming language has been made for.
Draw a shape, a pipe circuit and your program will follow the path as far as possible !

There are so many possibilities, action and reaction, direction and redirection...
Who knows what can be done with this language ?

Maybe it's time for you to test it...

 

 

II] Installation

WARNING : Make sur you don't have a 'pipe' command already installed on your system.
(Keep calm, Pipe_lang will not overwrite it in any cases)

Install

To install Pipe_lang :

Get the repository from GitHub :

git clone https://github.com/iasebsil83/Pipe_lang

Then, go into the repository folder and launch the installer : (requires root privileges to install correctly)

cd Pipe_lang
sudo ./install

Now you should be able to run command 'pipe'.

Uninstall

To uninstall Pipe_lang : (requires root privileges)

sudo rm -rf /opt/Pipe_lang /usr/bin/pipe /usr/share/nano/pipe.nanorc

There you go !

 

 

III] Use

Syntax

The Pipe language has a pretty simple syntax consisting in 3 types of statements :

  • Nodes (o )
  • Pipes (| - / \ < > ^ v +)
  • Command (x=2, echo $x...)

Any other statement will not be interpreted, it is just floating text.

 

1) Start

When a script starts its execution, the Pipe interpreter is looking for the first character 'o' in the file followed by a space.
This is the first node.

 

2) Executing node

Each time a node is reached, the command written to the right of this node is executed.
Then, depending on the exit code of this command, execution continues :

  • DOWN : if error code is 0 (No problem in command)
  • LEFT : if error code is not 0 (Problem occured)

(The command will be executed as a BASH command)
A node must always be followed by a space, even if there is no command after it.

 

3) Catching execution

As we said, execution goes LEFT or DOWN depending on the last command executed.
It is MANDATORY to have a character receiving the execution if it occurs.
If the execution goes to a pipe character, it will follow the pipe.
If it is another character, program stops here.

 

4) Pipe redirection

In the case execution goes to a pipe character, the execution flow will follow the line until a next node is found.
Here is some rules on pipe redirection :

- A node have 3 possible inputs (UP/DOWN/LEFT) and 2 possible outputs (DOWN/LEFT)

- A pipe has no proper 'sens'.
  (The same character '|' can be either traveled from UP to DOWN and from DOWN to UP)

- Depending on the sens the execution goes, the flow can be turned.
  (For character '/' :
   At X, going to the RIGHT :      |
                               X---/  Flow is turning UP.
   BUT
   At X, going to the LEFT :   /---X
                               |      Flow is turning DOWN.
  )

- Flow can be fully returned in the opposite way by using a pipe as a wall.
  (At X, going to the RIGHT :  X---|
   Flow will go back to the LEFT after touching the wall)

- Character '+' is allowing pipes to be crossed without changing their direction.
  (Don't confuse this:    |     with this:    |
                       ---|---             ---+---
                          |                   |
                    UP/DOWN line        UP/DOWN line
                    LEFT/RIGHT walls    LEFT/RIGHT line
  )

- To force the flow to go in a precise direction, use '< > ^ v'.
  (At X, going to the RIGHT :  X---<---
   Flow will go to the LEFT at '<'
   Very useful for intersections)

- If a node outputs the execution to another node directly,
  it is the same thing as if there was a pipe between them.
  ( o <=> o
    o     |     oo <=> o--o
          o
  )

To have a complete description of pipe redirection, a table is available next to this document in file 'redirections.png'.

 

Running a script

When you think your code is ready to be executed, you can run it using :

 pipe myScript.pipe

Other options are available, use pipe --help to see them.

 

That's it for the Pipe language, hoping it leads to beautiful codes !

 

**LAST NOTE : ** A syntax coloration file for the nano editor is included and will be installed in /usr/share/nano/pipe.nanorc if the editor is already installed on your computer.

 

 

Contact : i.a.sebsil83@gmail.com
Youtube : https://www.youtube.com/user/IAsebsil83
GitHub repo : https://github.com/iasebsil83

Let's Code !                                                By I.A.