Major syntax revision in progress...
This commit is contained in:
parent
b2d0cb93e2
commit
f2cfd30291
38
test.x
38
test.x
@ -22,25 +22,8 @@ type file_descriptor (
|
||||
standard_input = 0,
|
||||
standard_output = 1)
|
||||
|
||||
main () > integer:
|
||||
x: integer = 1;
|
||||
s: structure = (-1, true, 1);
|
||||
loop (x++ < 101):
|
||||
if ((x % 3 = 0) && (x % 5 = 0))
|
||||
echo ("fizzbuzz");
|
||||
else if (x % 3 = 0):
|
||||
echo ("fizz\n");
|
||||
echo ("and again fizz");;
|
||||
else if (x % 5 = 0)
|
||||
echo ("buzz\n");
|
||||
else
|
||||
echo ("fuck formatting...");
|
||||
echo ("\n");;
|
||||
return 0;;
|
||||
|
||||
heyo () echo ("Heyo!");
|
||||
cyaa () echo ("Heyo!");
|
||||
name () > characer [] return ("Ognjen");
|
||||
|
||||
string_length (character string []) > natural:
|
||||
length: natural = 0;
|
||||
@ -51,3 +34,24 @@ string_length (character string []) > natural:
|
||||
echo (character text []):
|
||||
system (linux_write_system_call, standard_output, text, string_length (text));
|
||||
return;;
|
||||
|
||||
--- entry point
|
||||
|
||||
my_main () > integer:
|
||||
x: integer = 1;
|
||||
s: structure = (-1, true, 1);
|
||||
---
|
||||
heyo ();
|
||||
loop (x++ < 17):
|
||||
if ((x % 3 = 0) && (x % 5 = 0))
|
||||
echo ("fizzbuzz");
|
||||
else if (x % 3 = 0):
|
||||
echo ("fizz\n");
|
||||
echo ("and again fizz");;
|
||||
else if (x % 5 = 0)
|
||||
echo ("buzz\n");
|
||||
else
|
||||
echo ("fuck formatting...");
|
||||
echo ("\n");;
|
||||
cyaa ();
|
||||
return 0;;
|
||||
|
87
xiranda.c
87
xiranda.c
@ -1,42 +1,30 @@
|
||||
#include <xolatile/xtandard.c>
|
||||
|
||||
enum {
|
||||
core_none, core_word, core_marker, core_string, core_number,
|
||||
core_symbol, core_type
|
||||
word_type, word_loop, word_if, word_else, word_case, word_return, word_import, word_system,
|
||||
function, variable, constant, type, string, number, marker, label,
|
||||
add, subtract, multiply, divide, modulus, equal, above, below,
|
||||
open, close, next, stop, branch, and, or, not,
|
||||
range, enrange, derange, comment
|
||||
};
|
||||
|
||||
enum {
|
||||
word_type, word_loop, word_if, word_else, word_case,
|
||||
word_return, word_import, word_system
|
||||
};
|
||||
static int function_code = 0;
|
||||
static int variable_code = 0;
|
||||
static int constant_code = 0;
|
||||
|
||||
#define STRING_LIMIT (80)
|
||||
#define NAME_LIMIT (80)
|
||||
static char function_name [9] [40] = { "" };
|
||||
static int function_type [9] = { 0 };
|
||||
static char function_argument_name [9] [6] [40] = { { "" } };
|
||||
static int function_argument_type [9] [6] = { { 0 } };
|
||||
|
||||
static int token_count = 0;
|
||||
static int string_code = 0;
|
||||
static int number_code = 0;
|
||||
static int marker_code = 0;
|
||||
static int type_code = 0;
|
||||
static int symbol_code = 0;
|
||||
static char variable_name [27] [40] = { "" };
|
||||
static int variable_type [27] = { 0 };
|
||||
static int variable_data [27] = { 0 };
|
||||
|
||||
static char constant_name [30] [40] = { "" };
|
||||
static int constant_type [30] = { 0 };
|
||||
static int constant_data [30] = { 0 };
|
||||
|
||||
static int * token_data = null;
|
||||
static int * token_type = null;
|
||||
/*static char * * string_name = null;*/
|
||||
static char * * string_data = null;
|
||||
static int * string_size = null;
|
||||
/*static char * * number_name = null;*/
|
||||
static int * number_data = null;
|
||||
static char * * marker_name = null;
|
||||
static char * * type_name = null;
|
||||
static int * marker_type = null;
|
||||
static char * symbol_data = null;
|
||||
/*
|
||||
static int * function_name = null;
|
||||
static int * function_type = null;
|
||||
static int * * function_argument_name = null;
|
||||
static int * * function_argument_type = null;
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
static char * word_list [] = {
|
||||
@ -51,43 +39,6 @@ static void add_token (int type, int data) {
|
||||
++token_count;
|
||||
}
|
||||
|
||||
static void add_string (char * data, int size) {
|
||||
string_data = reallocate (string_data, (string_code + 1) * (int) sizeof (* string_data));
|
||||
string_size = reallocate (string_size, (string_code + 1) * (int) sizeof (* string_size));
|
||||
string_data [string_code] = allocate (STRING_LIMIT * (int) sizeof (* string_data));
|
||||
string_copy (string_data [string_code], data);
|
||||
string_size [string_code] = size;
|
||||
++string_code;
|
||||
}
|
||||
|
||||
static void add_number (int data) {
|
||||
number_data = reallocate (number_data, (number_code + 1) * (int) sizeof (* number_data));
|
||||
number_data [number_code] = data;
|
||||
++number_code;
|
||||
}
|
||||
|
||||
static void add_marker (char * name, int type) {
|
||||
marker_name = reallocate (marker_name, (marker_code + 1) * (int) sizeof (* marker_name));
|
||||
marker_type = reallocate (marker_type, (marker_code + 1) * (int) sizeof (* marker_type));
|
||||
marker_name [marker_code] = allocate (NAME_LIMIT * (int) sizeof (* marker_name));
|
||||
string_copy (marker_name [marker_code], name);
|
||||
marker_type [marker_code] = type;
|
||||
++marker_code;
|
||||
}
|
||||
|
||||
static void add_type (char * name) {
|
||||
type_name = reallocate (type_name, (type_code + 1) * (int) sizeof (* type_name));
|
||||
type_name [type_code] = allocate (NAME_LIMIT * (int) sizeof (* type_name));
|
||||
string_copy (type_name [type_code], name);
|
||||
++type_code;
|
||||
}
|
||||
|
||||
static void add_symbol (char data) {
|
||||
symbol_data = reallocate (symbol_data, (symbol_code + 1) * (int) sizeof (* symbol_data));
|
||||
symbol_data [symbol_code] = data;
|
||||
++symbol_code;
|
||||
}
|
||||
|
||||
static void kill (char * data) {
|
||||
terminal_colour (colour_red, effect_bold);
|
||||
echo (data);
|
||||
|
Loading…
Reference in New Issue
Block a user