[egenix-users] Continuous searching of text thru all characterson line: Does not work, vol 1

M.-A. Lemburg mal at lemburg.com
Mon Jun 24 21:30:41 CEST 2002


Pekka Niiranen wrote:
> Nope,
> 
> this code works the same:
> 
> ---- code starts ---
> import os
> import pprint
> from simpleparse import generator
> from mx.TextTools import *
> 
> letter_set = set(alpha)
> linput = "aa?BB!aa?DD!cc"
> head_pos = None
> 
> 
> def pr(taglist,txt,l,r,subtag):
>     """Print matched string"""
>     print txt[l:r]
> 
> matchtable = ((pr, AllIn+CallTag, '?', +1),
>               (pr, AllInSet+CallTag, letter_set, +1),
>               (pr, AllIn+CallTag, '!', MatchFail, MatchOk))
> 
> 
> tagtable = ((None, AllInSet, letter_set, +1),
>             ('Match', Table+AppendMatch, matchtable),
>             (None, Table, ThisTable)) # Continue searching after first match
> on line.

Not sure what you want to achieve with the last line.
Shouldn't this be (None, Jump, To, -2) ?


> result,taglist,next = tag(linput, tagtable)
> print taglist
> print "-------"
> 
> ---- code stops ---
> 
> Since one needs parsers mostly because of nested structures cannot be
> searched with re-expressions, please add examples of nested searches in your
> future documentations. Once I get this one running, I will send it to you

You should consult the examples in the Examples directory.
There are a few instances of nested structures in there, e.g.
Tim.py.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                   http://www.egenix.com/files/python/
Meet us at EuroPython 2002:                 http://www.europython.org/




More information about the egenix-users mailing list