[Tutor] mxTextTools help: find the deepest in nest lists

pan at uchicago.edu pan at uchicago.edu
Wed Dec 10 00:48:48 EST 2003


I am learning how to use mxTextTools. I need help with
the following ... 

I wanna match the deepest lists in a nested list tree.
For example:

The [2, 2a] and [3, 3b] in :

   [[[1,[2, 2a]],[[3,3b],4]],6]

The [a.1,b_2] and [d.3,e] in :

   [[a.1,b_2],[[c,[d.3,e]],f]]

The [a1,a2], [d.1, d.2] and [o3,o4] in :

   [[[[[a1,a2],out],[d.1, d.2]],o2],[[o3,o4],o5]]

How can I setup a tagtable for matching them ??

What I got so far --- after painful trial and error --- is :

tagTable=((None, SubTable,
        (   (None, AllIn, '[', Fail),
            ('text',AllIn,allowed, Fail),
            (None,AllIn,']', MatchOk, +0)
        ), -1, +0
         ),
          )

which is still very terrible:

-- It only matches one set of the deepest lists (for example, 
only match [a1,a2] in the case 3);

-- it also returns something I dont' want (for example,  'c,' in the case-2)

-- it can't match entries starting with a number (for example, 
   [2, 2a])




pan



More information about the Tutor mailing list