fixed name
This commit is contained in:
parent
fdd617fa2f
commit
540a278327
2 changed files with 29 additions and 29 deletions
46
README.md
46
README.md
|
|
@ -1,13 +1,13 @@
|
|||
|
||||
<!-- vim: set wrap: -->
|
||||
|
||||
# Pregrep (C edition)
|
||||
# Pegrep (C edition)
|
||||
|
||||
Pregrep is a portmanteau of "peg" and "grep". That is, this program fills a similar niche as grep (GNU's regular expression processor), but with "peg" parsing rather that typical regular expression processing (LR parser vs. DFA).
|
||||
Pegrep is a portmanteau of "peg" and "grep". That is, this program fills a similar niche as grep (GNU's regular expression processor), but with "peg" parsing rather that typical regular expression processing (LR parser vs. DFA).
|
||||
|
||||
This repository stores the C implementation of pregrep.
|
||||
This repository stores the C implementation of Pegrep.
|
||||
|
||||
With pregrep, users can search for text in files that follows a more complex pattern than one could articulate in grep. The standout feature of pregrep is that patterns can be *recursive*.
|
||||
With Pegrep, users can search for text in files that follows a more complex pattern than one could articulate in grep. The standout feature of Pegrep is that patterns can be *recursive*.
|
||||
|
||||
For instance:
|
||||
|
||||
|
|
@ -29,32 +29,32 @@ For instance:
|
|||
|
||||
### arithmetic:
|
||||
|
||||
- `$ pregrep -w ' ' -e 'N:[0-9]+,p:N|\(a\),m:p([*/]p)*,a:m([+-])+:a'`
|
||||
- `$ pregrep --whitespace ' ' -e 'N:[0-9]+,p:N|\(a\),m:p([*/]p)*,a:m([+-])+:a'`
|
||||
- `$ pregrep -e 'ws: *,p:[0-9]+ws|\(wsa\)ws,m:p([*/]wsp)*,a:m([+-]<ws>m)*+:a'`
|
||||
- `$ pregrep -e 'ws: *,p:[0-9]+<ws>|\(<ws><a>\)<ws>,m:<p>([*/]<ws><p>)*,a:<m>([+-]<ws><m>)*'`
|
||||
- `$ pegrep -w ' ' -e 'N:[0-9]+,p:N|\(a\),m:p([*/]p)*,a:m([+-])+:a'`
|
||||
- `$ pegrep --whitespace ' ' -e 'N:[0-9]+,p:N|\(a\),m:p([*/]p)*,a:m([+-])+:a'`
|
||||
- `$ pegrep -e 'ws: *,p:[0-9]+ws|\(wsa\)ws,m:p([*/]wsp)*,a:m([+-]<ws>m)*+:a'`
|
||||
- `$ pegrep -e 'ws: *,p:[0-9]+<ws>|\(<ws><a>\)<ws>,m:<p>([*/]<ws><p>)*,a:<m>([+-]<ws><m>)*'`
|
||||
|
||||
### (Simple) JSON:
|
||||
|
||||
- `$ pregrep -W 'N:[0-9]+,S:"[^"]*",l:\[(j(,j)*)?],k:S\:j,o:{(k(,k)*)?},j:N|S|l|o'`
|
||||
- `$ pregrep -W 'N:[0-9]+,S:\"[^"]*\",l:\[(j(\,j)*)?],k:S\:j,o:\{(k(\,k)*)?},j:N|S|l|o'`
|
||||
- `$ pregrep -W 'N:[0-9]+,S:"[^"]*",l:\[(j(,j)*)?],o:{(S\:j(,S\:j)*)?},j:N|S|l|o'`
|
||||
- `$ pregrep -W 'N:[0-9]+,S:"[^"]*",l:\[(<j>(,<j>)*)?],k:<S>\:<j>,o:{(<k>(,<k>)*)?},j:<N>|<S>|<l>|<o>'`
|
||||
- `$ pregrep -W 'N:[0-9]+,S:"[^"]*",l:\[<sv(<j>,\,)>],o:{<sv(<S>\:<j>,\,)>},j:<N>|<S>|<l>|<o>'`
|
||||
- `$ pegrep -W 'N:[0-9]+,S:"[^"]*",l:\[(j(,j)*)?],k:S\:j,o:{(k(,k)*)?},j:N|S|l|o'`
|
||||
- `$ pegrep -W 'N:[0-9]+,S:\"[^"]*\",l:\[(j(\,j)*)?],k:S\:j,o:\{(k(\,k)*)?},j:N|S|l|o'`
|
||||
- `$ pegrep -W 'N:[0-9]+,S:"[^"]*",l:\[(j(,j)*)?],o:{(S\:j(,S\:j)*)?},j:N|S|l|o'`
|
||||
- `$ pegrep -W 'N:[0-9]+,S:"[^"]*",l:\[(<j>(,<j>)*)?],k:<S>\:<j>,o:{(<k>(,<k>)*)?},j:<N>|<S>|<l>|<o>'`
|
||||
- `$ pegrep -W 'N:[0-9]+,S:"[^"]*",l:\[<sv(<j>,\,)>],o:{<sv(<S>\:<j>,\,)>},j:<N>|<S>|<l>|<o>'`
|
||||
|
||||
- `$ pregrep -W 'N:[0-9]+,S:"[^"]*",csv():(<1>(<2><1>)*)?,l:\[<csv(<j>)>],o:{<csv(<S>:<j>)>},j:<N>|<S>|<l>|<o>'`
|
||||
- `$ pegrep -W 'N:[0-9]+,S:"[^"]*",csv():(<1>(<2><1>)*)?,l:\[<csv(<j>)>],o:{<csv(<S>:<j>)>},j:<N>|<S>|<l>|<o>'`
|
||||
|
||||
### "csv" and "sv" are both defined in .pregrep.yaml
|
||||
- `$ pregrep -W 'N:[0-9]+,S:"[^"]*",l:\[<csv(<j>)>],o:{<csv(<S>:<j>)>},j:<N>|<S>|<l>|<o>'`
|
||||
- `$ pregrep -W 'N:[0-9]+,S:"[^"]*",l:\[<csv(<j>)>],o:{<csv(<S>:<j>)>},j:<N>|<S>|<l>|<o>' --replace "(j (N @a) (N @b)) -> (j @b @a))"`
|
||||
### "csv" and "sv" are both defined in .pegrep.yaml
|
||||
- `$ pegrep -W 'N:[0-9]+,S:"[^"]*",l:\[<csv(<j>)>],o:{<csv(<S>:<j>)>},j:<N>|<S>|<l>|<o>'`
|
||||
- `$ pegrep -W 'N:[0-9]+,S:"[^"]*",l:\[<csv(<j>)>],o:{<csv(<S>:<j>)>},j:<N>|<S>|<l>|<o>' --replace "(j (N @a) (N @b)) -> (j @b @a))"`
|
||||
|
||||
### cvs of numbers:
|
||||
- `$ pregrep -e '(<sv([^,\n]*,\,)>\n)*'`
|
||||
- `$ pregrep -e '(<csv([^,\n]*)>\n)*'`
|
||||
- `$ pregrep -W -e '(<csv([^,\n]*)>\n)*'`
|
||||
- `$ pregrep -e 'ws:[ \n]*,(<csv([^,\n]<ws>*<ws>)>\n<ws>)*'`
|
||||
- `$ pregrep -e 'ws:[ \n]*,C:[^,\n]*,(<csv(C)>\n<ws>)*'`
|
||||
- `$ pregrep -W -e 'C:[^,\n]*,(<csv(<C>)>\n)*'`
|
||||
- `$ pegrep -e '(<sv([^,\n]*,\,)>\n)*'`
|
||||
- `$ pegrep -e '(<csv([^,\n]*)>\n)*'`
|
||||
- `$ pegrep -W -e '(<csv([^,\n]*)>\n)*'`
|
||||
- `$ pegrep -e 'ws:[ \n]*,(<csv([^,\n]<ws>*<ws>)>\n<ws>)*'`
|
||||
- `$ pegrep -e 'ws:[ \n]*,C:[^,\n]*,(<csv(C)>\n<ws>)*'`
|
||||
- `$ pegrep -W -e 'C:[^,\n]*,(<csv(<C>)>\n)*'`
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
12
makefile
12
makefile
|
|
@ -9,7 +9,7 @@ prefix = bin/${buildtype}-buildtype
|
|||
|
||||
objs = $(patsubst %.c,${prefix}/%.o,$(srcs))
|
||||
|
||||
default: ${prefix}/pregrep
|
||||
default: ${prefix}/pegrep
|
||||
|
||||
srclist.mk:
|
||||
find -name '*.c' -! -path '*/junk/*' | sed 's/^/srcs += /' | sort -V > $@
|
||||
|
|
@ -21,7 +21,7 @@ include srclist.mk
|
|||
%/:
|
||||
@mkdir -p $@
|
||||
|
||||
${prefix}/pregrep: ${buildtype_options} ${objs} | ${prefix}/
|
||||
${prefix}/pegrep: ${buildtype_options} ${objs} | ${prefix}/
|
||||
@echo "${buildtype}: linking ${@} ..."
|
||||
@gcc @${buildtype_options} ${objs} -o $@ -lm
|
||||
|
||||
|
|
@ -31,16 +31,16 @@ ${prefix}/%.o ${prefix}/%.d: %.c ${buildtype_options} | ${prefix}/%/
|
|||
|
||||
# env += UBSAN_OPTIONS='halt_on_error=1,print_stacktrace=1'
|
||||
|
||||
run: ${prefix}/pregrep
|
||||
run: ${prefix}/pegrep
|
||||
${env} $< ${args}
|
||||
|
||||
gdbrun: ${prefix}/pregrep
|
||||
gdbrun: ${prefix}/pegrep
|
||||
gdb --args $< ${args}
|
||||
|
||||
valrun: ${prefix}/pregrep
|
||||
valrun: ${prefix}/pegrep
|
||||
valgrind --gen-suppressions=yes -- $< ${args}
|
||||
|
||||
valrun-leak: ${prefix}/pregrep
|
||||
valrun-leak: ${prefix}/pegrep
|
||||
valgrind --leak-check=full --gen-suppressions=yes -- $< ${args}
|
||||
|
||||
include $(patsubst %.c,${prefix}/%.d,$(srcs))
|
||||
|
|
|
|||
Loading…
Reference in a new issue