-
Notifications
You must be signed in to change notification settings - Fork 0
Quick start
The PonyScript compiler is a tool that transforms source code written in PonyScript into C++ code. Then this C++ code is compiled using GCC (GNU Compiler Collection) into an executable file.
-
Translation to C++: Source code in PonyScript is translated into equivalent C++ code, preserving the structure and logic of the program.
-
Compilation using GCC: The generated C++ code is compiled using GCC, resulting in the creation of an executable file.
-
Performance: Compiling to C++ allows leveraging optimizations available in C++, thereby enhancing the performance of the executable file.
-
Portability: The resulting executable file can be run on various platforms supported by GCC without needing to recompile the source code.
-
Integration with Existing Libraries: The ability to use libraries written in C++ or having a connection with it expands the development capabilities in PonyScript.
- Possible Compatibility Issues: Using GCC may lead to some compatibility issues, especially when porting the program to platforms not supported by GCC.
int magic(int argc, char *argv[])
{
neighln("Hello World");
}
This example demonstrates a program printing "Hello World" to the console.
In the project directory, there must be a .ponycfg file where project settings are specified.
[File Name] = pony
Your code should be in .psc files.
pony [path to project folder]
The main library of the language is lib.dll, it is automatically included in your project.
- Main methods of lib:
- neigh(string): function to print a string to the console.
- neighln(string): function to print a string to the console with a newline.
- read(): function to input data from the console.
- readkey(): function to wait for a key press.
- str(): function to convert bool, int, double to string.
- to_int(): function to convert string to int.
- range(int, int): function returns List of numbers in range.
-
Methods of the
ponystringclass:- fromInt(int value): Creates a
ponystringobject from an integer value. - fromDouble(double value): Creates a
ponystringobject from a floating-point number. - split(char delimiter = ' '): Splits the string into substrings based on the specified delimiter.
- removeExtraSpaces(): Removes extra spaces from the string.
- replaceSubstring(const ponystring& oldSubstr, const ponystring& newSubstr): Replaces substrings in the string with other substrings.
- strip(const std::string& chars = " \t\r\n"): Removes specified characters from the beginning and end of the string.
- toUpperCase(): Converts the string to uppercase.
- toLowerCase(): Converts the string to lowercase.
- trim(): Removes spaces from the beginning and end of the string.
- isEmpty(): Checks if the string is empty.
- isDigit(): Checks if the string consists only of digits.
You can make a formatted string use this sintax f"some text {code} text"
- fromInt(int value): Creates a
- Methods of the
Listclass:- append(T data): Adds an element to the end of the list.
- toString() const: Returns a string representation of the list.
- sort(): Sorts the elements of the list.
- remove(const T& value): Removes the specified element from the list.
- remove_index(size_t index): Removes an element at the specified index.
- operator[]: Allows accessing elements of the list by index.
- clear(): Clears the list.
- getSize() const: Returns the current size of the list.
To include a library, use the friend command.
friend math // This command includes the math library