Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
86e288d
Add repository to Cargo.toml
csnover Aug 31, 2025
872678d
Replace Rust strings with byte arrays
csnover Aug 31, 2025
5ad65ee
Implement inverted character class
csnover Aug 31, 2025
fcb818b
Run rustfmt
csnover Aug 31, 2025
c9d3639
Enable and fix most pedantic clippy lints
csnover Aug 31, 2025
df708e4
Update to edition 2024
csnover Aug 31, 2025
9aad229
Remove unnecessary allocations and wrappers
csnover Aug 31, 2025
65e9b35
Use a callback function for Table
csnover Aug 31, 2025
d6c43d2
Replace tuples with named types where appropriate
csnover Sep 1, 2025
69a0420
Implement position capture groups
csnover Sep 1, 2025
0e79931
Fix rustdoc error
csnover Sep 1, 2025
c6b333d
Add CI workflow
csnover Sep 1, 2025
4bc831e
Use structured errors
csnover Sep 1, 2025
c510ab1
Clean up and document the public API
csnover Sep 1, 2025
3741ff7
Bump version number
csnover Sep 1, 2025
48ecd62
Expose a stateful GSub implementation
csnover Sep 2, 2025
75ea899
Add missing Eq marker traits
csnover Sep 2, 2025
06ab9b7
Allow optional replacement values for gsub callbacks
csnover Sep 2, 2025
398287e
Remove confusing type aliases with the same name
csnover Sep 3, 2025
d6dd437
Fix wrong function signature of `gmatch`
csnover Sep 3, 2025
153b623
Allow mutable replacement functions for `gsub`
csnover Sep 3, 2025
9a2a0f7
Simplify AST splitting
csnover Sep 3, 2025
f66005f
Reduce module sprawl
csnover Sep 3, 2025
728138b
Add test cases from Lua test suite
csnover Sep 3, 2025
a12420a
Send correct values to gsub callbacks
csnover Sep 3, 2025
bdd4dca
Fix class token included in set as literal
csnover Sep 3, 2025
8a7c52f
Fix incorrect parsing of `[]]`
csnover Sep 3, 2025
816fd58
Fix bad parsing of character sets
csnover Sep 3, 2025
93ce830
Support undocumented character class '%z'
csnover Sep 3, 2025
fd530c6
Change escapable magic byte list to conform to Lua documentation
csnover Sep 3, 2025
6bbb52e
Fix incorrect handling of anchors in middle of pattern
csnover Sep 3, 2025
8d788af
Fix string capture group '%0'
csnover Sep 3, 2025
f9460d2
Implement capture reference matching
csnover Sep 3, 2025
ec7d0de
Simplify previous byte lookup function
csnover Sep 3, 2025
8f1d21c
Support implicit capture '%1' in capture strings
csnover Sep 3, 2025
6cac198
Fix infinite loop in gsub when matching non-advancing patterns
csnover Sep 3, 2025
635679c
Fix gmatch not always iterating to the end
csnover Sep 4, 2025
8a93823
Fix matching after the end of a string
csnover Sep 4, 2025
6527ce4
Allow crazy character class set ranges
csnover Sep 4, 2025
dca82de
Follow Lua 5.3.3 semantics for empty matches
csnover Sep 4, 2025
b024f80
Fix frontier matches at start and end of line
csnover Sep 4, 2025
b07e00d
Fix broken qualifier implementation
csnover Sep 4, 2025
8a1ee2c
Remove unused `Token::Percent`
csnover Sep 4, 2025
4d907d3
Rip and replace the pattern matching engine
csnover Sep 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Rust CI

on:
pull_request:
push:
branches:
- main
- '[0-9]+.[0-9]+'

env:
CARGO_TERM_COLOR: always

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Use cache
uses: Swatinem/rust-cache@v2
with:
shared-key: stable
save-if: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy, rustfmt, llvm-tools-preview
- name: Check formatting
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy --all-targets -- -D warnings
- name: Build documentation
run: cargo rustdoc -- -D warnings

test:
name: Test on Rust ${{ matrix.rust.name }}
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- name: stable
components: clippy, rustfmt, llvm-tools-preview
- name: nightly
- name: "1.88" # rust-version, msrv
steps:
- name: Check out code
uses: actions/checkout@v4
# Using env.HOME or $HOME does not work in the rust-cache workflow step,
# so just build the path this way.
- name: Find toolchain path
id: toolchain_path
run: echo "path=$HOME/.rustup/toolchains/${{ matrix.rust.name }}-x86_64-unknown-linux-gnu" >> $GITHUB_OUTPUT
# Stable toolchain for Rust is already built into the runner image so
# only other versions need caching to avoid wasting time and bandwidth
# re-downloading them.
if: matrix.rust.name != 'stable'
- name: Use cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.rust.name }}
cache-on-failure: true
cache-directories: ${{ steps.toolchain_path.outputs.path }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust.name }}
components: ${{ matrix.rust.components }}
# Building is separated from testing just to more clearly differentiate in
# the CI whether the build failed or a test failed
- name: Build workspace
run: cargo build --lib --tests
- name: Run tests
run: cargo test

coverage:
name: Code coverage
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Use cache
uses: Swatinem/rust-cache@v2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy, rustfmt, llvm-tools-preview
- name: Install llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- name: Generate coverage data
run: cargo llvm-cov test --no-report
- name: Show coverage results
run: >
cargo llvm-cov report
--ignore-filename-regex 'benches|tests'
# https://github.com/actions/runner/issues/520
- name: Determine whether codecov.io secret is available
id: has_codecov
run: echo 'result=${{ secrets.CODECOV_TOKEN }}' >> $GITHUB_OUTPUT
- name: Generate coverage file
run: >
cargo llvm-cov report
--ignore-filename-regex 'benches|tests'
--lcov --output-path lcov.info
if: steps.has_codecov.outputs.result != 0
- name: Upload to codecov.io
uses: codecov/codecov-action@v5
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
if: steps.has_codecov.outputs.result != 0
60 changes: 59 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[package]
name = "lsonar"
version = "0.2.4"
edition = "2021"
version = "0.3.0"
edition = "2024"
authors = ["reloginn <nikita.malina23@gmail.com>"]
description = "Lua 5.3 pattern engine, fully compatible with the original Lua 5.3 engine"
license = "MIT"
repository = "https://github.com/reloginn/lsonar"
rust-version = "1.88"

[dependencies]
thiserror = "2.0.16"

[features]
default = ["1-based"]
Expand Down
4 changes: 0 additions & 4 deletions src/ast.rs

This file was deleted.

30 changes: 0 additions & 30 deletions src/ast/node.rs

This file was deleted.

7 changes: 0 additions & 7 deletions src/ast/quantifier.rs

This file was deleted.

135 changes: 0 additions & 135 deletions src/charset.rs

This file was deleted.

Loading