summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/befunge.c11
-rw-r--r--plugins/brainfuck.c4
-rw-r--r--plugins/forth.c5
-rw-r--r--plugins/lisp.c36
-rw-r--r--plugins/regex.c5
-rw-r--r--plugins/sql.c4
6 files changed, 37 insertions, 28 deletions
diff --git a/plugins/befunge.c b/plugins/befunge.c
index 844e27f..92165f4 100644
--- a/plugins/befunge.c
+++ b/plugins/befunge.c
@@ -80,7 +80,8 @@ void befunge_transpile(const char *input_body, const ZApi *api)
if (op >= '0' && op <= '9')
{
fprintf(out,
- " if(string_mode) { stack[sp++] = '%c'; } else { stack[sp++] = %c; }\n",
+ " if(string_mode) { stack[sp++] = '%c'; } else { "
+ "stack[sp++] = %c; }\n",
op, op);
}
else if (op == '"')
@@ -119,13 +120,13 @@ void befunge_transpile(const char *input_body, const ZApi *api)
}
else if (op == '/')
{
- fprintf(out,
- " { long a=stack[--sp]; stack[sp-1]= (a!=0)?stack[sp-1]/a:0; }\n");
+ fprintf(out, " { long a=stack[--sp]; stack[sp-1]= "
+ "(a!=0)?stack[sp-1]/a:0; }\n");
}
else if (op == '%')
{
- fprintf(out,
- " { long a=stack[--sp]; stack[sp-1]= (a!=0)?stack[sp-1]%%a:0; }\n");
+ fprintf(out, " { long a=stack[--sp]; stack[sp-1]= "
+ "(a!=0)?stack[sp-1]%%a:0; }\n");
}
else if (op == '!')
{
diff --git a/plugins/brainfuck.c b/plugins/brainfuck.c
index e800da7..576029b 100644
--- a/plugins/brainfuck.c
+++ b/plugins/brainfuck.c
@@ -4,8 +4,8 @@
void bf_transpile(const char *input_body, const ZApi *api)
{
FILE *out = api->out;
- fprintf(out,
- "{\n static unsigned char tape[30000] = {0};\n unsigned char *ptr = tape;\n");
+ fprintf(out, "{\n static unsigned char tape[30000] = {0};\n unsigned "
+ "char *ptr = tape;\n");
const char *c = input_body;
while (*c)
{
diff --git a/plugins/forth.c b/plugins/forth.c
index 9d39c6d..90e05c6 100644
--- a/plugins/forth.c
+++ b/plugins/forth.c
@@ -1,9 +1,9 @@
#include "zprep_plugin.h"
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <math.h>
static long stack[256];
static int sp = 0;
@@ -598,7 +598,8 @@ void process_forth_source(char *src, char **out_ptr)
void load_prelude()
{
- char prelude[] = ": squared fdup f* ; : hypot squared fswap squared f+ fsqrt ; : over swap dup "
+ char prelude[] = ": squared fdup f* ; : hypot squared fswap squared f+ fsqrt "
+ "; : over swap dup "
"rot rot ; : panic 0 1 - exit ; ";
char dummy_buf[1024];
dummy_buf[0] = '\0';
diff --git a/plugins/lisp.c b/plugins/lisp.c
index 7147928..439dd16 100644
--- a/plugins/lisp.c
+++ b/plugins/lisp.c
@@ -1,9 +1,9 @@
#include "zprep_plugin.h"
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
static void skip_whitespace(const char **p)
{
@@ -421,36 +421,42 @@ void lisp_transpile(const char *input_body, const ZApi *api)
FILE *h = api->hoist_out;
fprintf(h, "/* Lisp Runtime */\n");
fprintf(h, "typedef enum { L_NUM, L_PAIR, L_NIL } LType;\n");
- fprintf(h, "typedef struct LVal { LType type; union { long num; struct { struct LVal *car; "
+ fprintf(h, "typedef struct LVal { LType type; union { long num; struct { "
+ "struct LVal *car; "
"struct LVal *cdr; } pair; }; } *LVal;\n");
fprintf(h, "static struct LVal _nil = { L_NIL }; static LVal LNIL = &_nil;\n");
fprintf(h, "static LVal nil = &_nil;\n"); // Use static for file scope
fprintf(h, "static LVal l_num(long n) { LVal v = malloc(sizeof(struct LVal)); "
"v->type=L_NUM; v->num=n; return v; }\n");
fprintf(h, "static LVal l_nil() { return LNIL; }\n");
- fprintf(h, "static LVal l_cons(LVal a, LVal b) { LVal v = malloc(sizeof(struct LVal)); "
+ fprintf(h, "static LVal l_cons(LVal a, LVal b) { LVal v = "
+ "malloc(sizeof(struct LVal)); "
"v->type=L_PAIR; v->pair.car=a; v->pair.cdr=b; return v; }\n");
- fprintf(
- h,
- "static LVal l_car(LVal v) { return (v && v->type==L_PAIR) ? v->pair.car : LNIL; }\n");
- fprintf(
- h,
- "static LVal l_cdr(LVal v) { return (v && v->type==L_PAIR) ? v->pair.cdr : LNIL; }\n");
+ fprintf(h, "static LVal l_car(LVal v) { return (v && v->type==L_PAIR) ? "
+ "v->pair.car : LNIL; }\n");
+ fprintf(h, "static LVal l_cdr(LVal v) { return (v && v->type==L_PAIR) ? "
+ "v->pair.cdr : LNIL; }\n");
fprintf(h, "static int l_truthy(LVal v) { return (v && v->type!=L_NIL); }\n");
- fprintf(h, "static LVal l_add(LVal a, LVal b) { long x=(a&&a->type==L_NUM)?a->num:0; long "
+ fprintf(h, "static LVal l_add(LVal a, LVal b) { long "
+ "x=(a&&a->type==L_NUM)?a->num:0; long "
"y=(b&&b->type==L_NUM)?b->num:0; return l_num(x+y); }\n");
- fprintf(h, "static LVal l_sub(LVal a, LVal b) { long x=(a&&a->type==L_NUM)?a->num:0; long "
+ fprintf(h, "static LVal l_sub(LVal a, LVal b) { long "
+ "x=(a&&a->type==L_NUM)?a->num:0; long "
"y=(b&&b->type==L_NUM)?b->num:0; return l_num(x-y); }\n");
- fprintf(h, "static LVal l_mul(LVal a, LVal b) { long x=(a&&a->type==L_NUM)?a->num:0; long "
+ fprintf(h, "static LVal l_mul(LVal a, LVal b) { long "
+ "x=(a&&a->type==L_NUM)?a->num:0; long "
"y=(b&&b->type==L_NUM)?b->num:0; return l_num(x*y); }\n");
- fprintf(h, "static LVal l_div(LVal a, LVal b) { long x=(a&&a->type==L_NUM)?a->num:0; long "
+ fprintf(h, "static LVal l_div(LVal a, LVal b) { long "
+ "x=(a&&a->type==L_NUM)?a->num:0; long "
"y=(b&&b->type==L_NUM)?b->num:0; return l_num(y?x/y:0); }\n");
- fprintf(h, "static LVal l_lt(LVal a, LVal b) { long x=(a&&a->type==L_NUM)?a->num:0; long "
+ fprintf(h, "static LVal l_lt(LVal a, LVal b) { long "
+ "x=(a&&a->type==L_NUM)?a->num:0; long "
"y=(b&&b->type==L_NUM)?b->num:0; return (x<y)?l_num(1):LNIL; }\n");
fprintf(h, "static void l_print(LVal v) { \n");
fprintf(h, " if(!v || v->type==L_NIL) printf(\"nil\");\n");
fprintf(h, " else if(v->type==L_NUM) printf(\"%%ld\", v->num);\n");
- fprintf(h, " else if(v->type==L_PAIR) { printf(\"(\"); l_print(v->pair.car); printf(\" . "
+ fprintf(h, " else if(v->type==L_PAIR) { printf(\"(\"); "
+ "l_print(v->pair.car); printf(\" . "
"\"); l_print(v->pair.cdr); printf(\")\"); }\n");
fprintf(h, "}\n");
diff --git a/plugins/regex.c b/plugins/regex.c
index d7a8a97..b56515c 100644
--- a/plugins/regex.c
+++ b/plugins/regex.c
@@ -1,9 +1,9 @@
#include "zprep_plugin.h"
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
static void emit_match_logic(const char *pattern, FILE *out, int *label_counter);
@@ -111,7 +111,8 @@ static void emit_match_logic(const char *pattern, FILE *out, int * /*label_count
}
else
{
- fprintf(out, " if (*c == 0) return 0;\n"); // End of input for single char
+ fprintf(out,
+ " if (*c == 0) return 0;\n"); // End of input for single char
}
fprintf(out, " int match = 0;\n");
diff --git a/plugins/sql.c b/plugins/sql.c
index 0c563e2..130317f 100644
--- a/plugins/sql.c
+++ b/plugins/sql.c
@@ -1,14 +1,14 @@
#include "zprep_plugin.h"
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
typedef struct Col
{
char name[32];
- char type[32];
+ char type[32];
struct Col *next;
} Col;