38 lines
723 B
C
38 lines
723 B
C
#include "common.h"
|
|
#include "compiler.h"
|
|
#include "tokenizer.h"
|
|
|
|
int
|
|
main (int argc, char **argv)
|
|
{
|
|
if (argc != 3)
|
|
{
|
|
printf ("usage: varaq input.vq output.wasm");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
char *buffer;
|
|
int length = 0;
|
|
int sp = open (argv[1], O_RDONLY);
|
|
|
|
if (sp)
|
|
{
|
|
length = lseek (sp, (size_t)0, SEEK_END);
|
|
lseek (sp, (size_t)0, SEEK_SET);
|
|
buffer = malloc (length);
|
|
if (buffer)
|
|
{
|
|
read (sp, buffer, length * sizeof (char));
|
|
}
|
|
close (sp);
|
|
}
|
|
|
|
Code *prog = compile (buffer);
|
|
|
|
int tp = open (argv[2], O_CREAT | O_WRONLY, S_IRWXU | S_IRGRP | S_IROTH);
|
|
write (tp, prog->cells, prog->count);
|
|
close (tp);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|