https://github.com/shovon/grammar-infer
Infer syntactic context-free grammar of an application's input
https://github.com/shovon/grammar-infer
context-free-grammar grammar llvm
Last synced: 2 months ago
JSON representation
Infer syntactic context-free grammar of an application's input
- Host: GitHub
- URL: https://github.com/shovon/grammar-infer
- Owner: shovon
- License: mit
- Created: 2017-07-24T17:31:56.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-27T00:41:19.000Z (almost 9 years ago)
- Last Synced: 2025-10-11T19:40:36.988Z (9 months ago)
- Topics: context-free-grammar, grammar, llvm
- Language: C++
- Homepage:
- Size: 309 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Syntactic grammar inference
[Read the paper](https://github.com/shovon/grammar-infer/blob/master/paper.pdf).
## Usage
**Note**: only tested (and most likely only works on) LLVM 3.9.x.
```
# Profiling
clang -g -c -emit-llvm $SOURCE_FILE.c -o $OUTPUT.bc
$ABSOLUTE_PATH_TO_GRAMMER_INFER_BUILD $OUTPUT.bc -o $BINARY
# Execute the profiled binary
`realpath $BINARY` # plus some commands for your program to analyze
# The trace of the profiled binary should now be in `trace.txt`
# Analyzing trace
$ABSOLUTE_PATH_TO_TRACE_ANALYZER -t $PATH_TO/trace.txt -c $CSV.csv \
-g $GRAMMAR.txt
```
## Building
```shell
# Profiler
mkdir grammar_infer_build
cd grammar_infer_build
cmake -DLLVM_DIR=/lib/cmake/llvm \
/grammar-infer/grammar-infer
make
# Trace analyzer
mkdir trace_build
cd trace_build
cmake /trace-analyzer
make
```