Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huge numbers for dice #472

Merged
merged 150 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 135 commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
b91775b
Create test_huge_number.py
ianfhunter Mar 23, 2024
1c40395
style: format code with Autopep8, Black, Go fmt, Gofumpt, isort and Yapf
deepsource-autofix[bot] Mar 23, 2024
bf8f6a3
Update test_huge_number.py
ianfhunter Mar 23, 2024
00f5d52
style: format code with Autopep8, Black, Go fmt, Gofumpt, isort and Yapf
deepsource-autofix[bot] Mar 23, 2024
1e98e80
Update test_huge_number.py
ianfhunter Mar 23, 2024
6179d56
Update safe_functions.c
ianfhunter Mar 23, 2024
353001e
Update safe_functions.h
ianfhunter Mar 23, 2024
f2e7ee9
Update dice.lex
ianfhunter Mar 23, 2024
bdc0e46
Update vec.h
ianfhunter Mar 23, 2024
c6d3868
Update roll_parameters.h
ianfhunter Mar 23, 2024
2b4f24f
Update dice.yacc
ianfhunter Mar 23, 2024
ca7b44d
Update vec.h
ianfhunter Mar 23, 2024
3320da3
Update vector_functions.h
ianfhunter Mar 23, 2024
c82c3f9
Update vector_functions.c
ianfhunter Mar 24, 2024
7cb3198
Update string_functions.h
ianfhunter Mar 24, 2024
560ff7e
Update vector_functions.h
ianfhunter Mar 24, 2024
2a9daf2
Update string_functions.c
ianfhunter Mar 24, 2024
2f22806
Update vector_functions.c
ianfhunter Mar 24, 2024
846b89a
Update safe_functions.h
ianfhunter Mar 24, 2024
d667b76
Update safe_functions.c
ianfhunter Mar 24, 2024
6fcacc5
Update mocking.h
ianfhunter Mar 24, 2024
f4248c4
Update mocking.c
ianfhunter Mar 24, 2024
5c9ab89
Update array_functions.h
ianfhunter Mar 24, 2024
1543210
Update array_functions.c
ianfhunter Mar 24, 2024
d569924
Update randomness.c
ianfhunter Mar 24, 2024
7d365c2
Update randomness.h
ianfhunter Mar 24, 2024
38ceadd
Update dice_frontend.c
ianfhunter Mar 24, 2024
dfedd32
Update dice_core.h
ianfhunter Mar 24, 2024
fb730e7
Update dice_core.c
ianfhunter Mar 24, 2024
4e71e68
Merge branch 'main' into huge_numbers
ianfhunter Mar 24, 2024
14c6cb7
Update vec.h
ianfhunter Mar 24, 2024
2e329e1
Update dice_frontend.c
ianfhunter Mar 24, 2024
82f2d3e
Update vec.h
ianfhunter Mar 24, 2024
9cefc1c
Update vec.h
ianfhunter Mar 24, 2024
80920e7
Update dice_frontend.c
ianfhunter Mar 24, 2024
a3d46d9
Update dice_frontend.c
ianfhunter Mar 24, 2024
b71146f
Update dice.yacc
ianfhunter Mar 24, 2024
e83aa5b
Update dice.lex
ianfhunter Mar 24, 2024
794210e
Update shared_header.h
ianfhunter Mar 24, 2024
49e5f4c
Update vector_functions.h
ianfhunter Mar 24, 2024
70fa9e2
Update vector_functions.c
ianfhunter Mar 24, 2024
17ad200
Update safe_functions.c
ianfhunter Mar 24, 2024
601ea7c
Update array_functions.h
ianfhunter Mar 24, 2024
6c00d73
Update array_functions.c
ianfhunter Mar 24, 2024
3bcdf28
Update dice_frontend.h
ianfhunter Mar 24, 2024
7601f1c
Update dice_frontend.c
ianfhunter Mar 24, 2024
45c027f
Update roll_parameters.h
ianfhunter Mar 24, 2024
ce45db7
Update vector_functions.c
ianfhunter Mar 24, 2024
2d9c9a9
Update vector_functions.c
ianfhunter Mar 24, 2024
87a21ca
Update vector_functions.c
ianfhunter Mar 24, 2024
e726d74
Update dice.yacc
ianfhunter Mar 25, 2024
58fcbd2
Update macros.c
ianfhunter Mar 25, 2024
e810e96
Update conditionals.c
ianfhunter Mar 25, 2024
d463483
Update conditionals.h
ianfhunter Mar 25, 2024
1635c70
Update vector_functions.c
ianfhunter Mar 25, 2024
8aaf35f
Update vector_functions.h
ianfhunter Mar 25, 2024
aa87749
Update dice.yacc
ianfhunter Mar 25, 2024
1958d74
Update conditionals.c
ianfhunter Mar 25, 2024
f9b934c
Update vector_functions.c
ianfhunter Mar 25, 2024
76effdf
Update conditionals.c
ianfhunter Mar 25, 2024
b65d640
Update conditionals.h
ianfhunter Mar 25, 2024
c276b9a
replace pcg-basic with pcg-c
Mar 25, 2024
3b39e65
Update Makefile
ianfhunter Mar 25, 2024
e2d7054
Update test_OS.yml
ianfhunter Mar 25, 2024
1eab5cf
Update test_core.yml
ianfhunter Mar 25, 2024
22556f8
Update test_language_bindings.yml
ianfhunter Mar 25, 2024
5c2d32b
Update test_packages.yml
ianfhunter Mar 25, 2024
42011b8
Update test_OS.yml
ianfhunter Mar 25, 2024
1d2cd50
Update randomness.c
ianfhunter Mar 25, 2024
f3b642e
Update Makefile
ianfhunter Mar 25, 2024
c417c92
Update dice.yacc
ianfhunter Mar 25, 2024
1c7254b
Update Makefile
ianfhunter Mar 25, 2024
75c5c70
Update Makefile
ianfhunter Mar 25, 2024
2659ae5
Update Makefile
ianfhunter Mar 25, 2024
05dcfc7
Update Makefile
ianfhunter Mar 25, 2024
ba63718
Update Makefile
ianfhunter Mar 25, 2024
3485c97
Update Makefile
ianfhunter Mar 25, 2024
c579db2
Update Makefile
ianfhunter Mar 25, 2024
c39dfc8
Update Makefile
ianfhunter Mar 25, 2024
6ddcd28
Update Makefile
ianfhunter Mar 25, 2024
7060eba
Update Makefile
ianfhunter Mar 25, 2024
2c98685
Update Makefile
ianfhunter Mar 25, 2024
014af01
Update Makefile
ianfhunter Mar 25, 2024
5ab31df
Update Makefile
ianfhunter Mar 25, 2024
e7d4d36
Update Makefile
ianfhunter Mar 25, 2024
c3306b8
Update Makefile
ianfhunter Mar 25, 2024
a31a546
Update randomness.c
ianfhunter Mar 25, 2024
24118d6
Update Makefile
ianfhunter Mar 25, 2024
d27ccea
Update safe_functions.h
ianfhunter Mar 25, 2024
68bd1d7
Update dice.yacc
ianfhunter Mar 25, 2024
a4d2197
Update safe_functions.c
ianfhunter Mar 26, 2024
eb11609
Update safe_functions.h
ianfhunter Mar 26, 2024
2fe643b
Update safe_functions.c
ianfhunter Mar 26, 2024
7cffe60
Update dice.yacc
ianfhunter Mar 26, 2024
f8974d1
Update target.mk
ianfhunter Mar 26, 2024
5c972fd
Update target.mk
ianfhunter Mar 26, 2024
e16f062
Update Makefile
ianfhunter Mar 26, 2024
8d160b9
Update target.mk
ianfhunter Mar 26, 2024
6a3e36c
Update target.mk
ianfhunter Mar 26, 2024
b85a775
Update test_language_bindings.yml
ianfhunter Mar 26, 2024
a519712
Update randomness.c
ianfhunter Mar 26, 2024
d40724f
Update safe_functions.c
ianfhunter Mar 26, 2024
1ae909f
Update safe_functions.h
ianfhunter Mar 26, 2024
d4b1ddd
Update lint_codeQL.yml
ianfhunter Mar 26, 2024
a0b90ca
Update target.mk
ianfhunter Mar 26, 2024
b91594c
Update target.mk
ianfhunter Mar 26, 2024
6d78cf6
Update randomness.c
ianfhunter Mar 26, 2024
57e84b8
Update target.mk
ianfhunter Mar 26, 2024
e06daac
Update test_OS.yml
ianfhunter Mar 26, 2024
51cf5c4
Update target.mk
ianfhunter Mar 26, 2024
22c93b9
Update test_huge_number.py
ianfhunter Mar 26, 2024
9d7fdd2
Update target.mk
ianfhunter Mar 27, 2024
cbe50fb
Update target.mk
ianfhunter Mar 27, 2024
c241edd
Update target.mk
ianfhunter Mar 27, 2024
a52352c
Update target.mk
ianfhunter Mar 27, 2024
cd16b47
Update target.mk
ianfhunter Mar 27, 2024
1f20caf
Update test_troika.py
ianfhunter Mar 27, 2024
6de4fcd
Update target.mk
ianfhunter Mar 27, 2024
10e36fa
remove union to another PR
ianfhunter Mar 28, 2024
28a87e4
Update dice.yacc
ianfhunter Mar 28, 2024
9f82dc7
Merge branch 'main' into huge_numbers
ianfhunter Mar 28, 2024
00d17d8
Update conditionals.c
ianfhunter Mar 28, 2024
4553112
Update dice.yacc
ianfhunter Mar 28, 2024
df4f8ae
Update dice.yacc
ianfhunter Mar 28, 2024
1ac8a02
Update dice.yacc
ianfhunter Mar 29, 2024
00ed09e
Update dice_core.c
ianfhunter Mar 29, 2024
3e941e5
Update dice.yacc
ianfhunter Mar 29, 2024
7365bee
Update __init__.py
ianfhunter Mar 29, 2024
c556243
style: format code with Autopep8, Black, Go fmt, Gofumpt, isort and Yapf
deepsource-autofix[bot] Mar 29, 2024
346fe6d
Update __init__.py
ianfhunter Mar 29, 2024
8750e53
style: format code with Autopep8, Black, Go fmt, Gofumpt, isort and Yapf
deepsource-autofix[bot] Mar 29, 2024
1dfac7c
Update test_huge_number.py
ianfhunter Mar 29, 2024
c5652e6
Update test_huge_number.py
ianfhunter Mar 29, 2024
0af9d2a
Update dice.yacc
ianfhunter Mar 29, 2024
f32a672
Update src/grammar/rolls/dice_core.c
ianfhunter Mar 29, 2024
47377fa
Update src/grammar/rolls/dice_core.c
ianfhunter Mar 29, 2024
85e22cf
Update test_huge_number.py
ianfhunter Mar 29, 2024
b74e406
style: format code with Autopep8, Black, Go fmt, Gofumpt, isort and Yapf
deepsource-autofix[bot] Mar 29, 2024
ae1a203
Update test_huge_number.py
ianfhunter Mar 29, 2024
598b67c
Update __init__.py
ianfhunter Mar 29, 2024
5374fdf
style: format code with Autopep8, Black, Go fmt, Gofumpt, isort and Yapf
deepsource-autofix[bot] Mar 29, 2024
55d587c
Update randomness.c
ianfhunter Mar 29, 2024
2087d46
Update randomness.c
ianfhunter Mar 29, 2024
c9a0928
Update randomness.h
ianfhunter Mar 29, 2024
21f325b
Update randomness.c
ianfhunter Mar 29, 2024
3059908
Update randomness.c
ianfhunter Mar 29, 2024
dd09dd5
Update randomness.h
ianfhunter Mar 29, 2024
75de539
Update randomness.c
ianfhunter Mar 29, 2024
9e5addb
Update randomness.h
ianfhunter Mar 29, 2024
e086cf1
Update test_huge_number.py
ianfhunter Mar 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/lint_codeQL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test_OS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
with:
python-version: '3.x'
- uses: actions/checkout@v3
with:
submodules: true
- name: Install dependencies
run: |
python -m pip install -r reqs/requirements.txt
Expand Down Expand Up @@ -49,6 +51,8 @@ jobs:
python3.10-venv

- uses: actions/checkout@v3
with:
submodules: true
- name: test
shell: wsl-bash {0}
run: |
Expand All @@ -59,6 +63,8 @@ jobs:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build
run: make all
- name: Test
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v3
with:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/test_language_bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: make
run: |
make cpp
Expand All @@ -49,6 +51,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: prereqs
# https://linuxize.com/post/how-to-install-mono-on-ubuntu-20-04/
run: |
Expand All @@ -68,6 +72,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: go install
run: sudo apt install golang-go
- name: make go
Expand All @@ -80,6 +86,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: dep install
run: |
sudo apt update
Expand All @@ -98,6 +106,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: java dependencies
run: |
sudo apt-get update
Expand All @@ -113,6 +123,8 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
Expand Down Expand Up @@ -149,6 +161,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: julia install
run: |
wget https://julialang-s3.julialang.org/bin/linux/x64/1.8/julia-1.8.2-linux-x86_64.tar.gz
Expand All @@ -158,12 +172,15 @@ jobs:
- name: make julia
run: |
PATH="$PATH:$PWD/julia-1.8.2/bin" make julia

test_lua:
name: "Test: Lua"
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: lua install
run: |
sudo apt install luajit
Expand All @@ -176,6 +193,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: perl install
run: |
sudo apt install perl
Expand All @@ -190,6 +209,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: r-lib/actions/setup-r@v2
- name: make r
run: make r
Expand All @@ -199,6 +220,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: ruby install
run: |
sudo apt install ruby-full
Expand All @@ -210,6 +233,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -226,6 +251,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Setup Rust
run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v3
with:
Expand Down Expand Up @@ -50,6 +52,8 @@ jobs:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build
run: make all
- name: Test
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/grammar/external/pcg-c"]
path = src/grammar/external/pcg-c
url = https://github.com/imneme/pcg-c.git
34 changes: 21 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
CODEDIRS=./src/grammar ./src/grammar/rolls ./src/grammar/util ./src/grammar/operations ./src/grammar/external
INCDIRS=./src/grammar
INCDIRS=./src/grammar ./src/grammar/external/pcg-c/include

CC=cc
PCG_SRC=./src/grammar/external/pcg-c/src

$(info CC is $(CC))

ifeq ($(CC),g++)
STANDARD= -std=c++11
else ifeq ($(CC),clang++)
STANDARD= -std=c++11
else ifeq ($(filter $(CC),gcc cc),gcc cc)
STANDARD= -std=c99
else
STANDARD= -std=c99
endif
Expand All @@ -25,8 +29,8 @@ ifneq ($(shell uname -s), Darwin)
OPT := $(OPT) -Wl,-z,nodlopen -Wl,-z,noexecstack \
-Wl,-z,relro
endif
# -ffast-math # Problematic for Python

# -ffast-math # Problematic for Python

# YACC/LEX fails for the following, so disabled:
# -Wswitch-default -Wstrict-overflow=5
Expand Down Expand Up @@ -91,16 +95,16 @@ ifeq ($(LEX_FALLBACK), 1)
LEXER:=lex
else
#$(shell echo USING FLEX)
LEXER:=flex -f -Ca -Ce -Cr
LEXER:=flex -f -Ca -Ce -Cr
endif

# add flags and the include paths
DEFS=-DUSE_SECURE_RANDOM=${USE_SECURE_RANDOM} -DJUST_YACC=${YACC_FALLBACK} -DUSE_CLT=${USE_CLT}

CFLAGS=$(foreach D,$(INCDIRS),-I$(D)) $(OPT) $(DEFS)
CFLAGS=$(foreach D,$(INCDIRS),-I$(D)) $(OPT) $(DEFS)

# add flags to build for shared library and add include paths
SHAREDCFLAGS=-fPIC -c $(foreach D,$(INCDIRS),-I$(D)) $(ARC4RANDOM) $(DEFS)
SHAREDCFLAGS=-fPIC -c $(foreach D,$(INCDIRS),-I$(D)) $(ARC4RANDOM) $(DEFS)

# generate list of c files and remove y.tab.c from src/grammar directory
CFILES=$(foreach D,$(CODEDIRS),$(wildcard $(D)/*.c)) build/lex.yy.c build/y.tab.c
Expand All @@ -127,7 +131,7 @@ install: all
yacc:
mkdir -p build
$(foreach BD,$(CFILE_SUBDIRS),mkdir -p build/$(BD))
$(PARSER) -d src/grammar/dice.yacc $(PARSER_DEBUG)
$(PARSER) -d src/grammar/dice.yacc $(PARSER_DEBUG)
mv y.tab.c build/y.tab.c
mv y.tab.h build/y.tab.h
mv y.output build/y.output | true # Only present with verbose
Expand All @@ -136,29 +140,33 @@ lex:
mv lex.yy.c build/lex.yy.c

# Executable
compile:
compile: pcg
# FLEX creates warning when run with -f
# MacOS creates warnings for signs.
$(CC) $(CFLAGS) $(CFILES) $(ARC4RANDOM) \
-Wno-error=implicit-function-declaration \
-Wno-sign-conversion -Wno-sign-compare -lm \
-Wno-implicit-int-conversion
-Wno-implicit-int-conversion -lpcg_random -L$(PCG_SRC) \
-Wno-undef -Wno-conversion # For pcg-c

# PCG Submodule
pcg:
make -C src/grammar/external/pcg-c all

# Shared Lib
shared: $(OBJECTS)
$(CC) -shared -o build/dice.so $^ $(ARC4RANDOM) -lm
$(CC) -shared -o build/dice.so $^ $(ARC4RANDOM) -lm -lpcg_random -L$(PCG_SRC)
cp build/dice.so build/libdice.so
# Linux
mv ./a.out build/dice | true
# Windows
mv ./a.exe build/dice | true

# hardcode for lex and yacc files
build/y.tab.o:
build/y.tab.o:
$(CC) $(SHAREDCFLAGS) -c build/y.tab.c -o $@
build/lex.yy.o:
$(CC) $(SHAREDCFLAGS) -c build/lex.yy.c -o $@
$(CC) $(SHAREDCFLAGS) -c build/lex.yy.c -o $@

# Wildcard everything else
build/*/%.o:src/grammar/*/%.c
Expand Down
2 changes: 1 addition & 1 deletion src/R/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

r: clean yacc lex compile $(OBJECTS)
mkdir -p build/r/
$(CC) -shared -o build/r/dice.so $(OBJECTS) $(ARC4RANDOM) -lR
$(CC) -shared -o build/r/dice.so $(OBJECTS) $(ARC4RANDOM) -lR -lpcg_random -L$(PCG_SRC)
Rscript src/R/main.r
6 changes: 3 additions & 3 deletions src/grammar/constructs/roll_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#include "constructs/dice_enums.h"

typedef struct roll_params {
unsigned int number_of_dice;
unsigned int die_sides;
unsigned long long number_of_dice;
unsigned long long die_sides;
EXPLOSION_TYPE explode;
char** symbol_pool;
int start_value;
long long start_value;
DIE_TYPE dtype;
} roll_params;

Expand Down
6 changes: 4 additions & 2 deletions src/grammar/constructs/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

typedef struct vec {
DIE_TYPE dtype;

union { // Vectors can only contain one dice type
int* content;
long long* content;
char** symbols;
} storage;
unsigned int length;
unsigned long long length;

roll_params source;
bool has_source;
} vec;
Expand Down