Skip to content

Commit

Permalink
imported peg-0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gpakosz committed May 14, 2007
0 parents commit d164cbe
Show file tree
Hide file tree
Showing 41 changed files with 5,398 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
leg
peg
58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
CFLAGS = -g -Wall $(OFLAGS) $(XFLAGS)
OFLAGS = -O3 -DNDEBUG
#OFLAGS = -pg

OBJS = tree.o compile.o

all : peg leg

peg : peg.o $(OBJS)
$(CC) $(CFLAGS) -o $@-new peg.o $(OBJS)
mv $@-new $@

leg : leg.o $(OBJS)
$(CC) $(CFLAGS) -o $@-new leg.o $(OBJS)
mv $@-new $@

ROOT =
PREFIX = /usr/local
BINDIR = $(ROOT)$(PREFIX)/bin

install : $(BINDIR)/peg $(BINDIR)/leg

$(BINDIR)/% : %
cp -p $< $@
strip $@

uninstall : .FORCE
rm -f $(BINDIR)/peg
rm -f $(BINDIR)/leg

peg.o : peg.c peg.peg-c

%.peg-c : %.peg
# ./peg -o $@ $<

leg.o : leg.c

leg.c : leg.leg
# ./leg -o $@ $<

check : peg .FORCE
./peg < peg.peg > peg.out
diff peg.peg-c peg.out
rm peg.out

test examples : .FORCE
$(SHELL) -ec '(cd examples; $(MAKE))'

clean : .FORCE
rm -f *~ *.o *.peg.[cd] *.leg.[cd]
$(SHELL) -ec '(cd examples; $(MAKE) $@)'

spotless : clean .FORCE
rm -f peg
rm -f leg
$(SHELL) -ec '(cd examples; $(MAKE) $@)'

.FORCE :
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# peg/leg &mdash; recursive-descent parser generators for C

`peg` and `leg` are tools for generating recursive-descent parsers: programs that perform pattern matching on
text. They processes a Parsing Expression Grammar (PEG)[Ford 2004] to produce a program that recognises legal sentences of that grammar.

`peg` processes PEGs written using the original syntax described by Ford.

`leg` processes PEGs written using slightly different syntax and conventions that are intended to make it an attractive replacement for parsers built with `lex` and `yacc`.

Unlike `lex` and `yacc`, `peg` and `leg` support unlimited backtracking, provide ordered choice as a means for disambiguation, and can combine scanning (lexical analysis) and parsing (syntactic analysis) into a single activity.

`peg` is distributed under the MIT license. It will not infect your project with a contagious <strike>license</strike> disease if you
decide to modify it for your own use. The parser generators that `peg` creates are unencumbered and you are free to use and/or
distribute them any way you like.

`peg`/`leg` is copyright (c) 2007 by Ian Piumarta.

## References

* `peg`/`leg` manual page: [peg.1.html][1]

* [Ford 2004] Bryan Ford, [*Parsing Expression Grammars: A Recognition-Based Syntactic Foundation*][2]. ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), 2004.

[1]: http://piumarta.com/software/peg/peg.1.html "peg/leg manual"
[2]: http://bford.info/pub/lang/peg "Parsing Expression Grammars: A Recognition-Based Syntactic Foundation"

## Version history

* **0.1.1** ([zip](peg/zipball/0.1.1), [tar.gz](peg/tarball/0.1.1)) &mdash; 2007-05-15
First public release.
Loading

0 comments on commit d164cbe

Please sign in to comment.