| LICENSE | Initial commit | |
| prompt.txt | Add 'prompt.txt' | |
| README.md | Update 'README.md' | |
popbob fictional language
A fake programming language which is emulated by OpenAI's ChatGPT
Using Popbob
Start chatGPT and paste the prompt, then just type code as a message and send it to run
Here's the docs (the same you will feed to the AI)
The popbob programming language
Overview
There are only four types of "objects" in popbob:
- Constants, such as strings (
"this is a constant string"), numbers (12,1.4), booleans (True,False), or lists of variables ((1, 2, 3, "pop")) - Variables, which are just names that correspond to some value
- Functions, which will be discussed in focus later
- Codeblocks, which is popbob code enclosed in curly braces {like this}
Comments are identified by a double slash (// like this)
Functions
Popbob works with funcitons. Every action you can take is done through functions.
-
To call a funciton, it's sufficient to write
funciton_name(args, separated, by, commas) -
To define a function, type
def funcion_name(expected, args, separated, by, commas) {
...code...
return value
}
Returning a value is optional, and if omitted a function will always return False
Built-in funcitons
There are some built-in functions:
-
print(string_or_variable): displaystring_or_variablein the terminal -
let(name, value): assignvaluevalue tonamevariable, which is created if not existing.valuecan also be a list of values enclosed in brackets and separated with commas,("like", "this"), in which casenamewill be a variable list -
math(operator, var1, var2, var3): store invar3the result of the operation defined byoperator(sum+, subtraction-, division/, multiplication*, modulo%) betweenvar1andvar2.var3is optional, if it is not given,mathwill return the result of the operation. -
while(condition, code): runcode(which is a codeblock) repeating it as long asconditionevaluates toTrue. -
concat(var1, var2): will return the result of the concatenation of var2 to var1, if they are numbers they'll be summed. Exampleconcat("hello ", "world")will return"hello world";concat((1, 2, 3), (1))will return(1, 2, 3, 1);concat(1, 4)will return5
Condition Evaluation
Conditions are evaluated to booleans following this rules:
condition will evaluate to True if:
- it has value (i.e. is a non-empty string or a nonzero number)
- is a
Trueboolean constant or variable - is a list of length nonzero
- is a true comparison of two numbers (as in
a > b,a == b,a <= b) - is a true equality of two values (as in
a == "content",a == b) else it'll evaluate toFalse
Note that before any evaluation every function call must be run and replaced by it's return value
Example code:
// calling the built-in print function
print("Hello, world!")
// defining a function
def say_hello(name) {
print(concat("Hello, ", name))
}
// calling the say_hello function
say_hello("popbob")
// using the let function to create and assign a variable
let(greeting, "Hi there")
print(greeting)
// using the math function
let(x, 5)
let(y, 3)
let(z, math("+", x, y))
print(z) // expected output: 8
// using the while function
let(count, 0)
while(count < 5, {
print(count)
math("+", count, 1, count)
})
Expected output:
Hello, world!
Hello, popbob
Hi there
8
0
1
2
3
4