-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
35 lines (30 loc) · 1.58 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2016 David R. Jenni. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
Package pg provides packages to lex, parse and pretty-print
context-free grammars. Furthermore it provides a package for
generating SLR(1) parsers. The command pg implements a parser
generator using these packages. Package example contains example
programs which use the command pg.
A grammar is specified using BNF, which is a set of derivation rules
(productions). The following grammar specifies BNF (represented itself
in BNF); any input must satisfy this grammar:
Production -> "PRODUCTION_NAME" "->" Expression "." .
Expression -> Expression "|" Alternative | Alternative .
Alternative -> Alternative Terminal | Terminal .
Terminal -> "PRODUCTION_NAME" | "TOKEN" | "e" .
Production names and tokens are symbols of the grammar. The name of
the first production of the grammar is the start symbol. A production
name is an identifier, a token is a string. The arrow "->" is
interchangeable with the UTF-8 character U+2192 "→". The symbol "e"
indicates the empty symbol (epsilon). "e" is interchangeable with the
UTF-8 character U+03B5 "ε".
The arrow means that the symbol on the left must be replaced with the
expression on the right. An expression consists of one or more
sequences of symbols. More sequences are separated by a vertical bar,
indicating a choice. Multiple lines are allowed. A production is
terminated by a dot. The arrow means that the symbol on the left must
be replaced with the expression on the right.
*/
package pg