Skip to content

Commit ca2e6ee

Browse files
committed
adding comments to make it clear what is happening in this example
1 parent 45aedd5 commit ca2e6ee

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

examples/exceptions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@
2828
testSource = "<html<title>Yes</title><body><h1>Man, HTML is <i>great</i>.</h1><p>How could you even <b>think</b> otherwise?</p><img src='HIPPO.JPG'></img><a href='http://twistedmatrix.com'>A Good Website</a></body></html>"
2929

3030
print unwrapGrammar(TinyHTML)(testSource).apply('tag')
31+
32+
# The "tag" rule uses the custom label construct "^ (valid tag)".
33+
# When this rule fails, the exception raised will say
34+
# "expected a valid tag".
35+
#
36+
# <html<title>Yes</title><body><h1>Man, HTML is <i>great</i>.</h1><p>How could you even <b>think</b> otherwise?</p><img src='HIPPO.JPG'></img><a href='http://twistedmatrix.com'>A Good Website</a></body></html>
37+
# ^
38+
# Parse error at line 1, column 5: expected a valid tag. trail: [name attribute tag]

0 commit comments

Comments
 (0)