Skip to content

Commit

Permalink
fix compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
Dario Tarantini committed Jun 11, 2020
1 parent b3c1d55 commit bd761cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 1 addition & 2 deletions vbf/build.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ module main


fn build(input []Instruction) string {
mut output := ''
output += '#include <stdio.h>\nint main(){char array[$data_size]={0};char *ptr=array;'
mut output := '#include <stdio.h>\nint main(){char array[$data_size]={0};char *ptr=array;'
for pc := 0; pc < (input.len); pc++ {
if input[pc].operator == op_inc_dp {
output += '++ptr;'
Expand Down
16 changes: 14 additions & 2 deletions vbf/main.v
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,25 @@ fn main(){
}
c := compile(code)
resp := build(c)
mut file := os.create('./'+os.args[2]+'.c') or {
filename := os.args[2].replace(".vbf", "")
mut file := os.create('./' + filename + '.c') or {
println('Problem while creating the file')
return
}
file.write(resp)
file.close()
println('Program generated correctly\nNow you can build using\n\tcc '+os.args[2]+'.c')

$if windows {
println('Program generated correctly\nNow you can build it.')
}
$if macos {
println('Program generated correctly\nNow you can build it.')
}
$if linux {
os.system("cc " + filename + ".c -o " + filename)
os.rm(filename + ".c")
println('Program generated correctly\nExcute with: ./' + filename)
}
}else{
println('Wrong command!')
}
Expand Down

0 comments on commit bd761cd

Please sign in to comment.