summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/3cl.h120
-rw-r--r--include/instruction.h17
-rw-r--r--include/instructions.h23
-rw-r--r--include/main.h6
-rw-r--r--include/platform/getch.h13
-rw-r--r--include/readchar.h44
-rw-r--r--include/readfile.h11
-rw-r--r--include/stack.h21
-rw-r--r--include/utils.h16
-rw-r--r--include/variable.h29
10 files changed, 0 insertions, 300 deletions
diff --git a/include/3cl.h b/include/3cl.h
deleted file mode 100644
index 4466490..0000000
--- a/include/3cl.h
+++ /dev/null
@@ -1,120 +0,0 @@
-#ifndef __3CL_H__
-#define __3CL_H__
-
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-
-
-#ifndef CCL_STACKSIZE
-#define CCL_STACKSIZE 8192
-#endif
-
-typedef int16_t CCLNum;   /**< Abstract type for numbers in ccl */
-typedef size_t  CCLAddr;  /**< Abstract type for address in ccl */
-
-/**
- * Type of CCLFrame
- */
-enum CCLFrameType
-{
-    CCL_ROOT,    /**< Root frame, stores global variables    */
-    CCL_PROC,    /**< Function frame, stores local variables */
-    CCL_INFLOOP, /**< Infinity loop, stores start and repeat */
-    CCL_REPLOOP, /**< Repeat loop, stores start and repeat   */
-};
-
-/**
- * Pair which contains variable's name and value
- */
-struct CCLVariable
-{
-    struct CCLVariable *prev, *next;
-    char                name;
-    CCLNum              value;
-};
-
-/**
- * Pair which contains procedure's name and address
- */
-struct CCLProcedure
-{
-    struct CCLProcedure *prev, *next;
-    char                 name;
-    CCLAddr              address;
-};
-
-/**
- * Pair with length of stack and stack itself
- */
-struct CCLStack
-{
-    size_t  length;
-    size_t  cur;
-    CCLNum *stack;
-};
-
-/**
- * Linked list that stores current state and allows to do recursion with local variables.
- */
-struct CCLFrame
-{
-    struct  CCLFrame      *prev, *next;  /**< Frames are connected as linked list */
-    enum    CCLFrameType   type;         /**< Type of the frame                   */
-    CCLAddr                ep;           /**< Execution point                     */
-    union
-    {
-        /* Frame stores either variables (for procedures)... */
-        struct
-        {
-            struct  CCLVariable vars;    /**< For root frame variables are global */
-        };
-        /* ...or start address and repeats left (for loops) */
-        struct
-        {
-            CCLAddr start;               /**< Used by CCL_*LOOP                   */
-            int     repeats;             /**< Used by CCL_REPLOOP                 */
-        };
-    };
-};
-
-/**
- * Main structure for 3cl. It contains root frame, stack and code it's executing.
- */
-struct CCL
-{
-    struct CCLStack   stack;
-    struct CCLFrame   rootframe;
-    const char       *code;
-    bool              stopped;
-    int             (*in)();
-    void            (*out)(int);
-};
-
-/**
- * Inits CCL.
- * @see ccl_free
- * @see ccl_exec
- * @param ccl The structure to init
- * @param code The code to execute
- * @param in Function to get input
- * @param out Function to show output
- * @return 0 on success, any other number otherwise
- */
-int ccl_init(struct CCL *ccl, const char *code, int (*in)(), void (*out)(int));
-
-/**
- * Frees all things that ware allocated in ccl_init.
- * @see ccl_init
- * @param ccl The structure to free
- */
-void ccl_free(struct CCL *ccl);
-
-/**
- * Executes inited CCL instance
- * @see ccl_init
- * @param ccl The strcture to execute
- */
-void ccl_exec(struct CCL *ccl);
-
-#endif /* __3CL_H__ */
diff --git a/include/instruction.h b/include/instruction.h
deleted file mode 100644
index 63f28b2..0000000
--- a/include/instruction.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __CCL_INSTRUCTION_H__
-#define __CCL_INSTRUCTION_H__
-
-#include "3cl.h"
-
-/**< Type for every instruction in 3cl */
-typedef struct CCLFrame *(*CCLInstruction)(struct CCL *ccl, struct CCLFrame *frame);
-
-/**
- * Execute next instruction
- * @param ccl CCL instance
- * @param frame Current frame
- * @return Updated frame
- */
-struct CCLFrame *ccl_instruction(struct CCL *ccl, struct CCLFrame *frame);
-
-#endif /* __CCL_INSTRUCTION_H__ */
diff --git a/include/instructions.h b/include/instructions.h
deleted file mode 100644
index 04509e9..0000000
--- a/include/instructions.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef __CCL_INSTRUCTIONS_H__
-#define __CCL_INSTRUCTIONS_H__
-
-#include "3cl.h"
-
-
-#define INST(NAME) \
-    struct CCLFrame *ccl_instruction_##NAME(struct CCL *ccl, struct CCLFrame *frame)
-
-INST(nop);
-INST(pushzero);
-INST(increment);
-INST(decrement);
-INST(add);
-INST(subtract);
-INST(reverse);
-INST(assign);
-INST(invalid);
-
-#undef INST
-#define INST(NAME) ccl_instruction_##NAME
-
-#endif /* __CCL_INSTRUCTIONS_H__ */
diff --git a/include/main.h b/include/main.h
deleted file mode 100644
index 64abb24..0000000
--- a/include/main.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __MAIN_H__
-#define __MAIN_H__
-
-extern const char *program_name; /**< argv[0] */
-
-#endif /* __MAIN_H__ */
diff --git a/include/platform/getch.h b/include/platform/getch.h
deleted file mode 100644
index 490b536..0000000
--- a/include/platform/getch.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef __GETCH_H__
-#define __GETCH_H__
-
-#ifdef _WIN32
-#include <conio.h>
-#define getch _getche
-#else
-int getch(void);
-#endif /* _WIN32 */
-
-void getch_init(void);
-
-#endif /* __GETCH_H__ */
diff --git a/include/readchar.h b/include/readchar.h
deleted file mode 100644
index e881dcb..0000000
--- a/include/readchar.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef __CCL_READCHAR_H__
-#define __CCL_READCHAR_H__
-
-#include "3cl.h"
-
-
-/**
- * Flags to tell ccl_readchar how to read next character
- *
- * Bits
- * 4 Die if char is not whitelisted
- * 3 Brackets
- * 2 Instruction symbols
- * 1 English alphabet
- * 0 Underscore
- *
- * @see ccl_readchar
- */
-enum CCLRCFlags
-{
-    CCL_RC_DIE   = 0b10000, /**< Die if char is not whitelisted */
-    CCL_RC_BRACK = 0b01000, /**< Brackes                        */
-    CCL_RC_IS    = 0b00100, /**< Instruction symbols            */
-    CCL_RC_ALP   = 0b00010, /**< English alphabet               */
-    CCL_RC_US    = 0b00001, /**< Underscore                     */
-    CCL_RC_VAR       = 0b11010, /**< (Used by 3CL) Variable names                      */
-    CCL_RC_CCL_VARUS = 0b11011, /**< (Used by 3CL) Variable names including underscore */
-    CCL_RC_CCL_BRACK = 0b01000, /**< (Used by 3CL) Brackets                            */
-    CCL_RC_CCL_INSTR = 0b11111, /**< (Used by 3CL) Instruction                         */
-};
-
-/**
- * Function to read next character
- * Skips whitespace and comments, returns '\0' if reaches EOF
- * ccl_readchar will die on invalid symbol (e.g. cyrillic one) even if CCL_RC_DIE is set
- * @see CCLRCFlags
- * @param ccl CCL instance
- * @param frame Current frame
- * @param flags CCLRCFlags
- * @return Next character
- */
-char ccl_readchar(struct CCL *ccl, struct CCLFrame *frame, enum CCLRCFlags flags);
-
-#endif /* __CCL_READCHAR_H__ */
diff --git a/include/readfile.h b/include/readfile.h
deleted file mode 100644
index dcb47eb..0000000
--- a/include/readfile.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __READFILE_H__
-#define __READFILE_H__
-
-/**
- * Read file by filename, die on error
- * @param name Path to file
- * @return Contents of file with additional '\0' at the end
- */
-char *readfile(const char *name);
-
-#endif /* __READFILE_H__ */
diff --git a/include/stack.h b/include/stack.h
deleted file mode 100644
index ac17ed3..0000000
--- a/include/stack.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __CCL_STACK_H__
-#define __CCL_STACK_H__
-
-#include "3cl.h"
-
-
-/**
- * Push num to the stack
- * @param stack Stack where to push
- * @param num Number to push
- */
-void ccl_stack_push(struct CCLStack *stack, CCLNum num);
-
-/**
- * Pop number from the stack
- * @param stack Stack from where to pop
- * @return Popped number
- */
-CCLNum ccl_stack_pop(struct CCLStack *stack);
-
-#endif /* __CCL_STACK_H__ */
diff --git a/include/utils.h b/include/utils.h
deleted file mode 100644
index f415abc..0000000
--- a/include/utils.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __UTILS_H__
-#define __UTILS_H__
-
-#include <stdnoreturn.h>
-
-
-/**
- * Show message:
- * program_name: <formattedstring>\n
- * and exit with code
- * @param code Code to exit
- * @param fmt Format string
- */
-noreturn void die(int code, char *fmt, ...);
-
-#endif /* __UTILS_H__ */
diff --git a/include/variable.h b/include/variable.h
deleted file mode 100644
index f392a33..0000000
--- a/include/variable.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __CCL_VARIABLE_H__
-#define __CCL_VARIABLE_H__
-
-#include "3cl.h"
-
-
-/**
- * Try to find variable in list, NULL if not found.
- * @see ccl_variable_getany
- * @param vars Variable list
- * @param name Variable name
- */
-struct CCLVariable *ccl_variable_get(struct CCLVariable *vars, char name);
-
-/**
- * Try to find variable in current frame, then in root, NULL if not found.
- * @see ccl_variable_get
- * @param ccl CCL instance
- * @param frame Current frame
- * @param name Variable name
- */
-struct CCLVariable *ccl_variable_getany(struct CCL *ccl, struct CCLFrame *frame, char name);
-
-/**
- * Create new variable in list
- */
-struct CCLVariable *ccl_variable_set(struct CCLVariable *vars, char name, CCLNum value);
-
-#endif /* __CCL_VARIABLE_H__ */