rahulkumaran / sudocode

GNU General Public License v3.0
26 stars 38 forks source link

Sudocode

KWoC 2018

forthebadge made-with-python
Issues Pull Requests
Gitter Build Status License: GPL v3

Sudocode, as the name suggests, is the supreme coding tool for everyone. Using sudocode, one actually need not learn how to code in C or C++.
This particular tool helps you with converting your pseudocode to code.
All you need to do is follow some rules laid here and you'll be good to go. For now, this particular thing only converts pseudocode to C code. But I'll soon be expanding this to convert pseudocode to python and C++ code too.

It's a fairly simple project and does not involve any Machine Learning, but yes, implementing this using ML is definitely on the cards.
But for now, it's going to be just some code written with some common sense to help achieve this.

Possible Functionalities That Can Be Performed

All the above mentioned functionalities can be written in the form of a pseudocode and will be converted to code by our program

How to Run

  1. Clone the source with git:

    $ git clone https://github.com/rahulkumaran/sudocode.git
    $ cd sudocode
  2. Running sudocode:

    $ python3 main.py path/filename.txt 
    e.g. - $ python3 main.py testfiles/sudocode.txt

    Note: Python 3.6 or later must be installed in your system in order to run this project

Rules To Be Followed While Writing Pseudocode

The last statement says print temp. Here, the application understands that temp means the variable temp and not the string temp to be printed. It also understands whether the variable mentioned is an integer or a float value and accordingly mentions the format specifier in C and C++.

You need not mention a negative gap as the application understands that it's supposed to give a negative gap.

Now, an example of a loop:

    for int i=10 to 1 and gap=2
    print i
    endfor

Here, the application understands that the program is supposed to print i as a variable and hence it print the value of i and not just i as it is.

As you can see above, endwhile is used at the end of the while loop.
So basically, you can enter any statement or code in while loop, just that it should end with an endwhile.

Incase you don't want to return anything, then you'll have to mention void. Now to make sure you have some statements within the function, you can follow the format as mentioned for all above avaiable functionalities.
Just make sure that you end your function with endfunction.
An example is given below that gives you a clearer picture of how to define statements within a function.

function test returns int with args int a, int b, int c
print test func
a++
b++
c++
a = b + c
return a
endfunction

As you can see above, there's a return statement. This statement is optional.
Incase you decide to return a value, just make sure you mention the value you want tor return.