No longer maintained. See #3
My own programming written in Python (now you see why it's called Cobra).
Right now, no external modules are needed. You just need the Python programming language.
All you have to do is:
python execute.py <name-of-cobra-file>
You also have 2 other options:
cobra <name-of-cobra-file>
./cobra.sh <name-of-cobra-file>
I have an example.cobra
file in the root directory of this repository.
You can run it by running the following command in your terminal:
python execute.py example.cobra
or by using the other two options above: Windows, Mac or Linux.
The basic syntax for a Cobra program is: name of function any arguments to be passed in to the function
. That's a bit confusing. So for example, if you type say Hello, World!
, say
is the function and Hello, World!
is the argument. To create a comment, use the # sign. For example: # This is a comment. It will be ignored by Cobra
.
The current functions for Cobra are:
Description: Print to the console
Arguments:
- text: Text to print out to the console.
Example: say Hello, World!
Description: Creates a variable
Arguments:
- name: Variable name
- value: Variable value. Can be an existing variable or string.
Example: create_var test "This is a test"
Description: Creates a function
Arguments:
- name: Function name
Example:
create_function say_hello:
say "hello"
To execute a function:
# You just type the function's name
say_hello
Description: Imports a file into your current executing program.
Arguments:
- filename: The name of the file you want to import. Can end with .cobra or not.
Example: import helloworld
Inside helloworld.cobra, there is a function called testing_func
. To run it, just type it in like usual.
import helloworld
testing_func
The import
function will always import everything as of this commit.
Description: Runs a line of Python code in the Cobra environment.
Arguments:
- query: The query that you want to run.
Example: run_python "print('Hello World!')"
This is meant for compatibility with Python.
For examples of all of these functions, consult the example.cobra
file.