This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ComputerCraftFan11's profile picture

[WIP] Barix, the language compiled with Binary (and programmed with Lua :D)

Started by ComputerCraftFan11, 12 June 2012 - 07:46 AM
ComputerCraftFan11 #1
Posted 12 June 2012 - 09:46 AM
This is a CC language i'm making. It's called Barix.

It's interpreter is coded with Lua.
It also uses file extensions and overwrites shell.run() to support it.
The compiler makes it binary (will soon use something more random like "A" = "fojsiojrtg") (Right now its not much of a compiler, it just changes every character into a binary character).

HOW TO USE:
  • Run this program ONCE, it will create a program called compiler. (run the program every time you reboot, or save it as startup)
  • Create a Lua program and save it as anything (don't add .bar)
  • On the CraftOS Shell, type "compiler <programname>"
  • Your compiled program is now in <programname>.bar! Type that in the shell to run the binary program.
This is not done as i'm still making the programming language (it uses lua right now)

If you wan't the current code, here it is, right now i'm working on the language.

(INSTALLER)
http://pastebin.com/JdxFcx4E

Please note that after every reboot, you have to re-run the installer so the shell.run will be overwrote again.
ComputerCraftFan11 #2
Posted 12 June 2012 - 11:43 PM
I finished the compiler! I'll post how to use the Barix language when i'm done with it.
ComputerCraftFan11 #3
Posted 13 June 2012 - 04:13 AM
Added pastebin and updated the installer.
ComputerCraftFan11 #4
Posted 13 June 2012 - 04:47 AM
Bug fixes
  1. Fixed errors in the decompiler for files with more then 1 line.
tommyroyall #5
Posted 21 June 2012 - 08:48 PM
Hello, when you begin creation of the language, perhaps you would allow me too assist you in the development process of the language? I am proficient in Lua, and multiple other languages.
Xtansia #6
Posted 22 June 2012 - 05:39 AM
I'm not sure if you understand the concept of a binary compiled programming language.
It isn't just simply replacing characters with their binary encoded counterpart.
ComputerCraftFan11 #7
Posted 22 June 2012 - 10:18 PM
I'm not sure if you understand the concept of a binary compiled programming language.
It isn't just simply replacing characters with their binary encoded counterpart.

That was only a test. It won't be binary in the full version.
tommyroyall #8
Posted 22 June 2012 - 10:41 PM
Hey dude, when are we going to be designing the syntax for this? Should I get to work on the syntax? I've built a command line interpreter that saves it down to a file in lua. Is this going to be a language similar to C, Java, JavaScript, PHP, anything?
tommyroyall #9
Posted 23 June 2012 - 03:52 AM
Here's some ideas that I came up with:

=============
LUA EXAMPLE
=============
function moveTurtle()
print("Moving Turtle")
turtleState = "Moving"
turtle.forward()
turtle.select(4)
    rednet.send(3,"Hi")
end
a = 2
b = 3
c = a + b
moveTurtle()
-- A Comment
=============
BARIX EXAMPLE (Cmd Line)
=============
:moveTurtle
echo Moving Turtle
set turtleState "Moving"
turtle move forward
turtle inventory 4
    netsend 3 "hi"
moveTurtle:
set a 2
set b 3
math c = a + b
;moveTurtle;
REM A Comment
=============
BARIX EXAMPLE (Elaborate)
=============
function moveTurtle[]
write 1,1,"Moving Turtle"
var = turtleState
  turtleState = "Moving"
turtle[move[forward]]
turtle[inventory[4]]
    send[3["Hi"]]
endfunction
var = a, b, c
a = 2
b = 3
c = a + b
call moveTurtle[]
`A Comment
=============
Just some ideas :P/>/>
ComputerCraftFan11 #10
Posted 23 June 2012 - 09:49 AM
Here's some ideas that I came up with:

=============
LUA EXAMPLE
=============
function moveTurtle()
print("Moving Turtle")
turtleState = "Moving"
turtle.forward()
turtle.select(4)
    rednet.send(3,"Hi")
end
a = 2
b = 3
c = a + b
moveTurtle()
-- A Comment
=============
BARIX EXAMPLE (Cmd Line)
=============
:moveTurtle
echo Moving Turtle
set turtleState "Moving"
turtle move forward
turtle inventory 4
    netsend 3 "hi"
moveTurtle:
set a 2
set b 3
math c = a + b
;moveTurtle;
REM A Comment
=============
BARIX EXAMPLE (Elaborate)
=============
function moveTurtle[]
write 1,1,"Moving Turtle"
var = turtleState
  turtleState = "Moving"
turtle[move[forward]]
turtle[inventory[4]]
    send[3["Hi"]]
endfunction
var = a, b, c
a = 2
b = 3
c = a + b
call moveTurtle[]
`A Comment
=============
Just some ideas :P/>/>

Hmm, do you have a server where we can work on it? I don't have Skype or a microphone.

(you forgot to reset the turtle state)
tommyroyall #11
Posted 23 June 2012 - 04:30 PM
I don't have a server, sorry man, and we're in different time zones. Here's code for an interpreter that I've been working on, maybe we could run each line of code through something like this for running it line-by-line, or for translating it:

function sepInt()
line = 0
data = { }
state = "running"
table = { }
varnum = 0
variables = { }
repeat
input = nil
line = line + 1
print("Line: "..line)
input = read()
table = stringutils.seperate(input," ")
if table[1] == "print" then print(table[2]) end
if table[1] == "broadcast" then rednet.broadcast(table[2]) end
if table[1] == "send" then rednet.send(table[2],table[3]) end
if table[1] == "openport" then rednet.open("top") rednet.open("left") rednet.open("right") rednet.open("back") end
if table[1] == "receive" then rednet.receive(table[2]) end
if table[1] == "eject" then disk.eject(table[2]) end
until state ~= "running"
end
sepInt()

This is just a tiny, execute-by-line interpreter, but you could make it with things like this (and yes, it does require the StringUtilsAPI, because IT ROCKS :P/>/>):
if table[1]=="commandtag" then file.write(filename,"Lua Version Here")

Also, a file-writing one here:

function sepInt()
line = 0
data = { }
state = "running"
table = { }
varnum = 0
variables = { }
repeat
input = nil
line = line + 1
print("Line: "..line)
input = read()
table = stringutils.seperate(input," ")
if table[1] == "print" then f.writeLine("print("..table[2]..")") end
if table[1] == "broadcast" then f.writeLine("rednet.broadcast("..table[2]..")") end
if table[1] == "send" then f.writeLine("rednet.send("..table[2]..","..table[3]..")") end
if table[1] == "openport" then f.writeLine("rednet.open('top') rednet.open('left') rednet.open('right') rednet.open('back')") end
if table[1] == "receive" then f.writeLine("rednet.receive("..table[2])..")" end
if table[1] == "eject" then f.writeLine("disk.eject("..table[2])..")" end
until state ~= "running"
f.close()
end
function intro()
print("File to save code too:")
input = read()
f=io.open(input,"a")
sepInt()
end
intro()
Mads #12
Posted 24 June 2012 - 08:44 AM
How would you execute the binary program? If you were just gonna re-translate it back into Lua, you are missing the point of compiling to a binary program. The contents of these are supposed to be run by the hardware, andnot translated into another language, which is then ran though C(in this case Java), which is then compiled, and then run. That is pointless. http://en.wikipedia.org/wiki/Compiler
tommyroyall #13
Posted 24 June 2012 - 03:54 PM
I think that we should just write a compiler, forget the binary part, as mad said above, it is kind of pointless. A compiler from some language into Lua would be much easier, and so much more effective.
Mads #14
Posted 24 June 2012 - 04:28 PM
I would love to help on the translator though. I think it will be very interesting to see how this turns out.
ComputerCraftFan11 #15
Posted 24 June 2012 - 10:36 PM
How would you execute the binary program? If you were just gonna re-translate it back into Lua, you are missing the point of compiling to a binary program. The contents of these are supposed to be run by the hardware, andnot translated into another language, which is then ran though C(in this case Java), which is then compiled, and then run. That is pointless. http://en.wikipedia.org/wiki/Compiler

The binary thing was only temporary. I said that in another thread, and it won't be like this when it's done.
tommyroyall #16
Posted 25 June 2012 - 05:37 AM
Ahh, ok. That's pretty useful :P/>/> I just finished making RedScript, a 50+ cmd interpreter/language, that I think may be a good basis for this. I'll be posting it up on the forums soon.
tommyroyall #17
Posted 25 June 2012 - 06:34 PM
http://www.computercraft.info/forums2/index.php?/topic/2260-language-redscript-a-language-compiled-and-interpreted-in-cc/
Here's RedScript :P/>/>
ComputerCraftFan11 #18
Posted 26 June 2012 - 02:51 AM

Tommyroyall, I got a VPN and I can make a server thats managed by one of my programs.

When its up, wanna join? (PM me when you are on)