Bool is an object-oriented, dynamically typed, and strongly-typed programming language influenced by the languages of Python and OCaml. Bool comes with a plethora of benefits including the ability to be compiled to Javascript, the absence of curly braces and semi-colons, intuitive and simple readability, and so much more. Bool's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance.
Often, programmers will fall in love with Bool because of its similarity to Python and the productivity it provides. The original reason we decided to create Bool was to create a language that would allow programmers to have a similar "out-of-the-box," "plug-and-play" coding experience that each of us liked about Python. To make it more user-friendly, we decided to combine the safety and power of another favorite language, OCaml. The pattern-matching aspect of OCaml is a really intuitive way of programming and with its compile-time analysis of programs, this rules out many programming errors. More precisely, this protects the integrity of the data manipulated by an OCaml program.
For Bool, security is a high concern, and so we tried to adopt many of the same things that worked for the two parent languages that ensure some degree of protection and help for the programmer.
let foo:int = 101
let bar:string = 101
let y = tru
a + b
a - b
a * b
a / b
a % b
a ** b
a // b
tru # true
fal # false
!a # not a
a > b # a greater than b
a < b # a less than b
a >= b # a greater than/equal to b
a <= b # a less than/equal to b
a == b # a equals b
a != b # a does not equal b
fun foo (bar):
let result:string
for i in range(bar):
if i < 5:
result = "foobar"
elif i > 7:
result = "barfoo"
ret result
while a < 99:
a += 5
fun doubleEvens (array):
ret [for i in array if i % 2 === 0 i * 2]
class Person:
build (_nameFirst _nameLast _age)
class Fam isa Person:
build (_nameFirst _nameLast _age):
_affiliation = "blood"
cap (foo:PoliceMan):
fun bopim (numBops):
for bop in range(numBops):
print(_nameFirst + (" bopped " + (foo.nameFirst
+ (" " + (foo.nameLast + (" "
+ (bop + (" times"))))))))
ret bopim
class PoliceMan isa Person:
build (_nameFirst _nameLast _age):
_affiliation = "twelvy"
woopwoop ():
ret "Time to narc"
let five0:PoliceMan = new PoliceMan("john" "doe" 24)
let yg:Fam = new Fam("yg" "hootie" 23)
yg.cap(five0)(5)
fun tricky (a b c):
ret c(a)(b)
fun add2 (a):
fun add1(b):
ret a + b
ret add1
let sum:int = tricky(1 2 add2)
# This is a comment in Bool
## If you need more lines,
Bool can do that too. ##
fun gcd (a b):
if !b:
ret a
ret gcd(b a % b)
fun fibonacci (x):
let a:int = 0
let b:int = 1
let c:int
if (x < 3):
ret 1
while x > 0:
c = a + b
a = b
b = c
x -= 1
ret c
Program:
Block:
FullStmt:
IndentStmt:
SimpleStmt:
ClassDecl:
ClassSuite:
ClassBody:
FieldDecl:
ConstructorDecl:
MethodDecl:
MethodParams:
FieldParams:
ObjDecl:
PropertyDecl:
FunDecl:
VarDecl:
OpAssign:
assignop:
VarAssignment:
Return:
Funcall:
FunParams:
Params:
ParamDecl:
Conditional:
Case:
Suite:
Loop:
Exp:
Exp1:
Exp2:
Exp3:
Exp4:
Exp5:
Exp6:
Exp7:
Exp8:
SimpleLit:
VarExp:
MemberExp:
addop:
mulop:
prefixop:
expop:
relop:
Explist:
ListExp:
SimpleIf:
Listlit:
intlit:
floatlit:
stringlit:
ClassInst:
Objlit:
Funlit:
Reserved:
punctuation:
Type:
char:
stringSpace:
comment:
singlecomment:
multicomment:
id:
idName:
idStart:
idChar:
newline:
space:
+ requires compatible operands
Cannot create a float multiple of a string
** requires numerical or variable args
${this.op} requires numerical or variable args
Cannot access non-integer index of list
Operator '${this.op}' requires left operand to be object.
Operator '${this.op}' requires numerical operands.
Operator '${this.op}' requires integer operands.
Operator '${this.op}' requires compatible operands.
Cannot access properties of non-object
Cannot access non-integer index of list
Condition must be of type 'bool'. Found type ${this.condition.type}
Lists must be composed of compatible types
Cannot assign field outside of class context
Incompatible types: Expected ${this.target.type.name}, got ${this.source.type.name}
Cannot declare field outside of class
Cannot declare field parameters outside of class context
Cannot use for-in on non list
Cannot call non-function as function
Function requires ${curFun.params.length} parameters. Given ${paramGroup.params.length}
Incompatible types: Expected ${curFun.params.params[j].type}, got ${paramGroup.params[j].type}
Incompatible return type. Expected ${this.returnType}, got ${this.body.type}.
Cannot use for-in on non list
Incompatible return type. Expected ${this.returnType}, got ${this.block.type}.
Cannot use field parameters outside of class context
Cannot access property of non-object
Source is of wrong type. expected a number
Target of assignment operator ${this.op} must be integer.
Source of assignment operator ${this.op} must be integer.
Target of assignment ${this.op} must be number.
Source of assignment ${this.op} must be number.
Incompatible types: Expected ${this.type}, Got ${this.val.type}
Cannot create non-integral range.
Conditional expression must evaluate to boolean. Found ${this.condition.type}
Cannot negate non-number
Incompatible types: Expected ${this.target.type.name}, got ${this.source.type.name}
Incompatible Types: Declared ${this.type.name}, Assigned ${this.value.type.name}