def test_example11(self):
     text = u"Amend § 1005.36 to revise the section heading and "
     text += "paragraphs (a) and (b), and to add paragraph (d) to read "
     text += "as follows:"
     result = parse_text(text)
     self.assertEqual(result, [
         tokens.Context(['1005', None, '36']),
         tokens.Verb(tokens.Verb.PUT, active=True),
         tokens.Paragraph([], field=tokens.Paragraph.HEADING_FIELD),
         tokens.AndToken(),
         tokens.TokenList([tokens.Paragraph(paragraph='a'),
                           tokens.Paragraph(paragraph='b')]),
         tokens.AndToken(),
         tokens.Verb(tokens.Verb.POST, active=True),
         tokens.Paragraph(paragraph='d'),
     ])
 def test_example14(self):
     text = "and removing paragraph (c)(5) to read as follows:"
     result = parse_text(text)
     self.assertEqual(result, [
         tokens.AndToken(),
         tokens.Verb(tokens.Verb.DELETE, active=True),
         tokens.Paragraph([None, None, None, 'c', '5'])
     ])
 def test_example10(self):
     text = "paragraph (b) and the introductory text of paragraph (c)"
     result = parse_text(text)
     self.assertEqual(result, [
         tokens.Paragraph(paragraph='b'),
         tokens.AndToken(),
         tokens.Paragraph(paragraph='c', field=tokens.Paragraph.TEXT_FIELD)
     ])

intro_text_marker = (
    (Marker("introductory") + WordBoundaries(CaselessLiteral("text"))) |
    (Marker("subject") + Marker("heading")).setParseAction(lambda _: "text")
)

of_connective = (Marker("of") | Marker("for") | Marker("to"))

passive_marker = (
    Marker("is") | Marker("are") | Marker("was") | Marker("were") |
    Marker("and").setResultsName("and_prefix").setParseAction(
        lambda _: True))


and_token = Marker("and").setParseAction(lambda _: tokens.AndToken())


# Verbs
def generate_verb(word_list, verb, active):
    """Short hand for making tokens.Verb from a list of trigger words"""
    word_list = [CaselessLiteral(w) for w in word_list]
    if not active:
        word_list = [passive_marker + w for w in word_list]
    grammar = reduce(lambda l, r: l | r, word_list)
    grammar = WordBoundaries(grammar)
    grammar = grammar.setParseAction(
        lambda m: tokens.Verb(verb, active, bool(m.and_prefix)))
    return grammar