Posts

tape_t windows.h

#pragma once #include <stdlib.h> #include <stdio.h> enum Bool { FALSE, TRUE }; char getch(char* Tape, int current_ptr) { return Tape[current_ptr]; } char getchIncr(char* Tape, int current_ptr) { return Tape[current_ptr++]; } int tapeIncr(int current_ptr, int i) { current_ptr += i; return current_ptr; } void necessary_expect(char* Tape, int current_ptr, char expected_symbol) { if (getch(Tape, current_ptr) != expected_symbol) { printf("Missing char is %c but input char is (%c)%d\n", expected_symbol, getch(Tape, current_ptr), getch(Tape, current_ptr)); exit(0); } current_ptr++; } Bool optional_expect(char* Tape, int current_ptr, char expected_symbol) { if (getch(Tape, current_ptr) != expected_symbol) { return FALSE; } current_ptr++; return TRUE; } void jumpline(char* Tape, int current_ptr) { if (getch(Tape, current_ptr) == '\n') { current_ptr++; return; } while (getch(Tape, current_ptr) != '\n') ...

tuple_t Windows.h

#pragma once /******************************************************************************   New Era Datastructure  Designed by Daipayan Bhowal *******************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <string.h> typedef enum Type {     CHAR,     INT,     FLOAT,     DOUBLE,     SHORT,     LONG,     LONG_LONG,     STRING }type_t; typedef struct Tables {     int index;     int type[64];     void* args[64];     char max_index; } tables; typedef tables* table_t; table_t itable(int num, ...) // init_table {     va_list valist;     va_start(valist, num);     static int counter = 0;     table_t t = (table_t)malloc(sizeof(tables));     t->index = ++counter;     for (int j = 0; j < num; j...

string_t windows.h

#pragma once #pragma once #include <stdio.h> #include <stdlib.h> #include <string.h> #undef empty #define STR_LEN_CHECK(str,pos)  str->len <= pos #define IS_SPACE(str,pos) at(str,pos) == ' ' ||  \ at(str, pos) == '\n' || \ at(str, pos) == '\v' || \ at(str, pos) == '\t' struct string_struct { int len; char* str; char* back; char empty; }; typedef struct string_struct struct_var; typedef struct_var* string_t; typedef struct mem { string_t str; int string_size; int index; } memrecord; string_t string_file(char* s, int* len); string_t string(char* s); void push(string_t st, char s); char pop(string_t st); char* con(string_t a); int length(string_t a); char at(string_t a, int i); string_t copy(string_t a); string_t getlines(string_t a); string_t overwrite(string_t a, string_t b); int locate(string_t s, string_t find_str); int findString(string_t s, string_t find_str); int findStringPos(string_t s, string_t find_str,...

string_t Windows.c

 //#include <stdafx.h> #include "string_t.h" int string_file_len(char* s) { int i = 0; while (s[i] != EOF) { i++; } return i; } string_t string_file(char* s, int* file_length) { int len = string_file_len(s); char* content = (char*)malloc(len + 1); memcpy(content, s, len); content[len] = EOF; string_t st = (string_t)malloc(sizeof(struct_var)); st->len = len + 1; st->str = content; st->back = content + len - 1; if (strcmp(s, "\0")) st->empty = 1; *file_length = len; return st; } string_t string(char* s) { int len = strlen(s); char* content = (char*)calloc(len + 1,sizeof(char)); memcpy(content, s, len); content[len] = '\0'; string_t st = (string_t)malloc(sizeof(struct_var)); st->len = len + 1; st->str = content; st->back = content + len - 1; if (strcmp(s, "\0")) st->empty = 1; return st; } string_t string_const(const char* s) { int len = strlen(s); char* con...

VECPP Windows.c

#include "tape_t.h" #include "string_t.h" #include "tuple_t.h" #include "bool_t.h" #include <direct.h> #if _MSC_VER #include "io.h" #else #include <cunistd> #endif typedef bool_t _bool; /**** first design #include, #define VAR, #define FUNC() and #ifdef, #elif and #endif *****/ enum MacroType { define_t, include_t, line_t, undef_t, error_tt, pragma_t, defined_t, if_t, ifdef_t, ifndef_t, elif_t, else_t, endif_t, COMPILER_DATA, UNDEFINED, MAX_TYPE }; /*MacroType getIndexFromStr(string_t s) { string_t tmp; char* arr[13] = { "define","include","line","undef","error","pragma","defined","if","ifdef","ifndef","elif","else","endif" }; for (int i = 0; i < 13; i++) { tmp = string(arr[i]); if ((compare(tmp, s)) == 0) return (MacroType)i; } return UNDEF...