Compare commits

...

3 Commits

Author SHA1 Message Date
2834e28db2 Updated markdown. 2025-03-28 03:10:54 +01:00
80d72823f7 Update markdown. 2025-03-28 03:02:24 +01:00
cc1c6570e3 Transactions. 2025-03-28 02:41:15 +01:00
7 changed files with 34 additions and 7 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ rf
auth.h
.rcontext*
tests
rpylib.so

2
chat.h
View File

@ -54,7 +54,7 @@ char *chat_json(const char *role, const char *message) {
}
json_object_object_add(root_object, "messages", message_list());
json_object_object_add(root_object, "max_tokens", json_object_new_int(prompt_max_tokens));
// json_object_object_add(root_object, "max_tokens", json_object_new_int(prompt_max_tokens));
json_object_object_add(root_object, "temperature", json_object_new_double(prompt_temperature));
return (char *)json_object_to_json_string_ext(root_object, JSON_C_TO_STRING_PRETTY);

View File

@ -35,7 +35,29 @@
#define FG_CYAN "\033[36m"
int is_keyword(const char *word) {
const char *keywords[] = {"int", "float", "double", "char", "void", "if", "else", "while", "for", "return", "struct", "printf"};
const char *keywords[] = {
"int", "float", "double", "char", "void",
"if", "else", "while", "for", "return",
"struct", "printf",
// Rust keywords
"let", "fn", "impl", "match", "enum", "trait", "use", "mod", "pub", "const", "static",
// Python keywords
"def", "class", "import", "from", "as", "with", "try", "except", "finally", "lambda", "async", "await",
// Java keywords
"public", "private", "protected", "class", "interface", "extends", "implements", "new", "static", "final", "synchronized",
// JavaScript keywords
"var", "let", "const", "function", "async", "await", "if", "else", "switch", "case", "break", "continue", "return",
// C++ keywords
"namespace", "template", "typename", "class", "public", "private", "protected", "virtual", "override", "friend", "new",
// Go keywords
"package", "import", "func", "var", "const", "type", "interface", "struct", "go", "defer", "select",
// Bash keywords
"if", "then", "else", "elif", "fi", "case", "esac", "for", "while", "until", "do", "done", "function",
// C# keywords
"namespace", "using", "class", "interface", "public", "private", "protected", "static", "void", "new", "override"
};
for (size_t i = 0; i < sizeof(keywords) / sizeof(keywords[0]); i++) {
if (strcmp(word, keywords[i]) == 0) {
return 1;
@ -81,7 +103,7 @@ void parse_markdown_to_ansi(const char *markdown) {
bool inside_code = false;
while (*ptr) {
if (*ptr == '`') {
if (*ptr == '`' && *(ptr + 1) != '`') {
inside_code = !inside_code;
if (inside_code) {
printf(FG_YELLOW);
@ -90,10 +112,13 @@ void parse_markdown_to_ansi(const char *markdown) {
}
ptr++;
continue;
}else if(!strncmp(ptr, "```", 3)) {
inside_code = !inside_code;
ptr = strstr(ptr, "\n") + 1;
}
if (inside_code) {
char code_buffer[4096];
char code_buffer[1024*1024] = {0};;
size_t index = 0;
while (*ptr && *ptr != '`') {
@ -152,4 +177,4 @@ void parse_markdown_to_ansi(const char *markdown) {
}
}
}
}
}

2
r.h
View File

@ -3,7 +3,7 @@
#include "malloc.h"
#include <stdbool.h>
#include <string.h>
#include "utils.h"
#include "auth.h"
bool is_verbose = false;

BIN
rpylib.so

Binary file not shown.

View File

@ -8,7 +8,7 @@
#ifndef R_TOOLS_H
#define R_TOOLS_H
#include "r.h"
#include <stdio.h>
#include <json-c/json.h>
#include <json-c/json_object.h>

View File

@ -12,6 +12,7 @@
#ifndef UTILS_H
#define UTILS_H
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>