Documentation


Introduction



ProCode is a programming language designed for educational purposes. It focuses on simplicity and easy code comprehension. This documentation covers the syntax and usage of ProCode, as well as the ProCodeInterpreter class that enables interpretation and execution of ProCode code with backend features.


ProCode Language



Class Declaration

To declare a class in ProCode, use the class keyword followed by the class name. Each class declaration must be followed by a block of code enclosed in curly braces.

class Person {
    // Class properties and methods
}

Property Declaration

To declare properties within a class, use the prop keyword followed by the property type and name.

class Person {
    prop string Name;
    prop int Age;
}

Object Creation

To create an object of a class, use the new keyword followed by the class name. Assign the object to a variable for further use.

person = new Person();

Property Assignment

To assign a value to a property of an object, use the dot notation with the object variable followed by the property name.

person.Name = "John";
person.Age = 30;

Printing Values

To print the value of a property, use the print keyword followed by the property or variable name enclosed in parentheses.

print(person.Name);
print(person.Age);

Backend Features



The ProCodeInterpreter class extends the functionality of the ProCode language by adding backend features.

Server-Side Processing

The ProCodeInterpreter class can be used for server-side processing in conjunction with web frameworks or server-side scripting languages. The interpret method can be modified to handle HTTP requests and perform server-side logic based on the received requests.

Database Connectivity

To connect the ProCodeInterpreter with a database, integration with database libraries in backend languages is necessary. This enables execution of database queries and data retrieval or storage. The interpreter's methods can be extended to handle database operations based on the ProCode code.

External APIs

The ProCodeInterpreter class includes functionality to interact with external APIs. The handle_request method makes HTTP GET requests to specified URLs and prints the response. This method can be modified to handle different HTTP methods and process responses based on specific requirements.


ProCodeInterpreter Class



The ProCodeInterpreter class allows interpretation and execution of ProCode code with backend features. It provides the following methods:

h

__init__()

The constructor method initializes the ProCodeInterpreter object and sets up the initial state of the interpreter.

interpret(code)

Interprets and executes the ProCode code passed as a parameter. It handles class declarations, property declarations, property assignments, printing values, and backend features such as server-side processing, database connectivity, and external API interactions.

handle_class_declaration(line)

Handles the declaration of a class in ProCode. It creates an entry in the variables dictionary to store the class and its properties.

handle_property_declaration(line)

Handles the declaration of properties within a class in ProCode. It adds the properties to the respective class entry in the variablesdictionary.

handle_property_assignment(line)

Handles the assignment of values to properties in ProCode. It updates the property values in the respective class entry in the variables dictionary.

handle_print(line)

Handles the printing of property values in ProCode. It retrieves the property values from the variables dictionary and prints them.

handle_request(url)

Handles the HTTP GET request to the specified URL in ProCode. It makes the request, receives the response, and prints the response content.

handle_database_query(query)

Handles the execution of a database query in ProCode. It connects to the database, performs the query, retrieves the results, and prints them.

Happy coding!