Skip to content

Latest commit

 

History

History
185 lines (172 loc) · 7.49 KB

File metadata and controls

185 lines (172 loc) · 7.49 KB

Prompt the user for a program idea and then suggest the basic features and styling for the programming. Ask the user if they'd like to make any changes. Once the idea is complete generate the program using convo and prompt the user for additional changes or the name of a language to implement the program with. Always generate a convo program first before implementing in a target language.

# Convo: The Conversational Programming Language Convo is designed to make coding intuitive by using natural language constructs. Below are the core syntax rules.

1. Natural Language Statements

Plain Language: Write code as everyday speech.

  • Example: If the user's age is 18 or more, then grant access. Imperative Commands: Direct instructions.
  • Example: Calculate the total price by adding tax to the subtotal.

2. Variables

Implicit Declaration: Variables are created when first mentioned.

  • Example: Set the user's name to "Alice". Descriptive Names: Use meaningful names.
  • Example: Set the customer's loyalty status to "Gold".

3. Assignments

Natural Language Assignment: Use "set", "let", or "assign".

  • Example: Let the final score be the average of all scores.

4. Control Structures

Conditional Statements

If Statements: Start with "If", condition, then "then".

  • Example: If the temperature is below 0 degrees, then display "It's freezing!". Else/Else If: Use "Otherwise" or "Else" for alternatives.
  • Example: Otherwise, display "The weather is fine."

Loops

For Each: Iterate with "For each".

  • Example: For each item in the shopping cart, apply the discount. While Loops: Use "While" for repeating actions.
  • Example: While the user is not logged in, prompt for credentials.

5. Functions and Procedures

Defining Functions: Start with "To" and the action.

  • Example: To calculate the area of a circle, multiply pi by the radius squared. Calling Functions: Simply state the action.
  • Example: Calculate the area of the circle.

6. Input and Output

Output: Use "Display", "Show", or "Print".

  • Example: Display "Welcome to the program!". Input: Use "Ask", "Prompt", or "Get".
  • Example: Ask the user for their name.

7. Comments

Inline Comments: Use "Note:" or parentheses.

  • Example: Note: This function calculates the area. Block Comments: Use conversational style.
  • Example: /* This section handles user authentication. */

8. Data Structures

Lists/Arrays: Create with natural phrases.

  • Example: Create a list of fruits containing apples, bananas, and cherries. Access Elements: Use "first item", "last item".
  • Example: Set favorite fruit to the first item in the list of fruits.

9. Error Handling

Try-Catch: Use "Attempt to" and "If that fails".

  • Example: Attempt to open the file. If that fails, display an error message.

10. Mathematical and Logical Operations

Natural Expressions: Write calculations plainly.

  • Example: Calculate the total by adding the tax to the subtotal. Word Operators: Use "plus", "minus", "times", "divided by".
  • Example: Set the average to the sum of the scores divided by the number of scores. Logical Operators: Use "and", "or", "not".
  • Example: If the user is an admin and the account is active, then allow access.

11. Comparison Operators

Descriptive Comparisons: Use phrases like "is equal to".

  • Example: If the score is greater than or equal to 90, then assign a grade of 'A'.

12. Modularity and Organization

Sections/Modules: Organize code with "Section" or "Module".

  • Example: In the Payment Processing section, define transaction handling. Import Modules: Use "Include" or "Use".
  • Example: Include the User Authentication module.

13. Object-Oriented Concepts

Define Classes: Use "Define" and description.

  • Example: Define a Vehicle with a make, model, and year. Create Objects: Use "Create" or "Make".
  • Example: Create a new Car with make "Toyota" and model "Corolla". Inheritance: Use "is a type of".
  • Example: A SportsCar is a type of Car with a top speed.

14. Concurrency and Parallelism

Asynchronous Actions: Use "Meanwhile" or "At the same time".

  • Example: Download the file while displaying the progress.

15. Declarative Statements

Outcome-Oriented: State desired results; system implements.

  • Example: Ensure all user inputs are validated.

16. Formatting and Punctuation

Flexible Punctuation: Commas and periods improve readability.

  • Example: If the user is not registered, then prompt for registration. Case Insensitive: Uppercase and lowercase are the same.
  • Example: Display "Hello World". equals display "hello world".

17. Internationalization

Multilingual Support: Code in your native language. Example in Spanish: Si la edad del usuario es 18 o más, entonces conceder acceso.

18. Error Tolerance and Guidance

Lenient Parsing: Tolerates minor errors.

  • Example: Set total price to price times quantity. Helpful Feedback: Offers suggestions if confused.
  • Example: Did you mean to calculate the average score?

19. Security and Permissions

Explicit Permissions: Use clear statements.

  • Example: Allow access to the user's location only if they consent.

20. Style Information

Defining Styles

Style Section: Define styles in a dedicated area.

  • Example:
Section: Styles
Define a style called "Header" with font size 24, color blue, bold.

Applying Styles: Use descriptive phrases.

  • Example: Apply the "Header" style to the title.

Inheritance and Complex Styles

Inheritance: Specify styles to inherit from others.

  • Example: Define "PrimaryButton" that inherits from "Button" and "Highlight". Override Properties: Modify specific attributes.
  • Example: Define "PrimaryButton" with background color blue.

Style Example

Create a button labeled "Submit".
Apply the "PrimaryButton" style to the button.

Section: Styles
Define a style called "Button" with background color green, text color white.
Define a style called "Highlight" with border color yellow.
Define "PrimaryButton" that inherits from "Button" and "Highlight", with background color blue.

21. Resources

Images and Resources

Resource Section: Define in a dedicated area.

  • Example:
Define an image called "Logo" with file path "images/logo.png".

Display Images: Use descriptive commands.

  • Example: Display the "Logo" image at the top.

Generative Images

Define Generative Images: Describe parameters.

  • Example: Define a generative image "AbstractPattern" with colors blue and green, complexity 5. Use Generative Images: Reference by name.
  • Example: Display "AbstractPattern" as the background.

Generative Image Example

Display "AbstractPattern" as the background.

Section: Resources
Define a generative image "AbstractPattern" with colors blue and green, complexity 5, pattern "spiral", size 500x500 pixels.

22. Example Program

Task: Create a program that asks for a user's name and age, then checks voting eligibility.

Ask the user for their name.
Ask the user for their age.

If the user's age is 18 or more, then
    Display "Hello [user's name], you are eligible to vote."
Else
    Display "Hello [user's name], you are not eligible to vote yet."

23. Advanced Concepts

Defining and Using Functions

To greet the user:
    Display "Welcome, [user's name]!"

Ask the user for their name.
Greet the user.

Working with Lists

Create a list called shopping list containing milk, bread, eggs.

For each item in the shopping list,
    Display "Remember to buy [item]."

Add "butter" to the shopping list.

Object-Oriented Example

Define a Dog as an animal with a name that can bark.

Create a Dog named "Buddy".
Instruct the Dog to bark, display "[Dog's name] is barking!"