• Stars
    star
    117
  • Rank 293,230 (Top 6 %)
  • Language
    Zig
  • Created almost 4 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Compile time regular expressions in zig

Zig compile time regular expressions

Generating fast code since 2020

Features

  • Comptime regular expression compilation
  • Comptime and runtime matching
  • UTF8, UTF16le, ASCII, codepoint array support
  • Captures (with named (:<name>...) support)
  • |, *, +, ?, (:?...), [...], [^...], {N}, {min,}, {min,max}
  • '\d', '\s' character classes

TODO

  • Faster generated code using DFAs when possible
  • search, findAll, etc.
  • More character classes
  • More features (backreferences etc.)

Example

test "runtime matching" {
    @setEvalBranchQuota(1250);
    // The encoding is utf8 by default, you can use .ascii, .utf16le, .codepoint here instead.
    if (try match("(?<test>def|abc)([😇ω])+", .{.encoding = .utf8}, "abc😇ωωωωω")) |res| {
        std.debug.warn("Test: {}, 1: {}\n", .{ res.capture("test"), res.captures[1] });
    }
}

test "comptime matching" {
    @setEvalBranchQuota(2700);
    if (comptime try match("(?<test>def|abc)([😇ω])+", .{}, "abc😇ωωωωω")) |res| {
        @compileError("Test: " ++ res.capture("test").? ++ ", 1: " ++ res.captures[1].?);
    }
}

See tests.zig for more examples.
Small benchmark with ctregex, PCRE2

More Repositories

1

interface.zig

Dynamic dispatch for zig made easy
Zig
157
star
2

iguanaTLS

Minimal, experimental TLS 1.2 implementation in Zig
Zig
85
star
3

PeerType

Zig peer type resolution at comptime, ported from the compiler source code
Zig
15
star
4

zig-wasi

Zig stage2 compiler compiled as a wasm module that uses wasi
Zig
10
star
5

zdwg

Read, manipulate, write AutoCad DWG files in zig
Zig
7
star
6

slights

HTTP server written in ooc
ooc
5
star
7

lepto.zig

Date and time library for zig, inspired by C++20 std::chrono
Zig
4
star
8

analysis-buddy

Analysis buddy for the zig issue linker discord bot
Zig
4
star
9

gooc-gen

ooc binding generator based on the ooc GObject-Introspection binding, ooc-gi
ooc
3
star
10

sparrow

Multiplatform GUI framework written entirely in ooc.
ooc
3
star
11

rock-dev

The rock developer handbook.
2
star
12

cooved

ooc ide written in ooc
1
star
13

ooc-gi

GObject-Introspection bindings for ooc
ooc
1
star
14

ooc-fmod

FMOD ooc bindings
ooc
1
star
15

oocui

ooc bindings for the IUP GUI framework
ooc
1
star
16

libBPScript

A C++ library to manage bullet patterns of shmup games.
C++
1
star
17

rapidograph

ooc static web framework (generates static pages instead of creating them on each request)
1
star
18

libootcc

libtcc ooc binding
1
star
19

scc

The Shoddy C Compiler (self hosting unstable C11 compiler).
C
1
star
20

oc-c89

C89 backend for the oc compiler
ooc
1
star
21

llamaweb

Simple web framework for ooc. Not MVC(yet?)
ooc
1
star
22

ooc-js

ooc to javascript experiment
ooc
1
star
23

oc-nagaqueen

Nagaqueen frontend for the oc compiler
C
1
star
24

glossac

"Γλώσσα" (greek pseudo-language) compiler
ooc
1
star
25

simpleplan

Simple project management software (aiming for CPM and Gantt charts with a simple GUI first)
C++
1
star
26

cpp_ml

C++20 machine learning library with no external dependencies (nanorange used temporarily for C++20 ranges)
C++
1
star
27

sonofaj

Son Of A J...!
ooc
1
star
28

auto-click

Multitasking auto clicker written in ooc (with a bit of C, I was too bored to bind xlib for ooc :P) that allows you to continue using your mouse normally
ooc
1
star