Uploading something that I do not know what it is...

This commit is contained in:
Ognjen Milan Robovic 2023-09-18 15:47:33 -04:00
parent 942c7d9afa
commit 50a462a385
3 changed files with 95 additions and 0 deletions

7
compile.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
set -xe
gcc -g -ansi -Wall -Wextra -Wpedantic -Werror -o xode xode.c
exit

7
install.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
set -xe
cp xode /usr/bin/xode
exit

81
xode.c Normal file
View File

@ -0,0 +1,81 @@
/*
* Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
*
* Xode is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation.
* And when you do redistribute it or modify it, it will use either version 3 of the License, or (at yours truly opinion) any later version.
* It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3.
*/
#include <xolatile/xtandard.h>
#include <xolatile/xtandard.c>
/*
! Comment line...
[ 0F 05 ]
" World "
' 3.141 '
label ! set
( label ) ! get
*/
static char * preprocess (char * source, char * buffer) {
int offset_0 = 0;
int offset_1 = 0;
buffer = allocate (string_length (source));
do {
if (source [offset_0] == '!') {
do {
++offset_0;
} while (source [offset_0] != '\n');
}
if (character_is_blank (source [offset_0]) == 0) {
buffer [offset_1] = source [offset_0];
++offset_1;
}
++offset_0;
} while (source [offset_0] != '\0');
buffer [offset_1] = '\0';
return (buffer);
}
int main (int argc, char * * argv) {
int offset = 0;
char * input = NULL;
char * buffer = NULL;
int output = -1;
if (argc != 3) {
fatal_failure (1, "xompile: xode input output");
}
input = file_import (argv [1]);
output = open (argv [2], O_RDWR);
buffer = preprocess (input, buffer);
do {
if (buffer [offset] == '[') {
++offset;
do {
int byte = encode_byte (& buffer [offset]);
file_write (output, & byte, 1);
++offset;
++offset;
} while (buffer [offset] != ']');
}
++offset;
} while (buffer [offset] != '\0');
output = file_close (output);
buffer = deallocate (buffer);
input = deallocate (input);
return (EXIT_SUCCESS);
}