fortrangoingonforty/fortbite / 9816bbb

Browse files

wash my hands of this

Authored by espadonne
SHA
9816bbb92c8f73f3c47dec51f51edf34ef4ba1c5
Parents
f31e787
Tree
96d3a6e

9 changed files

StatusFile+-
D CMakeLists.txt 0 143
D include/config.h 0 6
D include/export.h 0 6
D include/fortbite.h 0 30
D include/math.h 0 19
D include/plotting.h 0 6
D include/plugins.h 0 6
D include/types.h 0 111
D include/units.h 0 6
CMakeLists.txtdeleted
@@ -1,143 +0,0 @@
1
-cmake_minimum_required(VERSION 3.12)
2
-project(fortbite VERSION 1.0.0 LANGUAGES C)
3
-
4
-set(CMAKE_C_STANDARD 11)
5
-set(CMAKE_C_STANDARD_REQUIRED ON)
6
-
7
-# Find required packages
8
-find_package(PkgConfig REQUIRED)
9
-
10
-# Find GMP and MPFR for arbitrary precision arithmetic
11
-pkg_check_modules(GMP REQUIRED gmp)
12
-pkg_check_modules(MPFR REQUIRED mpfr)
13
-
14
-# Find readline for CLI features
15
-find_library(READLINE_LIB readline)
16
-if(NOT READLINE_LIB)
17
-    message(FATAL_ERROR "libreadline not found")
18
-endif()
19
-
20
-# Include directories
21
-include_directories(include)
22
-include_directories(${GMP_INCLUDE_DIRS})
23
-include_directories(${MPFR_INCLUDE_DIRS})
24
-
25
-# Compiler flags
26
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic")
27
-set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -DDEBUG")
28
-set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG")
29
-
30
-# Source files
31
-set(CORE_SOURCES
32
-    src/core/main.c
33
-    src/core/engine.c
34
-    src/core/types.c
35
-    src/core/memory.c
36
-)
37
-
38
-set(PARSER_SOURCES
39
-    src/parser/lexer.c
40
-    src/parser/parser.c
41
-    src/parser/ast.c
42
-    src/parser/syntax.c
43
-)
44
-
45
-set(MATH_SOURCES
46
-    src/math/precision.c
47
-    src/math/arithmetic.c
48
-    src/math/complex.c
49
-    src/math/matrix.c
50
-    src/math/functions.c
51
-)
52
-
53
-set(UNITS_SOURCES
54
-    src/units/converter.c
55
-    src/units/database.c
56
-    src/units/parser.c
57
-)
58
-
59
-set(PLOTTING_SOURCES
60
-    src/plotting/ascii_plot.c
61
-    src/plotting/data.c
62
-    src/plotting/export.c
63
-)
64
-
65
-set(EXPORT_SOURCES
66
-    src/export/formats.c
67
-    src/export/csv.c
68
-    src/export/json.c
69
-    src/export/latex.c
70
-)
71
-
72
-set(CONFIG_SOURCES
73
-    src/config/config.c
74
-    src/config/defaults.c
75
-    src/config/validation.c
76
-)
77
-
78
-set(PLUGINS_SOURCES
79
-    src/plugins/loader.c
80
-    src/plugins/api.c
81
-    src/plugins/registry.c
82
-)
83
-
84
-set(CLI_SOURCES
85
-    src/cli/interface.c
86
-    src/cli/history.c
87
-    src/cli/completion.c
88
-    src/cli/display.c
89
-)
90
-
91
-set(UTILS_SOURCES
92
-    src/utils/string.c
93
-    src/utils/file.c
94
-    src/utils/debug.c
95
-)
96
-
97
-set(ALL_SOURCES
98
-    ${CORE_SOURCES}
99
-    ${PARSER_SOURCES}
100
-    ${MATH_SOURCES}
101
-    ${UNITS_SOURCES}
102
-    ${PLOTTING_SOURCES}
103
-    ${EXPORT_SOURCES}
104
-    ${CONFIG_SOURCES}
105
-    ${PLUGINS_SOURCES}
106
-    ${CLI_SOURCES}
107
-    ${UTILS_SOURCES}
108
-)
109
-
110
-# Create executable
111
-add_executable(fortbite ${ALL_SOURCES})
112
-
113
-# Link libraries
114
-target_link_libraries(fortbite 
115
-    ${GMP_LIBRARIES}
116
-    ${MPFR_LIBRARIES}
117
-    ${READLINE_LIB}
118
-    dl  # for dynamic loading
119
-    m   # math library
120
-)
121
-
122
-# Install target
123
-install(TARGETS fortbite DESTINATION bin)
124
-install(DIRECTORY data/ DESTINATION share/fortbite/data)
125
-
126
-# Enable testing
127
-enable_testing()
128
-
129
-# Unit tests
130
-file(GLOB TEST_SOURCES tests/unit/*.c)
131
-foreach(test_source ${TEST_SOURCES})
132
-    get_filename_component(test_name ${test_source} NAME_WE)
133
-    add_executable(${test_name} ${test_source} ${ALL_SOURCES})
134
-    target_compile_definitions(${test_name} PRIVATE TESTING)
135
-    target_link_libraries(${test_name} 
136
-        ${GMP_LIBRARIES}
137
-        ${MPFR_LIBRARIES}
138
-        ${READLINE_LIB}
139
-        dl
140
-        m
141
-    )
142
-    add_test(NAME ${test_name} COMMAND ${test_name})
143
-endforeach()
include/config.hdeleted
@@ -1,6 +0,0 @@
1
-#ifndef FORTBITE_CONFIG_H
2
-#define FORTBITE_CONFIG_H
3
-
4
-#include "types.h"
5
-
6
-#endif
include/export.hdeleted
@@ -1,6 +0,0 @@
1
-#ifndef FORTBITE_EXPORT_H
2
-#define FORTBITE_EXPORT_H
3
-
4
-#include "types.h"
5
-
6
-#endif
include/fortbite.hdeleted
@@ -1,30 +0,0 @@
1
-#ifndef FORTBITE_H
2
-#define FORTBITE_H
3
-
4
-#include <stdio.h>
5
-#include <stdlib.h>
6
-#include <stdint.h>
7
-#include <stdbool.h>
8
-#include <string.h>
9
-#include <gmp.h>
10
-#include <mpfr.h>
11
-
12
-#define FORTBITE_VERSION "1.0.0"
13
-#define DEFAULT_PRECISION 50
14
-
15
-typedef struct fortbite_context fortbite_context_t;
16
-
17
-int fortbite_init(void);
18
-void fortbite_cleanup(void);
19
-fortbite_context_t* fortbite_context_new(void);
20
-void fortbite_context_free(fortbite_context_t* ctx);
21
-
22
-#include "types.h"
23
-#include "math.h"
24
-#include "units.h"
25
-#include "plotting.h"
26
-#include "export.h"
27
-#include "config.h"
28
-#include "plugins.h"
29
-
30
-#endif
include/math.hdeleted
@@ -1,19 +0,0 @@
1
-#ifndef FORTBITE_MATH_H
2
-#define FORTBITE_MATH_H
3
-
4
-#include "types.h"
5
-
6
-fortbite_token_t* fortbite_tokenize(const char* input);
7
-void fortbite_tokens_free(fortbite_token_t* tokens);
8
-
9
-void* fortbite_malloc(size_t size);
10
-void* fortbite_calloc(size_t count, size_t size);
11
-void* fortbite_realloc(void* ptr, size_t size);
12
-void fortbite_free(void* ptr);
13
-char* fortbite_strdup(const char* str);
14
-
15
-#ifdef DEBUG
16
-void fortbite_memory_stats(void);
17
-#endif
18
-
19
-#endif
include/plotting.hdeleted
@@ -1,6 +0,0 @@
1
-#ifndef FORTBITE_PLOTTING_H
2
-#define FORTBITE_PLOTTING_H
3
-
4
-#include "types.h"
5
-
6
-#endif
include/plugins.hdeleted
@@ -1,6 +0,0 @@
1
-#ifndef FORTBITE_PLUGINS_H
2
-#define FORTBITE_PLUGINS_H
3
-
4
-#include "types.h"
5
-
6
-#endif
include/types.hdeleted
@@ -1,111 +0,0 @@
1
-#ifndef TYPES_H
2
-#define TYPES_H
3
-
4
-#include <gmp.h>
5
-#include <mpfr.h>
6
-#include <stddef.h>
7
-
8
-typedef enum {
9
-    FORTBITE_TYPE_SCALAR,
10
-    FORTBITE_TYPE_COMPLEX,
11
-    FORTBITE_TYPE_MATRIX,
12
-    FORTBITE_TYPE_UNIT,
13
-    FORTBITE_TYPE_FUNCTION,
14
-    FORTBITE_TYPE_UNDEFINED
15
-} fortbite_type_t;
16
-
17
-typedef struct {
18
-    mpfr_t value;
19
-    int precision;
20
-} fortbite_scalar_t;
21
-
22
-typedef struct {
23
-    fortbite_scalar_t real;
24
-    fortbite_scalar_t imag;
25
-} fortbite_complex_t;
26
-
27
-typedef struct {
28
-    size_t rows;
29
-    size_t cols;
30
-    fortbite_complex_t** data;
31
-    bool is_sparse;
32
-} fortbite_matrix_t;
33
-
34
-typedef struct fortbite_unit {
35
-    char* name;
36
-    char* symbol;
37
-    double factor;
38
-    int dimension[7];  // SI base units: m, kg, s, A, K, mol, cd
39
-    struct fortbite_unit* base_unit;
40
-} fortbite_unit_t;
41
-
42
-typedef struct {
43
-    fortbite_complex_t value;
44
-    fortbite_unit_t* unit;
45
-} fortbite_quantity_t;
46
-
47
-typedef struct {
48
-    fortbite_type_t type;
49
-    union {
50
-        fortbite_scalar_t scalar;
51
-        fortbite_complex_t complex;
52
-        fortbite_matrix_t matrix;
53
-        fortbite_quantity_t quantity;
54
-    } data;
55
-} fortbite_value_t;
56
-
57
-typedef struct fortbite_variable {
58
-    char* name;
59
-    fortbite_value_t value;
60
-    struct fortbite_variable* next;
61
-} fortbite_variable_t;
62
-
63
-typedef enum {
64
-    TOKEN_NUMBER,
65
-    TOKEN_IDENTIFIER,
66
-    TOKEN_OPERATOR,
67
-    TOKEN_LPAREN,
68
-    TOKEN_RPAREN,
69
-    TOKEN_LBRACKET,
70
-    TOKEN_RBRACKET,
71
-    TOKEN_SEMICOLON,
72
-    TOKEN_COMMA,
73
-    TOKEN_ASSIGN,
74
-    TOKEN_PRECISION,
75
-    TOKEN_UNIT,
76
-    TOKEN_EOF,
77
-    TOKEN_ERROR
78
-} fortbite_token_type_t;
79
-
80
-typedef struct {
81
-    fortbite_token_type_t type;
82
-    char* value;
83
-    size_t length;
84
-    size_t position;
85
-} fortbite_token_t;
86
-
87
-fortbite_value_t* fortbite_value_new(fortbite_type_t type);
88
-void fortbite_value_free(fortbite_value_t* value);
89
-fortbite_value_t* fortbite_value_copy(const fortbite_value_t* value);
90
-
91
-void fortbite_scalar_new_init(fortbite_scalar_t* scalar, int precision);
92
-void fortbite_scalar_clear(fortbite_scalar_t* scalar);
93
-void fortbite_scalar_set_d(fortbite_scalar_t* scalar, double value);
94
-void fortbite_scalar_set_str(fortbite_scalar_t* scalar, const char* str, int base);
95
-void fortbite_scalar_set(fortbite_scalar_t* dest, const fortbite_scalar_t* src);
96
-
97
-void fortbite_complex_new_init(fortbite_complex_t* complex, int precision);
98
-void fortbite_complex_clear(fortbite_complex_t* complex);
99
-void fortbite_complex_set(fortbite_complex_t* dest, const fortbite_complex_t* src);
100
-
101
-fortbite_matrix_t fortbite_matrix_new(size_t rows, size_t cols, int precision);
102
-void fortbite_matrix_clear(fortbite_matrix_t* matrix);
103
-fortbite_matrix_t fortbite_matrix_copy(const fortbite_matrix_t* src);
104
-void fortbite_matrix_free(fortbite_matrix_t* matrix);
105
-fortbite_complex_t* fortbite_matrix_get(const fortbite_matrix_t* matrix, size_t row, size_t col);
106
-void fortbite_matrix_set(fortbite_matrix_t* matrix, size_t row, size_t col, const fortbite_complex_t* value);
107
-
108
-fortbite_variable_t* fortbite_variable_new(const char* name, const fortbite_value_t* value);
109
-void fortbite_variable_free(fortbite_variable_t* var);
110
-
111
-#endif
include/units.hdeleted
@@ -1,6 +0,0 @@
1
-#ifndef FORTBITE_UNITS_H
2
-#define FORTBITE_UNITS_H
3
-
4
-#include "types.h"
5
-
6
-#endif