Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0814ca0
Showing
8 changed files
with
1,811 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This is the official list of Go authors for copyright purposes. | ||
|
||
# Names should be added to this file as | ||
# Name or Organization <email address> | ||
# The email address is not required for organizations. | ||
|
||
Andrew J Snodgrass <andy@pointlander.info> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2010, Go Authors | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation and/or | ||
other materials provided with the distribution. | ||
* Neither the name of the Go Authors nor the names of its contributors may be used to | ||
endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | ||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2010 The Go Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style | ||
# license that can be found in the LICENSE file. | ||
|
||
include $(GOROOT)/src/Make.$(GOARCH) | ||
|
||
.PHONY: all | ||
all: peg | ||
|
||
peg: bootstrap.go peg_main.go | ||
$(GC) peg.go bootstrap.go | ||
$(GC) -I ./ peg_main.go | ||
$(LD) -L ./ -o peg peg_main.6 | ||
|
||
bootstrap.go: bootstrap | ||
./bootstrap | ||
|
||
bootstrap: main.6 | ||
$(LD) -L ./ -o bootstrap main.6 | ||
|
||
main.6: peg.6 main.go | ||
$(GC) -I ./ main.go | ||
|
||
peg.6: peg.go | ||
$(GC) peg.go | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f *.6 bootstrap.go bootstrap peg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
About | ||
|
||
Peg, Parsing Expression Grammar, is an implementation of a Packrat parser | ||
generator. A Packrat parser is a descent recursive parser capable of | ||
backtracking. The generated parser searches for the correct parsing of the | ||
input. | ||
For more information see: | ||
http://en.wikipedia.org/wiki/Parsing_expression_grammar | ||
http://pdos.csail.mit.edu/~baford/packrat/ | ||
This Go implementation is based on: | ||
http://piumarta.com/software/peg/ | ||
|
||
|
||
Files | ||
|
||
main.go: bootstrap syntax tree of peg | ||
peg.go: syntax tree and code generator | ||
peg_main.go: bootstrap main | ||
peg.peg: peg in its own language | ||
|
||
|
||
Building | ||
|
||
make | ||
|
||
|
||
Testing | ||
|
||
There should be no differences between the bootstrap and self compiled: | ||
|
||
./peg -inline -switch peg.peg | ||
diff bootstrap.go peg.peg.go | ||
|
||
"-inline" tells the parser generator to inline parser rules. "-switch" | ||
reduces the number of rules that have to be tried for some pegs. | ||
|
||
|
||
Author | ||
|
||
Andrew J Snodgrass | ||
andy@pointlander.info |
Oops, something went wrong.