diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2020-09-11 01:54:26 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2020-09-11 01:54:26 -0700 |
| commit | f64467af21efab70b8cfab46f3f7f9d36c5b6e5f (patch) | |
| tree | 9ecb841dc536a14a9bb418f8886b94632e14f541 | |
| parent | 2baadd9ba00a84b3daa5c7028e7129223fbd5b1d (diff) | |
Updated makefile, added manpage
| -rw-r--r-- | Makefile | 33 | ||||
| -rw-r--r-- | bpeg.1 | 60 | ||||
| -rw-r--r-- | bpeg.c | 2 |
3 files changed, 89 insertions, 6 deletions
@@ -1,23 +1,46 @@ +NAME=bpeg PREFIX=/usr/local CFLAGS=-std=c99 -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L CWARN=-Wall -Wpedantic -Wextra -Wno-unknown-pragmas -Wno-missing-field-initializers\ -Wno-padded -Wsign-conversion -Wno-missing-noreturn -Wno-cast-qual -Wtype-limits -LDFLAGS= G ?= O ?= -O3 CFILES=compiler.c grammar.c utils.c vm.c OBJFILES=$(CFILES:.c=.o) -all: bpeg +all: $(NAME) .c.o: cc -c $(CFLAGS) $(CWARN) $(G) $(O) -o $@ $< -bpeg: $(OBJFILES) bpeg.c +$(NAME): $(OBJFILES) $(NAME).c cc $(CFLAGS) $(CWARN) $(G) $(O) -o $@ $^ clean: - rm -f bpeg $(OBJFILES) + rm -f $(NAME) $(OBJFILES) -.PHONY: all clean +install: $(NAME) + @prefix="$(PREFIX)"; \ + if [ ! "$$prefix" ]; then \ + printf '\033[1mWhere do you want to install? (default: /usr/local) \033[0m'; \ + read prefix; \ + fi; \ + [ ! "$$prefix" ] && prefix="/usr/local"; \ + mkdir -pv -m 755 "$$prefix/share/man/man1" "$$prefix/bin" \ + && cp -v $(NAME).1 "$$prefix/share/man/man1/" \ + && rm -f "$$prefix/bin/$(NAME)" \ + && cp -v $(NAME) "$$prefix/bin/" + +uninstall: + @prefix="$(PREFIX)"; \ + if [ ! "$$prefix" ]; then \ + printf '\033[1mWhere do you want to uninstall from? (default: /usr/local) \033[0m'; \ + read prefix; \ + fi; \ + [ ! "$$prefix" ] && prefix="/usr/local"; \ + echo "Deleting..."; \ + rm -rvf "$$prefix/bin/$(NAME)" "$$prefix/share/man/man1/$(NAME).1" ; \ + printf "\033[1mIf you created any config files in ~/.config/$(NAME), you may want to delete them manually.\033[0m\n" + +.PHONY: all, clean, install, uninstall @@ -0,0 +1,60 @@ +.\" Manpage for bpeg. +.\" Contact bruce@bruce-hill.com to correct errors or typos. +.TH man 1 "Sep 12, 2020" "0.1" "bpeg manual page" +.SH NAME +bpeg \- Bruce's Parsing Expression Grammar tool +.SH SYNOPSIS +.B bpeg +[\fI-h\fR|\fI--help\fR] +[\fI-v\fR|\fI--verbose\fR] +[\fI-d\fR|\fI--define\fR \fI<name>\fR=\fI<pattern>\fR] +[\fI-r\fR|\fI--replace\fR \fI<replacement>\fR] +[\fI-g\fR|\fI--grammar\fR \fI<grammar file>\fR] +\fI<pattern\fR +[[--] \fI<input file>\fR] +.SH DESCRIPTION +\fBbpeg\fR is a tool that matches parsing expression grammars using a custom syntax. +.SH OPTIONS +.B \--verbose +Print debugging information. + +.B \--define <name>=<pattern> +Define a grammar rule. + +.B \--replace <replacement> +Replace all occurrences of the main pattern with the given string. + +.B \--grammar <grammar file> +Load the grammar from the given file. + +.B \--help +Print the usage and exit. + +.B <pattern> +The main pattern for bpeg to match. By default, this pattern +is in "string literal" mode (i.e. a backslash is requres for +non-literal patterns). The default mode is to find \fBall\fR +occurrences of the pattern and highlight them. + +.B <input file> +The input file to search (default: stdin). + +.SH EXAMPLES +.TP +.B +ls | bpeg foo +Find files containing the string "foo" + +.TP +.B +ls | bpeg '.c\\$' -r '.h' +Find files ending with ".c" and replace the extension with ".h" + +.TP +.B +bpeg -g grammar.bpeg '\\myThing' my_file.txt +Find ocurrences of the grammar rule "myThing" in the file \fBmy_file.txt\fR +using the grammar rules defined in \fBgrammar.bpeg\fR + +.SH AUTHOR +Bruce Hill (bruce@bruce-hill.com) @@ -48,7 +48,7 @@ static const char *usage = ( "Flags:\n" " -h --help\t print the usage and quit\n" " -v --verbose\t print verbose debugging info\n" - " -s --slow\t run in slow mode for debugging\n" + " -d --define <name>=<def> Define a grammar rule\n" " -r --replace <replacement> replace the input pattern with the given replacement\n" " -g --grammar <grammar file> use the specified file as a grammar\n"); |
