Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 30 additions & 10 deletions .github/workflows/build-deb.yml → .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
name: Build libmicrohammer .deb
name: Pipeline

on:
pull_request:
workflow_dispatch:

permissions:
contents: write

jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format

- name: Check formatting
run: |
find src examples -name '*.c' -o -name '*.h' | xargs clang-format --dry-run --Werror

scons-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y scons gcc libglib2.0-dev pkg-config

- name: Run tests
run: scons test

build-deb:
runs-on: ubuntu-latest

needs: [clang-format, scons-test]
steps:
- uses: actions/checkout@v4

Expand All @@ -30,14 +58,6 @@ jobs:
mv $DEB_FILE $NEW_NAME
echo "deb_file=$NEW_NAME" >> $GITHUB_OUTPUT

- name: Create tag
id: tag
run: |
VERSION=$(cat VERSION)
TAG="v$VERSION"
git tag $TAG
echo "tag=$TAG" >> $GITHUB_OUTPUT

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
Expand Down
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml

This file was deleted.

9 changes: 2 additions & 7 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Tested on Ubuntu 22.04 and 24.04 (VM and WSL).

## Contributor Setup

### Formatting and pre-commit
### Formatting

Install formatting tools:

```bash
sudo apt install -y clang-format pre-commit
sudo apt install -y clang-format
```

Use `clang-format` to keep C code consistent.
Expand All @@ -26,11 +26,6 @@ clang-format -i **/*.c **/*.h
clang-format -i path/to/file.c
```

Install the pre-commit hooks defined in `.pre-commit-config.yaml` to run formatting automatically:
```bash
pre-commit install
```

### Version management

The repository centralizes the semantic version in the `VERSION` file. Update that file to bump the project version. All downstream artifacts read from it:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.1.1
11 changes: 11 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
libmicrohammer (1.1.1-1) unstable; urgency=medium

* Add scons uninstall target to remove installed libhammer files
* Remove version suffix from installed .so files
* Add variant=microhammer to pkg-config metadata
* Document uninstall and version/variant query in README
* Fix crashing scons test compilation from pruned backends
* Improve h_in and h_not_in documentation in hammer.h

-- Mahmoud Elbasiouny <melbasiouny@riversideresearch.org> Tue, 03 Mar 2026 12:00:00 -0500

libmicrohammer (1.1.0-1) unstable; urgency=medium

* Testing infrastructure overhaul
Expand Down
2 changes: 1 addition & 1 deletion src/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <stdlib.h>
#include <string.h>

static const char *HParserBackendNames[] = {"Packrat", "Regular", "LL(k)", "LALR", "GLR"};
static const char *HParserBackendNames[] = {"Invalid", "Packrat"};

/*
Usage:
Expand Down
28 changes: 17 additions & 11 deletions src/hammer.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,7 @@ HParseResult *h_parse__m(HAllocator *mm__, const HParser *parser, const uint8_t
size_t length);

/**
* @brief Initialize a parser for iteratively consuming an input stream in chunks. This is only
* supported by some backends.
* @brief Initialize a parser for iteratively consuming an input stream in chunks.
*
* @param parser Parser to use
* @return Result is NULL if not supported by the backend.
Expand Down Expand Up @@ -517,7 +516,7 @@ HParser *h_bits(size_t len, _Bool sign);
HParser *h_bits__m(HAllocator *mm__, size_t len, _Bool sign);

/**
* @brief Returns a parser that parses the specified number of octets. The input does not have to be
* @brief Returns a parser that parses the specified number of bytes. The input does not have to be
* aligned to a byte boundary.
*
* @param len Number of bytes
Expand Down Expand Up @@ -657,19 +656,27 @@ HParser *h_action(const HParser *p, const HAction a, void *user_data);
HParser *h_action__m(HAllocator *mm__, const HParser *p, const HAction a, void *user_data);

/**
* @brief Parse a single character in the given charset
* @param charset Character set
* @param length Charset length
* @brief Parse a single byte that is in the given charset. Always attempts to
* consume exactly one byte from the input; advances the cursor by one byte on
* success. Fails (and does not advance the cursor) if the byte is not in the
* charset.
* @param charset Array of accepted byte values
* @param length Number of bytes in charset
* @return Result token type: TT_UINT
* @note Consumes 1 byte (8 bits) from the input stream on success
*/
HParser *h_in(const uint8_t *charset, size_t length);
HParser *h_in__m(HAllocator *mm__, const uint8_t *charset, size_t length);

/**
* @brief Parse a single character *NOT* in the given charset
* @param charset Character set to exclude
* @param length Charset length
* @brief Parse a single byte that is *NOT* in the given charset. Always
* attempts to consume exactly one byte from the input; advances the cursor by
* one byte on success. Fails (and does not advance the cursor) if the byte is
* in the charset.
* @param charset Array of excluded byte values
* @param length Number of bytes in charset
* @return Result token type: TT_UINT
* @note Consumes 1 byte (8 bits) from the input stream on success
*/
HParser *h_not_in(const uint8_t *charset, size_t length);
HParser *h_not_in__m(HAllocator *mm__, const uint8_t *charset, size_t length);
Expand Down Expand Up @@ -878,8 +885,7 @@ HParser *h_epsilon_p__m(HAllocator *mm__);
/**
* @brief This parser applies its first argument to read an unsigned integer value, then applies its
* second argument that many times. length should parse an unsigned integer value; this is checked
* at runtime. Specifically, the token_type of the returned token must be TT_UINT. In future we
* might relax this to include TT_USER but don't count on it.
* at runtime. Specifically, the token_type of the returned token must be TT_UINT.
*
* @param length Parser to read length
* @param value Parser to apply length times
Expand Down
5 changes: 4 additions & 1 deletion src/t_bitreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
#include <stdint.h>

#define MK_INPUT_STREAM(buf, len, endianness_) \
{.input = (uint8_t *)buf, .length = len, .index = 0, .bit_offset = 0, .endianness = endianness_}
{ \
.input = (uint8_t *)buf, .length = len, .index = 0, .bit_offset = 0, \
.endianness = endianness_ \
}

static void test_bitreader_ints(void) {
HInputStream is =
Expand Down
Loading