fbgc

Small Language and Calculator in C

View the Project on GitHub fbgencer/fbgc

History

Features

Write your first program:

print('Hello World')

Build

To build fbgc, simply run:

$ make

Run

fbgc allows you to define multiple types of entries. Such as integers, doubles, strings, tuples and matrices. You don’t need to specify types as in the case of statically typed languages.

Basic types:

# This is a line comment
x = 5 # integer
x = 3.14159 # double
x = 'Hey this is a string' # string
x = (1,2,1.23,('Hey i am tuple!')) # tuple
x = [1,2,3 ; 4,5,6] # 2x3 matrix

Absolute operator: number objects return positive of that number under abs operator complex object returns 2-d distance string, tuple and matrix objects return their length

|'fbgc'| # gives 4

|('a','fbgc',1,2,3)| # gives 5

|3+4j| # gives 5.0

|-3| # gives 3

Function definition:

sum = fun(a,b)
	return a+b
end

Conditional structures:

if(a == 5 & y == 7)
	print('This is an if structure')
end

if(x == 5)
	print('Inside if : ',x)
elif(x == 6)
	print('Inside elif  :',x)
else
	print('Inside else: ',x)
end

i = 0
while(i<5)
	print(i)
end

Paranthesis can be dropped as well. 

if i == 5
	print('i is five')
end

if x == 5 ; print("x is 5"); else print('x is not 5') ; end

In fbgc, for loop allows you to write fast code ! You can create a for loop just giving sequence or range

for(i = 0:10)
	print(i) #prints 0,1,2,3,4,5,6,7,8,9
end

for i = 1:0.1:3.14
	print(i) #prints 1, 1.1, 1.2, 1.3, 1.4 .... 3.1
end

for(i = 0:2:10)
	print(i) #prints 0,2,4,6,8
end

for (i = 'fbgc')
	print(i) #prints 'f','b','g','c'
end

#|obj| operator gives you the length of the object
x = 'Hello world'
for (i = 0 : |x|)
	print(x[i])
end

Future Work

fbgc is looking forward to be improved. If you are interested in please make pull request. It is under development.