Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulya Trofimovich committed Dec 11, 2024
0 parents commit d427fd9
Show file tree
Hide file tree
Showing 303 changed files with 85,251 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: f37c26ea3c129989b651949c8400a616
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file added .doctrees/benchmarks/benchmarks.doctree
Binary file not shown.
Binary file added .doctrees/benchmarks/c/env.doctree
Binary file not shown.
Binary file added .doctrees/benchmarks/c/libre2c/jit/env.doctree
Binary file not shown.
Binary file added .doctrees/benchmarks/c/libre2c/nfa/env.doctree
Binary file not shown.
Binary file added .doctrees/build/build.doctree
Binary file not shown.
Binary file added .doctrees/environment.pickle
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .doctrees/examples/examples_c.doctree
Binary file not shown.
Binary file added .doctrees/examples/examples_d.doctree
Binary file not shown.
Binary file added .doctrees/examples/examples_go.doctree
Binary file not shown.
Binary file added .doctrees/examples/examples_haskell.doctree
Binary file not shown.
Binary file added .doctrees/examples/examples_java.doctree
Binary file not shown.
Binary file added .doctrees/examples/examples_js.doctree
Binary file not shown.
Binary file added .doctrees/examples/examples_ocaml.doctree
Binary file not shown.
Binary file added .doctrees/examples/examples_python.doctree
Binary file not shown.
Binary file added .doctrees/examples/examples_rust.doctree
Binary file not shown.
Binary file added .doctrees/examples/examples_v.doctree
Binary file not shown.
Binary file added .doctrees/examples/examples_zig.doctree
Binary file not shown.
Binary file not shown.
Binary file added .doctrees/index.doctree
Binary file not shown.
Binary file added .doctrees/install/install.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .doctrees/manual/basics/warnings/warnings.doctree
Binary file not shown.
Binary file added .doctrees/manual/features/dot/example.doctree
Binary file not shown.
Binary file not shown.
Binary file added .doctrees/manual/manual.doctree
Binary file not shown.
Binary file added .doctrees/manual/manual_c.doctree
Binary file not shown.
Binary file added .doctrees/manual/manual_d.doctree
Binary file not shown.
Binary file added .doctrees/manual/manual_go.doctree
Binary file not shown.
Binary file added .doctrees/manual/manual_hs.doctree
Binary file not shown.
Binary file added .doctrees/manual/manual_java.doctree
Binary file not shown.
Binary file added .doctrees/manual/manual_js.doctree
Binary file not shown.
Binary file added .doctrees/manual/manual_ocaml.doctree
Binary file not shown.
Binary file added .doctrees/manual/manual_py.doctree
Binary file not shown.
Binary file added .doctrees/manual/manual_rust.doctree
Binary file not shown.
Binary file added .doctrees/manual/manual_v.doctree
Binary file not shown.
Binary file added .doctrees/manual/manual_zig.doctree
Binary file not shown.
Binary file added .doctrees/releases/changelog/changelog.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/0_15.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/0_15_1.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/0_15_2.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/0_15_3.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/0_16.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/1_0.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/1_0_1.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/1_0_2.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/1_0_3.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/1_1.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/1_1_1.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/1_2.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/1_2_1.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/1_3.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/2_0.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/2_0_1.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/2_0_2.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/2_0_3.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/2_1.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/2_1_1.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/2_2.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/3_0.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/3_1.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/4_0.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/4_0_1.doctree
Binary file not shown.
Binary file added .doctrees/releases/release_notes/4_0_2.doctree
Binary file not shown.
Empty file added .nojekyll
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
re2c.org
113 changes: 113 additions & 0 deletions _downloads/059776af7897d85a01b707b04aab941b/parse_records.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// re2c $INPUT -o $OUTPUT -i
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

struct mtag_t
{
int pred;
const char *tag;
};

typedef std::vector<mtag_t> mtagpool_t;

static void mtag(int *pt, const char *t, mtagpool_t *tp) {
mtag_t l = {*pt, t};
*pt = (int) tp->size();
tp->push_back(l);
}

static void print_channels(const mtagpool_t &tp, int x, int y) {
if (x == -1) return;
print_channels(tp, tp[x].pred, tp[y].pred);
const char *px = tp[x].tag, *py = tp[y].tag;
fprintf(stderr, " %.*s\n", (int) (py - px), px);
}

#define YYMTAGP(t) mtag(&t, YYCURSOR, &tp)
#define YYMTAGN(t) mtag(&t, NULL, &tp)

static int lex(const char *YYCURSOR) {
const char *YYMARKER, *n1, *n2, *a1, *a2, *c1, *c2;
mtagpool_t tp;
int h1, h2;
/*!stags:re2c format = "const char *@@;"; */
/*!mtags:re2c format = "int @@;"; */

for (;;) {
tp.clear();
/*!mtags:re2c format = "@@ = -1;"; */
/*!re2c
re2c:define:YYCTYPE = char;
re2c:yyfill:enable = 0;
re2c:tags = 1;
end = "\x00";
eol = "\n";
wsp = [ \t]*;
eq = wsp "=" wsp;
nick = [a-zA-Z0-9_]+;
name = [A-Z] ("." | [a-z]+);
names = name (wsp name)*;
country = [A-Za-z ]+;
channel = ([a-z0-9-]+ "/")? "#" [a-z0-9-]+;
* { fprintf(stderr, "error: %s\n", YYCURSOR); return 1; }
end { return 0; }
wsp | eol { continue; }
@n1 nick @n2 wsp "{" wsp eol
wsp "name" eq @a1 names @a2 wsp eol
wsp "country" eq @c1 country @c2 wsp eol
wsp "channels" eq (wsp #h1 channel #h2 wsp ";")* wsp eol
wsp "}" {
fprintf(stderr, "\n%.*s\n", (int) (n2 - n1), n1);
fprintf(stderr, " name: %.*s\n", (int) (a2 - a1), a1);
fprintf(stderr, " country: %.*s\n", (int) (c2 - c1), c1);
fprintf(stderr, " channels:\n");
print_channels(tp, h1, h2);
continue;
}
*/
}
}

int main() {
const char *fname = "etc_passwd";
FILE *f;

// prepare input file
f = fopen(fname, "w");
fprintf(f,
"h4cker1970 {\n"
" name = Jon Smith\n"
" country = UK\n"
" channels = freenode/#gentoo-dev; freenode/#gentoo-arch; freenode/#alpha;\n"
"}\n"
"\n"
"mitek {\n"
" name = Mitrofan Rygoravich\n"
" country = Belarus\n"
" channels = bynets/#haskell; freenode/#unix;\n"
"}\n"
"\n");
fclose(f);

// read input file into buffer
f = fopen(fname, "r");
fseek(f, 0, SEEK_END);
const size_t fsize = (size_t) ftell(f);
fseek(f, 0, SEEK_SET);
char *buffer = (char*) malloc(fsize + 1);
fread(buffer, 1, fsize, f);
buffer[fsize] = 0;
fclose(f);

assert(lex(buffer) == 0);

// cleanup
remove(fname);
free(buffer);
return 0;
}
Loading

0 comments on commit d427fd9

Please sign in to comment.