Skip to content

Commit 043c88a

Browse files
authored
Update NEW-FEATURES.rst
Go over grammar
1 parent b42a339 commit 043c88a

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

NEW-FEATURES.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The original version of this Earley parser, circa 2000, was pretty awesome at
55
that time. It was remarkably fast, and small: one Python file. Some care
66
was put into making it run fast.
77

8-
That made it easy to embed in a project. In fact at one time it was
8+
That made it easy to embed in a project. In fact, at one time it was
99
added to the Python distribution before it was removed in a later version.
1010

1111
But embedding the code was the only option for over a decade. Nor
@@ -62,18 +62,18 @@ over 600 rules for each of the 13 or so versions of Python.
6262
It is very easy to create nonsensical grammar rules, so we need to
6363
have a way to check the grammar. Particularly useful is the ability to
6464
find unused left-hand-side nonterminals that are not either the start
65-
symbol or used on the right-hand side. Likewise unused nonterminals
66-
(lower-case symbols) that appear on the right-hand side that are not
67-
defined as a rule. Of course, tokens or upper-case symbols are ok.
65+
symbol or used on the right-hand side. Likewise, the code has the abitly
66+
to report unused nonterminals (lower-case symbols) that appear on the right-hand
67+
side that are not defined as a rule. Of course, tokens or upper-case symbols are ok.
6868

6969
Checking for duplicate rules is also handy. Also finding immediate
7070
recursion rules. e.g. ``expr ::= expr``.
7171

7272
Parser Error State
7373
==================
7474

75-
The original code showed you the how far you had parsed and that was
76-
useful. But in production code you often want more. So I added the
75+
The original code showed you how far you had parsed and that was
76+
useful. But in production code, you often want more. So I added the
7777
list of rule states of the current state. I won't show that here.
7878

7979
Reduce Rule Tracing
@@ -133,14 +133,14 @@ and other things like that.
133133
Custom Additional Reduction Rule Checks
134134
=======================================
135135

136-
More recently, I the ability to callback before each reduction so
137-
additional checks can be performed before a reduction. In an ambiguous
138-
grammar useful as it helps distinguish which rule should be used among
136+
More recently, I added the ability to run a callback function *before* each reduction, so
137+
additional checks can be performed before the reduction. In an ambiguous
138+
grammar, this is useful because it helps distinguish which rule should be used among
139139
many.
140140

141141
Here are some little examples from the project *uncompyle6* which
142142
deparses Python bytecode. There is a rule in the grammar for a keyword
143-
argument that's used in a parameter list of a function.
143+
argument that is used in a parameter list of a function.
144144
for example the ``path=`` in ``os.path.exists(path='/etc/hosts')``
145145

146146
This grammar rule is:
@@ -150,19 +150,19 @@ This grammar rule is:
150150
kwarg ::= LOAD_CONST expr
151151
152152
153-
But there is an additional restriction that the value in the
153+
However there is an additional restriction that the value of the
154154
``LOAD_CONST`` can't be any old value; it must be a "string" (which
155155
would have the value "path") in the previous example.
156156

157-
The reduction rule checking can work at a strickly token level, or it
158-
can work on and AST tree that would be generated if the reduction were done.
157+
The reduction rule checking can work at a strictly token level, or it
158+
can work on an AST tree that would be generated if the reduction were done.
159159

160160

161161
Limited Grammar Shorthands: \+, \*, ?
162162
=====================================
163163

164164
I also added a little syntactic sugar for the Kleene closure
165-
operators ``+``, ``*`` and optional suffix ``?``. It is limited to only one
165+
operators ``+``, ``*``, and optional suffix ``?``. It is limited to only one
166166
nonterminal on the right-hand side, but that does come up often and
167167
helps a little. So you can now do things like:
168168

@@ -204,7 +204,7 @@ easy to have dead grammar rules that never get used. And
204204
grammar constructs from one version of Python can easily bleed into
205205
another version. By looking at grammar coverage over a large set of
206206
parses, I can prune grammar rules or segregate them. I can also craft
207-
smaller parse tests which cover more of the grammar in fewer Python
207+
smaller parse tests that cover more of the grammar in fewer Python
208208
statements
209209

210210
Removing Grammar Rules

0 commit comments

Comments
 (0)