lenawanel c791a23456
reduce memory usage of the construct_automata script (#1481)
* remove unneeded loop in `SpliceMutator::mutate`

previously we searched for the first and the last difference
between exactly the same 2 inputs 3 times in a loop

* remove unused struct fields

* avoid allocating strings for `Transition`s

* avoid allocating `String`s for `Stack`s

* avoid allocating Strings for `Element`s

* apply some clippy lints

* some more clippy lints

* simplify regex

* remove superflous if condition

* remove the Rc<_> in `Element`

* small cleanups and regex fix

* avoid allocating a vector for the culled pda

* bug fix

* bug fix

* reintroduce the Rc, but make it use the *one* alloced VecDeque this time

* slim down dependencies

* use Box<[&str]> for storted state stacks

this saves us a whopping 8 bytes ;), since we don't have to store
the capacity

* revert the changes from 9ffa715c10089f157e4e20563143a2df890c8ffe

fixes a bug

* apply clippy lint

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-09-05 16:29:24 +02:00
..
2022-05-27 01:05:03 +02:00

Gramatron preprocessing scripts

In this folder live the scripts to convert a grammar (some examples in the grammars/ subfolder) into a serialized Automaton.

You need as first to convert the grammar to the GNF form using the gnf_converter.py Python script.

Then use the output as input of the construct_automata crate.

Here an example using the Ruby grammar:

./gnf_converter.py --gf grammars/ruby_grammar.json --out ruby_gnf.json --start PROGRAM
cd construct_automata
RUSTFLAGS="-C target-cpu=native" cargo run --release -- --gf ../ruby_gnf.json --out ../ruby_automaton.postcard

You can add the --limit flag to limit the stack size, as described in the Gramatron paper.