#
# DO NOT EDIT THIS FILE!
#
# Parser generated by BisonGen on Tue Aug 24 16:25:34 2004.
#


# token definitions
NOTHING = 257
LEADINGWS = 258
LIST = 259
NL = 260
H_START = 261
H_END = 262
TICKS = 263
LINK_START = 264
LINK_END = 265
URL = 266
THREEBRACE_START = 267
THREEBRACE_END = 268
MACRO_START = 269
MACRO_END = 270
TABLE_START = 271
TD = 272
TR = 273
TR_TD = 274
TABLE_END = 275
HR = 276
FIVETILDE = 277
FOURTILDE = 278
THREETILDE = 279
SMALLOPEN = 280
SMALLCLOSE = 281
BIGOPEN = 282
BIGCLOSE = 283
SUB = 284
SUP = 285
DLIST_MOIN = 286
DLIST_MW = 287
XMLLT = 288
XML_CLOSE = 289
XML_TAGTYPE = 290
XML_ATTRS = 291
XMLGT = 292
PRE_CONTENT = 293
NOWIKI_CONTENT = 294
PROCESSOR_CONTENT = 295
XML_TABLE = 296
XML_TABLE_CLOSE = 297
XML_BR = 298
XML_DIV = 299
XML_DIV_CLOSE = 300
XML_TR = 301
XML_TR_CLOSE = 302
XML_TD = 303
XML_TD_CLOSE = 304
XML_LI = 305
XML_LI_CLOSE = 306
XML_UL = 307
XML_UL_CLOSE = 308
XML_OL = 309
XML_OL_CLOSE = 310
XML_DL = 311
XML_DL_CLOSE = 312
XML_DT = 313
XML_DT_CLOSE = 314
XML_HR = 315
ANY = 316

# vector mapping lexer token numbers into internal token numbers
token_translations = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 
59, 60, 61, 62]

YYTRANSLATE = lambda x: x > 316 and 80 or token_translations[x]

# vector of items of all rules.
rhs_tokens = [None,
              [64],
              [64, 63],
              [69],
              [65],
              [79],
              [66],
              [66, 65],
              [9],
              [23],
              [25],
              [12],
              [62],
              [40],
              [74],
              [75],
              [76],
              [78],
              [68],
              [68, 67],
              [72],
              [24],
              [65],
              [],
              [],
              [],
              [],
              [],
              [39],
              [41],
              [24],
              [67],
              [70],
              [70, 69],
              [71],
              [39],
              [77],
              [],
              [],
              [7, 67, 8],
              [7, 65],
              [10, 67, 11],
              [10, 65, 11],
              [10, 65],
              [10, 67],
              [62],
              [62, 73],
              [26, 65, 27],
              [26, 65],
              [28, 65, 29],
              [28, 65],
              [15, 73, 16],
              [15, 73],
              [4, 5],
              [],
              [5],
              [32],
              [],
              [33],
              [],
              [34, 36, 35, 38],
              [34, 36, 37, 35, 38],
              [34, 36, 37, 38],
              [34, 36, 38],
              [34, 35, 36, 38],
              [34, 35, 36, 38],
              [34, 36],
              [4],
              [6],
              [9],
              [10],
              [11],
              [12],
              [32],
              [33],
              [5],
              [13],
              [14],
              [15],
              [16],
              [17],
              [18],
              [19],
              [20],
              [21],
              [22],
              [23],
              [24],
              [25],
              [26],
              [27],
              [28],
              [29],
              [30],
              [31],
              [7],
              [8],
              [3],
              [34],
              [35],
              [36],
              [37],
              [38],
              [41],
              [39],
              [40],
              [62],
              [42],
              [43],
              [44],
              [45],
              [46],
              [47],
              [48],
              [49],
              [50],
              [51],
              [52],
              [53],
              [54],
              [55],
              [56],
              [57],
              [58],
              [59],
              [60],
              [61],
              [62],
              ]

# vector of line numbers and filename of all rules
rule_info = [": line 0",
             "wikishort.bgen: line 73",
             "wikishort.bgen: line 77",
             "wikishort.bgen: line 87",
             "wikishort.bgen: line 88",
             "wikishort.bgen: line 89",
             "wikishort.bgen: line 94",
             "wikishort.bgen: line 95",
             "wikishort.bgen: line 99",
             "wikishort.bgen: line 100",
             "wikishort.bgen: line 101",
             "wikishort.bgen: line 102",
             "wikishort.bgen: line 103",
             "wikishort.bgen: line 104",
             "wikishort.bgen: line 105",
             "wikishort.bgen: line 106",
             "wikishort.bgen: line 107",
             "wikishort.bgen: line 108",
             "wikishort.bgen: line 113",
             "wikishort.bgen: line 114",
             "wikishort.bgen: line 118",
             "wikishort.bgen: line 119",
             "wikishort.bgen: line 120",
             "wikishort.bgen: line 125",
             "wikishort.bgen: line 126",
             "wikishort.bgen: line 130",
             "wikishort.bgen: line 131",
             "wikishort.bgen: line 132",
             "wikishort.bgen: line 133",
             "wikishort.bgen: line 138",
             "wikishort.bgen: line 139",
             "wikishort.bgen: line 143",
             "wikishort.bgen: line 144",
             "wikishort.bgen: line 145",
             "wikishort.bgen: line 146",
             "wikishort.bgen: line 151",
             "wikishort.bgen: line 169",
             "wikishort.bgen: line 173",
             "wikishort.bgen: line 179",
             "wikishort.bgen: line 185",
             "wikishort.bgen: line 186",
             "wikishort.bgen: line 191",
             "wikishort.bgen: line 192",
             "wikishort.bgen: line 196",
             "wikishort.bgen: line 202",
             "wikishort.bgen: line 206",
             "wikishort.bgen: line 212",
             "wikishort.bgen: line 216",
             "wikishort.bgen: line 222",
             "wikishort.bgen: line 226",
             "wikishort.bgen: line 232",
             "wikishort.bgen: line 234",
             "wikishort.bgen: line 239",
             "wikishort.bgen: line 247",
             "wikishort.bgen: line 254",
             "wikishort.bgen: line 262",
             "wikishort.bgen: line 269",
             "wikishort.bgen: line 275",
             "wikishort.bgen: line 282",
             "wikishort.bgen: line 290",
             "wikishort.bgen: line 295",
             "wikishort.bgen: line 296",
             "wikishort.bgen: line 297",
             "wikishort.bgen: line 298",
             "wikishort.bgen: line 299",
             "wikishort.bgen: line 300",
             "wikishort.bgen: line 301",
             "wikishort.bgen: line 302",
             "wikishort.bgen: line 303",
             "wikishort.bgen: line 304",
             "wikishort.bgen: line 305",
             "wikishort.bgen: line 306",
             "wikishort.bgen: line 307",
             "wikishort.bgen: line 308",
             "wikishort.bgen: line 309",
             "wikishort.bgen: line 310",
             "wikishort.bgen: line 311",
             "wikishort.bgen: line 312",
             "wikishort.bgen: line 313",
             "wikishort.bgen: line 314",
             "wikishort.bgen: line 315",
             "wikishort.bgen: line 316",
             "wikishort.bgen: line 317",
             "wikishort.bgen: line 318",
             "wikishort.bgen: line 319",
             "wikishort.bgen: line 320",
             "wikishort.bgen: line 321",
             "wikishort.bgen: line 322",
             "wikishort.bgen: line 323",
             "wikishort.bgen: line 324",
             "wikishort.bgen: line 325",
             "wikishort.bgen: line 326",
             "wikishort.bgen: line 327",
             "wikishort.bgen: line 328",
             "wikishort.bgen: line 329",
             "wikishort.bgen: line 330",
             "wikishort.bgen: line 331",
             "wikishort.bgen: line 332",
             "wikishort.bgen: line 333",
             "wikishort.bgen: line 334",
             "wikishort.bgen: line 335",
             "wikishort.bgen: line 336",
             "wikishort.bgen: line 337",
             "wikishort.bgen: line 338",
             "wikishort.bgen: line 339",
             "wikishort.bgen: line 340",
             "wikishort.bgen: line 341",
             "wikishort.bgen: line 342",
             "wikishort.bgen: line 343",
             "wikishort.bgen: line 344",
             "wikishort.bgen: line 345",
             "wikishort.bgen: line 346",
             "wikishort.bgen: line 347",
             "wikishort.bgen: line 348",
             "wikishort.bgen: line 349",
             "wikishort.bgen: line 350",
             "wikishort.bgen: line 351",
             "wikishort.bgen: line 352",
             "wikishort.bgen: line 353",
             "wikishort.bgen: line 354",
             "wikishort.bgen: line 355",
             ]

# vector of string-names indexed by token number
token_names = ['<EOF>',
               'error',
               '$undefined.',
               'NOTHING',
               'LEADINGWS',
               'LIST',
               'NL',
               'H_START',
               'H_END',
               'TICKS',
               'LINK_START',
               'LINK_END',
               'URL',
               'THREEBRACE_START',
               'THREEBRACE_END',
               'MACRO_START',
               'MACRO_END',
               'TABLE_START',
               'TD',
               'TR',
               'TR_TD',
               'TABLE_END',
               'HR',
               'FIVETILDE',
               'FOURTILDE',
               'THREETILDE',
               'SMALLOPEN',
               'SMALLCLOSE',
               'BIGOPEN',
               'BIGCLOSE',
               'SUB',
               'SUP',
               'DLIST_MOIN',
               'DLIST_MW',
               'XMLLT',
               'XML_CLOSE',
               'XML_TAGTYPE',
               'XML_ATTRS',
               'XMLGT',
               'PRE_CONTENT',
               'NOWIKI_CONTENT',
               'PROCESSOR_CONTENT',
               'XML_TABLE',
               'XML_TABLE_CLOSE',
               'XML_BR',
               'XML_DIV',
               'XML_DIV_CLOSE',
               'XML_TR',
               'XML_TR_CLOSE',
               'XML_TD',
               'XML_TD_CLOSE',
               'XML_LI',
               'XML_LI_CLOSE',
               'XML_UL',
               'XML_UL_CLOSE',
               'XML_OL',
               'XML_OL_CLOSE',
               'XML_DL',
               'XML_DL_CLOSE',
               'XML_DT',
               'XML_DT_CLOSE',
               'XML_HR',
               'ANY',
               'Root',
               'Toplevel',
               'Inlines',
               'Inline',
               'Inlines_pluslink',
               'Inline_pluslink',
               'BlocklevelS',
               'Blocklevel',
               'Header',
               'Link',
               'ANYs',
               'Small',
               'Big',
               'Macro',
               'ListItem',
               'XMLTag',
               'Catchall',
               'XMLTag',
               'Catchall',
               'None',
               '0',
               ]

# symbol number of symbol that rule derives.
derives = [0, 63, 63, 64, 64, 64, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 
66, 66, 67, 67, 68, 68, 68, -1, -1, -1, -1, -1, -1, 69, 69, 70, 70, 70, 
-1, 71, 71, 72, 72, 72, 72, 73, 73, 74, 74, 75, 75, 76, 76, -1, 77, -1, 
-1, 78, 78, 78, 78, 78, 78, 78, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 
79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 
79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 
79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79]

# number of symbols composing right hand side of rule.
rhs_size = [0, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 
1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 2, 3, 3, 2, 2, 1, 2, 3, 
2, 3, 2, 3, 2, 3, 1, 2, 2, 4, 5, 4, 3, 4, 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1]

# default rule to reduce with in state. 0 means the default is an error.
# indexed by state number
default_action = [0, 90, 60, 50, 61, 88, 89, 8, 63, 64, 11, 69, 70, 71, 
72, 73, 74, 75, 76, 77, 78, 9, 80, 10, 82, 83, 84, 85, 86, 87, 66, 67, 
91, 92, 93, 94, 95, 32, 13, 96, 100, 101, 102, 103, 104, 105, 106, 107, 
108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 12, 1, 4, 6, 
3, 29, 31, 14, 15, 16, 33, 17, 5, 8, 0, 11, 0, 9, 21, 10, 0, 0, 0, 13, 
12, 36, 0, 18, 20, 41, 48, 44, 46, 0, 59, 2, 7, 50, 0, 32, 30, 22, 40, 
35, 22, 19, 42, 47, 43, 45, 0, 0, 0, 56, 38, 37, 57, 53, 0, 55, 54, 0, 
0, 0]

# default state to go to after a reduction of a rule.
# indexed by variable number (lhs token)
default_goto = [95, 61, 62, 63, 86, 87, 64, 65, 66, 88, 90, 67, 68, 69, 
70, 71, 72]

# index in yytable of the portion describing state (indexed by state number)
# If the value in yytable is positive, we shift the token and go to that state.
# If the value is negative, it is minus a rule number to reduce by.
# If the value is zero, the default action from yydefact[s] is used.
action_idx = [91, -32768, -32768, -32768, -32768, 19, -32768, -32768, -32768, 
-32768, -32768, -32768, -32768, -61, -32768, -32768, -32768, -32768, -32768, 
-32768, -32768, -32768, -32768, -32768, 23, -32768, 23, -32768, -32768, 
-32768, -32768, -32768, -30, -32768, -32768, -32768, -32768, -32768, -32768, 
-32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, 
-32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, 
-32768, -32768, -32768, -32768, 91, -32768, 23, -32768, -3, -32768, -32768, 
-32768, -32768, -32768, -32768, -32768, -32768, 145, -32768, -61, -32768, 
-32768, -32768, 149, 149, -30, -32768, -32768, -1, 9, 172, -32768, -61, 
4, 3, 8, -10, -25, -32768, -32768, -32768, 172, -32768, -32768, 29, 30, 
-32768, -32768, -32768, -32768, -32768, -32768, -32768, 12, 14, -20, -32768, 
-32768, -32768, -32768, -32768, 16, -32768, -32768, 55, 56, -32768]

# the index in yytable of the portion describing what to do after reducing a rule.
# The value from yytable is the state to go to.
goto_idx = [60, -32768, -5, -32768, -71, -32768, 0, -32768, -32768, -32768, 
-27, -32768, -32768, -32768, -32768, -32768, -32768]

# a vector filled with portions for different uses. (using action_idx and goto_idx)
yytable = [85, 89, 97, 102, 98, 93, 94, -22, -22, -22, 111, -22, 112, 113, 
-22, 118, 105, 103, 119, 91, 107, 92, -22, -22, -22, -22, 110, -22, 73, 
74, 108, 75, 73, -22, 76, 75, 99, 109, 76, -22, 114, 115, 77, 78, 79, 80, 
77, 81, 79, 80, 116, 81, 117, 82, 120, 122, 123, 82, 96, 83, 121, -22, 
106, 83, 0, 100, 0, 0, 0, 101, 0, 0, 0, 0, 0, 91, 92, 0, 0, 0, 0, 84, 104, 
0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 85, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 73, 74, 0, 75, 73, 0, 76, 
75, 0, 0, 76, 0, 0, 0, 77, 78, 79, 80, 77, 81, 79, 80, 0, 81, 0, 82, 0, 
73, 74, 82, 75, 83, 0, 76, 0, 83, 0, 0, 0, 0, 0, 77, 78, 79, 80, 0, 81, 
0, 0, 0, 0, 0, 82, 84, 0, 0, 0, 84, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84]

# a vector indexed in parallel with yytable.
# It indicates the bounds of the portion you are trying to examine.
yycheck = [5, 62, 5, 74, 7, 35, 36, 8, 9, 10, 35, 12, 37, 38, 15, 35, 87, 
8, 38, 24, 16, 26, 23, 24, 25, 26, 36, 28, 9, 10, 27, 12, 9, 34, 15, 12, 
39, 29, 15, 40, 11, 11, 23, 24, 25, 26, 23, 28, 25, 26, 38, 28, 38, 34, 
38, 0, 0, 34, 63, 40, 0, 62, 89, 40, -1, 65, -1, -1, -1, 74, -1, -1, -1, 
-1, -1, 80, 81, -1, -1, -1, -1, 62, 87, -1, -1, 62, -1, -1, -1, -1, -1, 
-1, -1, 98, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 
56, 57, 58, 59, 60, 61, 62, 9, 10, -1, 12, 9, -1, 15, 12, -1, -1, 15, -1, 
-1, -1, 23, 24, 25, 26, 23, 28, 25, 26, -1, 28, -1, 34, -1, 9, 10, 34, 
12, 40, -1, 15, -1, 40, -1, -1, -1, -1, -1, 23, 24, 25, 26, -1, 28, -1, 
-1, -1, -1, -1, 34, 62, -1, -1, -1, 62, 40, -1, -1, -1, -1, -1, -1, -1, 
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62]

YYLAST = 234
YYFINAL = 123
YYFLAG = -32768
YYNTBASE = 63

# Static definitions
YYEMPTY = -2
YYEOF = 0
YYINITDEPTH = 1000

LEXER_FUNCTIONS = 0

class Parser:
    def __init__(self, verbose=0):
        self.verbose = verbose
        
    def debug_mode(self, flag=None):
        if flag is None:
            return self.verbose

        if type(flag) != type(1):
            raise TypeError('an integer is required')
        self.verbose = flag
        return flag

    def parse(self, text):
        state_stack = [0]*YYINITDEPTH
        value_stack = [0]*YYINITDEPTH

        
        lexer_pos = 0
        lexer_end = len(text)
        lexer_state = INITIAL
        lexer_last = 0
        yylval = ''

        yyline = 1
        yycolumn = 1
        
        yystate = 0
        yychar = YYEMPTY        # cause a token to be read
        
        # Initialize stack pointers
        # Waste one element of value and location stack
        # so that they stay on the same level as the state stack.
        # The wasted elements are never initialized.
        state_ptr = -1
        value_ptr = 0
        
        while 1:
            # Push a new state, which is found in yystate.
            # In all cases, when you get here, the value and location stacks
            # have just been pushed.  So pushing a state here evens the stacks.
            state_ptr = state_ptr + 1
            state_stack[state_ptr] = yystate
        
            
            # Do appropriate processing given the current state.
            # Read a lookahead token if we need one and don't already have one.
        
            # First try to decide what to do without reference to lookahead token.
            yyn = action_idx[yystate]
            if yyn == YYFLAG:
                yyn = default_action[yystate]
                if yyn == 0:
                    self.report_error(yystate, yyline, yycolumn, yylval)
                    return 1
                # Do a reduction. yyn is the number of a rule to reduce with.
        
                state_ptr = state_ptr - rhs_size[yyn]
                value_ptr = value_ptr - rhs_size[yyn]
        
                if action_routines[yyn]:
                    yyval = action_routines[yyn](self, value_stack, value_ptr)
                    value_ptr = value_ptr + 1
                    value_stack[value_ptr] = yyval
                else:
                    value_ptr = value_ptr + 1

        
                # Now "shift" the result of the reduction.
                # Determine what state that goes to, based on the state
                # we popped back to and the rule number reduced by.
        
                yyn = derives[yyn] - YYNTBASE
                yystate = goto_idx[yyn] + state_stack[state_ptr]
                if 0 <= yystate <= YYLAST and yycheck[yystate] == state_stack[state_ptr]:
                    yystate = yytable[yystate]
                else:
                    yystate = default_goto[yyn]
                continue
            
            # Not known => get a lookahead token if don't already have one.
        
            # yychar is either YYEMPTY, YYEOF or a valid token in external form
            if yychar == YYEMPTY:
                # Setup line and column numbers
                for ch in yylval:
                    if ch == '\n':
                        yyline = yyline + 1
                        yycolumn = 1
                    else:
                        yycolumn = yycolumn + 1

                ### Lexical analysis ###
                while lexer_last < lexer_end:
                    lexer_pos = lexer_last
                    try:
                        match = patterns[lexer_state].match(text, lexer_pos)
                        matched = reduce(lambda result, item:
                                         item[1] is None and result or item,
                                         match.groupdict().items(),
                                         (None, None))
                    except AttributeError:
                        # comes here when match is none, it is an error anyway
                        self.error('No action found for "%s"' % text[lexer_pos:])

                    lexer_last = lexer_last + len(matched[1])
                    lexer_action = pattern_actions[matched[0]]
                    
                    if lexer_action:
                        lexer_state = lexer_action[0] or lexer_state
                        if len(lexer_action) > 1:
                            yylval = matched[1]
                            yychar = lexer_action[1] or ord(yylval)
                            break
                        else:
                            # Just a state change, reprocess the text
                            lexer_last = lexer_pos
                    else:
                        # throw away matched text and update position
                        for ch in matched[1]:
                            if ch == '\n':
                                yyline = yyline + 1
                                yycolumn = 1
                            else:
                                yycolumn = yycolumn + 1
                    continue
                else:
                    # Reached end of input
                    yychar = YYEOF
            # Convert token to internal form (in yychar1) for indexing tables with

            if yychar <= 0:
                # This means end-of-input.
                yychar1 = 0
            else:
                yychar1 = YYTRANSLATE(yychar)
                yyn = yyn + yychar1

            if yyn < 0 or yyn > YYLAST or  yycheck[yyn] != yychar1:
                # comes here after end of input
                yyn = default_action[yystate]
                if yyn == 0:
                    self.report_error(yystate, yyline, yycolumn, yylval)
                    return None
                # Do a reduction. yyn is the number of a rule to reduce with.
        
                state_ptr = state_ptr - rhs_size[yyn]
                value_ptr = value_ptr - rhs_size[yyn]
        
                if action_routines[yyn]:
                    yyval = action_routines[yyn](self, value_stack, value_ptr)
                    value_ptr = value_ptr + 1
                    value_stack[value_ptr] = yyval
                else:
                    value_ptr = value_ptr + 1

        
                # Now "shift" the result of the reduction.
                # Determine what state that goes to, based on the state
                # we popped back to and the rule number reduced by.
        
                yyn = derives[yyn] - YYNTBASE
                yystate = goto_idx[yyn] + state_stack[state_ptr]
                if 0 <= yystate <= YYLAST and yycheck[yystate] == state_stack[state_ptr]:
                    yystate = yytable[yystate]
                else:
                    yystate = default_goto[yyn]
                continue
            
            yyn = yytable[yyn]
        
            # yyn is what to do for this token type in this state.
            # Negative => reduce, -yyn is rule number.
            # Positive => shift, yyn is new state.
            #   New state is final state => don't bother to shift
            #   just return success.
            # 0, or max negative number => error.
        
            if YYFLAG < yyn < 0:
                yyn = -yyn
                # Do a reduction. yyn is the number of a rule to reduce with.
        
                state_ptr = state_ptr - rhs_size[yyn]
                value_ptr = value_ptr - rhs_size[yyn]
        
                if action_routines[yyn]:
                    yyval = action_routines[yyn](self, value_stack, value_ptr)
                    value_ptr = value_ptr + 1
                    value_stack[value_ptr] = yyval
                else:
                    value_ptr = value_ptr + 1

        
                # Now "shift" the result of the reduction.
                # Determine what state that goes to, based on the state
                # we popped back to and the rule number reduced by.
        
                yyn = derives[yyn] - YYNTBASE
                yystate = goto_idx[yyn] + state_stack[state_ptr]
                if 0 <= yystate <= YYLAST and yycheck[yystate] == state_stack[state_ptr]:
                    yystate = yytable[yystate]
                else:
                    yystate = default_goto[yyn]
                continue
            elif yyn == YYFINAL:
                return value_stack[value_ptr-1]
            elif yyn <= 0:
                # Now it is either 0 or YYFLAG
                self.report_error(yystate, yyline, yycolumn, yylval)
                return None
            
            # Shift the lookahead token.
        
 
            if yychar != YYEOF:
                yychar = YYEMPTY
            
            value_ptr = value_ptr + 1
            value_stack[value_ptr] = yylval
        
            yystate = yyn
            continue
        # should never get here
        return None
        
    def report_error(self, state, line, column, lval):
        ruleno = action_idx[state]
        msg = "parse error at line %d, column %d: matched '%s'" % (
            line, column, lval)
        if YYFLAG < ruleno < YYLAST:
            # Start X at -ruleno to avoid negative indexes in yycheck
            start = ruleno < 0 and -ruleno or 0
            first = 1
            for x in range(start, len(token_names)):
                if (x + ruleno) < len(yycheck) and yycheck[x + ruleno] == x:
                    if first:
                        msg = msg + ", expecting"
                        first = 0
                    else:
                        msg = msg + " or"
                    msg = msg + " '%s'" % token_names[x]
        self.error(msg)
        return
        
    def announce(self, format, *args):
        sys.stderr.write(format % args)
        return

    def error(self, format, *args):
        raise SyntaxError(format % args)

    def print_reduce(self, rule):
        sys.stderr.write("Reducing via rule %d (%s), " % (rule, rule_info[rule]))
        # print the symbols being reduced and their result.
        for token in rhs_tokens[rule]:
            sys.stderr.write("%s " % token_names[token])
        sys.stderr.write("-> %s\n" % token_names[derives[rule]])
        return

    def print_state_stack(self, stack, size):
        sys.stderr.write("state stack now")
        for i in range(size+1):
            sys.stderr.write(" %d" % stack[i])
        sys.stderr.write("\n")
        return

new = Parser

# modules required for action routines

# the action code for each rule
def Root1(self, __stack, __ptr):
    """
    from wikishort.bgen, line 73
    Root: Toplevel
    """
    __val = __stack[__ptr+1]
    return __val

def Root2(self, __stack, __ptr):
    """
    from wikishort.bgen, line 77
    Root: Toplevel Root
    """
    __val = __stack[__ptr+1]+__stack[__ptr+2]
    return __val

def Inlines2(self, __stack, __ptr):
    """
    from wikishort.bgen, line 95
    Inlines: Inline Inlines
    """
    __val = __stack[__ptr+1]+__stack[__ptr+2]
    return __val

def Inline1(self, __stack, __ptr):
    """
    from wikishort.bgen, line 99
    Inline: TICKS
    """
    __val = 'TICKS|'+__stack[__ptr+1]+'|'
    return __val

def Inline2(self, __stack, __ptr):
    """
    from wikishort.bgen, line 100
    Inline: FIVETILDE
    """
    __val = 'FIVETILDE|'+__stack[__ptr+1]+'|'
    return __val

def Inline3(self, __stack, __ptr):
    """
    from wikishort.bgen, line 101
    Inline: THREETILDE
    """
    __val = 'THREETILDE|'+__stack[__ptr+1]+'|'
    return __val

def Inline4(self, __stack, __ptr):
    """
    from wikishort.bgen, line 102
    Inline: URL
    """
    __val = 'URL|'+__stack[__ptr+1]+'|'
    return __val

def Inline5(self, __stack, __ptr):
    """
    from wikishort.bgen, line 103
    Inline: ANY
    """
    __val = __stack[__ptr+1]
    return __val

def Inline6(self, __stack, __ptr):
    """
    from wikishort.bgen, line 104
    Inline: NOWIKI_CONTENT
    """
    __val = '*'+__stack[__ptr+1]+'|'
    return __val

def Inline7(self, __stack, __ptr):
    """
    from wikishort.bgen, line 105
    Inline: Small
    """
    __val = 'small|'+__stack[__ptr+1]+'|'
    return __val

def Inline8(self, __stack, __ptr):
    """
    from wikishort.bgen, line 106
    Inline: Big
    """
    __val = __stack[__ptr+1]
    return __val

def Inline9(self, __stack, __ptr):
    """
    from wikishort.bgen, line 107
    Inline: Macro
    """
    __val = __stack[__ptr+1]
    return __val

def Inline10(self, __stack, __ptr):
    """
    from wikishort.bgen, line 108
    Inline: XMLTag
    """
    __val = __stack[__ptr+1]
    return __val

def Inlines_pluslink2(self, __stack, __ptr):
    """
    from wikishort.bgen, line 114
    Inlines_pluslink: Inline_pluslink Inlines_pluslink
    """
    __val = __stack[__ptr+1]+__stack[__ptr+2]
    return __val

def Inline_pluslink2(self, __stack, __ptr):
    """
    from wikishort.bgen, line 119
    Inline_pluslink: FOURTILDE
    """
    __val = 'THREETILDE|'+__stack[__ptr+1]+'|'
    return __val

def Flows2(self, __stack, __ptr):
    """
    from wikishort.bgen, line 126
    Flows: Flow Flows
    """
    __val = __stack[__ptr+1]+__stack[__ptr+2]
    return __val

def Flow1(self, __stack, __ptr):
    """
    from wikishort.bgen, line 130
    Flow: PRE_CONTENT
    """
    __val = 'prec'+__stack[__ptr+1]+'|'
    return __val

def Flow2(self, __stack, __ptr):
    """
    from wikishort.bgen, line 131
    Flow: PROCESSOR_CONTENT
    """
    __val = 'proc'+__stack[__ptr+1]+'|'
    return __val

def Flow3(self, __stack, __ptr):
    """
    from wikishort.bgen, line 132
    Flow: FOURTILDE
    """
    __val = 'THREETILDE|'+__stack[__ptr+1]+'|'
    return __val

def BlocklevelS2(self, __stack, __ptr):
    """
    from wikishort.bgen, line 139
    BlocklevelS: Blocklevel BlocklevelS
    """
    __val = __stack[__ptr+1]+__stack[__ptr+2]
    return __val

def Blocklevel2(self, __stack, __ptr):
    """
    from wikishort.bgen, line 144
    Blocklevel: PRE_CONTENT
    """
    __val = 'preinbl'+__stack[__ptr+1]+'|'
    return __val

def Blocklevel3(self, __stack, __ptr):
    """
    from wikishort.bgen, line 145
    Blocklevel: ListItem
    """
    __val = 'ListBL'+__stack[__ptr+1]+'|'
    return __val

def Header1(self, __stack, __ptr):
    """
    from wikishort.bgen, line 151
    Header: H_START Inlines_pluslink H_END
    """
    diff = len(__stack[__ptr+3]) - len(__stack[__ptr+1])
    if diff < 0:
        __stack[__ptr+1] = __stack[__ptr+3][:len(__stack[__ptr+1])]
        __stack[__ptr+2] = -diff*'='+__stack[__ptr+2]
    elif diff > 0:
        __stack[__ptr+3] = __stack[__ptr+1][:len(__stack[__ptr+3])]
        __stack[__ptr+2] = __stack[__ptr+2]+diff*'='
    __val = 'H'+str(len(__stack[__ptr+1]))+'\\'+__stack[__ptr+2]+'/'
    return __val

def Link1(self, __stack, __ptr):
    """
    from wikishort.bgen, line 173
    Link: LINK_START Inlines_pluslink LINK_END
    """
    __val = 'IMGLINK\\'+__stack[__ptr+1]+__stack[__ptr+2]+__stack[__ptr+3]+'/LINK'
    return __val

def Link2(self, __stack, __ptr):
    """
    from wikishort.bgen, line 179
    Link: LINK_START Inlines LINK_END
    """
    __val = 'LINK\\'+__stack[__ptr+1]+__stack[__ptr+2]+__stack[__ptr+3]+'/LINK'
    return __val

def ANYs2(self, __stack, __ptr):
    """
    from wikishort.bgen, line 192
    ANYs: ANY ANYs
    """
    __val = __stack[__ptr+1]+__stack[__ptr+2]
    return __val

def Small1(self, __stack, __ptr):
    """
    from wikishort.bgen, line 196
    Small: SMALLOPEN Inlines SMALLCLOSE
    """
    __val = 'Small\\'+__stack[__ptr+1]+__stack[__ptr+2]+__stack[__ptr+3]+'/Small'
    return __val

def Big1(self, __stack, __ptr):
    """
    from wikishort.bgen, line 206
    Big: BIGOPEN Inlines BIGCLOSE
    """
    __val = 'Big\\'+__stack[__ptr+1]+__stack[__ptr+2]+__stack[__ptr+3]+'/Big'
    return __val

def Macro1(self, __stack, __ptr):
    """
    from wikishort.bgen, line 216
    Macro: MACRO_START ANYs MACRO_END
    """
    __val = 'Macro\\'+__stack[__ptr+1]+__stack[__ptr+2]+__stack[__ptr+3]+'/Macro'
    return __val

def ListItem1(self, __stack, __ptr):
    """
    from wikishort.bgen, line 226
    ListItem: LEADINGWS LIST Inlines_extended
    """
    __val = 'ListMM\\'+__stack[__ptr+1]+__stack[__ptr+2]+__stack[__ptr+3]+'/ListMM'
    return __val

def ListItem3(self, __stack, __ptr):
    """
    from wikishort.bgen, line 234
    ListItem: DLIST_MOIN Inlines_extended
    """
    __val = 'ListMM\\'+__stack[__ptr+1]+__stack[__ptr+2]+'/ListMM'
    return __val

def ListItem4(self, __stack, __ptr):
    """
    from wikishort.bgen, line 239
    ListItem: DLIST_MW Inlines_extended
    """
    __val = 'ListMM\\'+__stack[__ptr+1]+__stack[__ptr+2]+'/ListMM'
    return __val

def XMLTag1(self, __stack, __ptr):
    """
    from wikishort.bgen, line 247
    XMLTag: XMLLT XML_TAGTYPE XML_CLOSE XMLGT
    """
    __val = 'xmlSingle\\'+__stack[__ptr+1]+__stack[__ptr+2]+__stack[__ptr+3]+__stack[__ptr+4]+'/xmlSingle'
    return __val

def XMLTag2(self, __stack, __ptr):
    """
    from wikishort.bgen, line 254
    XMLTag: XMLLT XML_TAGTYPE XML_ATTRS XML_CLOSE XMLGT
    """
    __val = 'xmlSingleAtt\\'+__stack[__ptr+1]+__stack[__ptr+2]+__stack[__ptr+3]+__stack[__ptr+4]+__stack[__ptr+5]+'/xmlSingleAtt'
    return __val

def XMLTag3(self, __stack, __ptr):
    """
    from wikishort.bgen, line 262
    XMLTag: XMLLT XML_TAGTYPE XML_ATTRS XMLGT
    """
    __val = 'xmlAtt\\'+__stack[__ptr+1]+__stack[__ptr+2]+__stack[__ptr+3]+__stack[__ptr+4]+'/xmlAtt'
    return __val

def XMLTag4(self, __stack, __ptr):
    """
    from wikishort.bgen, line 269
    XMLTag: XMLLT XML_TAGTYPE XMLGT
    """
    __val = 'xml\\'+__stack[__ptr+1]+__stack[__ptr+2]+__stack[__ptr+3]+'/xml'
    return __val

def XMLTag5(self, __stack, __ptr):
    """
    from wikishort.bgen, line 275
    XMLTag: XMLLT XML_CLOSE XML_TAGTYPE XMLGT
    """
    __val = 'xmlClose\\'+__stack[__ptr+1]+__stack[__ptr+2]+__stack[__ptr+3]+__stack[__ptr+4]+'/xmlClose'
    return __val

def XMLTag6(self, __stack, __ptr):
    """
    from wikishort.bgen, line 282
    XMLTag: XMLLT XML_CLOSE XML_TAGTYPE XMLGT
    """
    __val = 'xmlClose\\'+__stack[__ptr+1]+__stack[__ptr+2]+__stack[__ptr+3]+__stack[__ptr+4]+'/xmlClose'
    return __val

def Catchall1(self, __stack, __ptr):
    """
    from wikishort.bgen, line 295
    Catchall: LEADINGWS
    """
    __val = 'LEADINGWS|'+__stack[__ptr+1]+'|'
    return __val

def Catchall3(self, __stack, __ptr):
    """
    from wikishort.bgen, line 297
    Catchall: TICKS
    """
    __val = 'TICKS|'+__stack[__ptr+1]+'|'
    return __val

def Catchall4(self, __stack, __ptr):
    """
    from wikishort.bgen, line 298
    Catchall: LINK_START
    """
    __val = 'LINK_START|'+__stack[__ptr+1]+'|'
    return __val

def Catchall5(self, __stack, __ptr):
    """
    from wikishort.bgen, line 299
    Catchall: LINK_END
    """
    __val = 'LINK_END|'+__stack[__ptr+1]+'|'
    return __val

def Catchall6(self, __stack, __ptr):
    """
    from wikishort.bgen, line 300
    Catchall: URL
    """
    __val = 'URL|'+__stack[__ptr+1]+'|'
    return __val

def Catchall7(self, __stack, __ptr):
    """
    from wikishort.bgen, line 301
    Catchall: DLIST_MOIN
    """
    __val = 'DLIST|'+__stack[__ptr+1]+'|'
    return __val

def Catchall8(self, __stack, __ptr):
    """
    from wikishort.bgen, line 302
    Catchall: DLIST_MW
    """
    __val = 'DLIST|'+__stack[__ptr+1]+'|'
    return __val

def Catchall9(self, __stack, __ptr):
    """
    from wikishort.bgen, line 303
    Catchall: LIST
    """
    __val = 'LIST|'+__stack[__ptr+1]+'|'
    return __val

def Catchall10(self, __stack, __ptr):
    """
    from wikishort.bgen, line 304
    Catchall: THREEBRACE_START
    """
    __val = 'THREEBRACE_START|'+__stack[__ptr+1]+'|'
    return __val

def Catchall11(self, __stack, __ptr):
    """
    from wikishort.bgen, line 305
    Catchall: THREEBRACE_END
    """
    __val = 'THREEBRACE_END|'+__stack[__ptr+1]+'|'
    return __val

def Catchall12(self, __stack, __ptr):
    """
    from wikishort.bgen, line 306
    Catchall: MACRO_START
    """
    __val = 'MACRO_START|'+__stack[__ptr+1]+'|'
    return __val

def Catchall13(self, __stack, __ptr):
    """
    from wikishort.bgen, line 307
    Catchall: MACRO_END
    """
    __val = 'MACRO_END|'+__stack[__ptr+1]+'|'
    return __val

def Catchall14(self, __stack, __ptr):
    """
    from wikishort.bgen, line 308
    Catchall: TABLE_START
    """
    __val = 'TABLE_START|'+__stack[__ptr+1]+'|'
    return __val

def Catchall15(self, __stack, __ptr):
    """
    from wikishort.bgen, line 309
    Catchall: TD
    """
    __val = 'TD|'+__stack[__ptr+1]+'|'
    return __val

def Catchall16(self, __stack, __ptr):
    """
    from wikishort.bgen, line 310
    Catchall: TR
    """
    __val = 'TR|'+__stack[__ptr+1]+'|'
    return __val

def Catchall17(self, __stack, __ptr):
    """
    from wikishort.bgen, line 311
    Catchall: TR_TD
    """
    __val = 'TR_TD|'+__stack[__ptr+1]+'|'
    return __val

def Catchall18(self, __stack, __ptr):
    """
    from wikishort.bgen, line 312
    Catchall: TABLE_END
    """
    __val = 'TABLE_END|'+__stack[__ptr+1]+'|'
    return __val

def Catchall19(self, __stack, __ptr):
    """
    from wikishort.bgen, line 313
    Catchall: HR
    """
    __val = 'HR|'+__stack[__ptr+1]+'|'
    return __val

def Catchall20(self, __stack, __ptr):
    """
    from wikishort.bgen, line 314
    Catchall: FIVETILDE
    """
    __val = 'FIVETILDE|'+__stack[__ptr+1]+'|'
    return __val

def Catchall21(self, __stack, __ptr):
    """
    from wikishort.bgen, line 315
    Catchall: FOURTILDE
    """
    __val = 'FOURTILDE|'+__stack[__ptr+1]+'|'
    return __val

def Catchall22(self, __stack, __ptr):
    """
    from wikishort.bgen, line 316
    Catchall: THREETILDE
    """
    __val = 'THREETILDE|'+__stack[__ptr+1]+'|'
    return __val

def Catchall23(self, __stack, __ptr):
    """
    from wikishort.bgen, line 317
    Catchall: SMALLOPEN
    """
    __val = 'SMALLOPEN|'+__stack[__ptr+1]+'|'
    return __val

def Catchall24(self, __stack, __ptr):
    """
    from wikishort.bgen, line 318
    Catchall: SMALLCLOSE
    """
    __val = 'SMALLCLOSE|'+__stack[__ptr+1]+'|'
    return __val

def Catchall25(self, __stack, __ptr):
    """
    from wikishort.bgen, line 319
    Catchall: BIGOPEN
    """
    __val = 'BIGOPEN|'+__stack[__ptr+1]+'|'
    return __val

def Catchall26(self, __stack, __ptr):
    """
    from wikishort.bgen, line 320
    Catchall: BIGCLOSE
    """
    __val = 'BIGCLOSE|'+__stack[__ptr+1]+'|'
    return __val

def Catchall27(self, __stack, __ptr):
    """
    from wikishort.bgen, line 321
    Catchall: SUB
    """
    __val = 'SUB|'+__stack[__ptr+1]+'|'
    return __val

def Catchall28(self, __stack, __ptr):
    """
    from wikishort.bgen, line 322
    Catchall: SUP
    """
    __val = 'SUP|'+__stack[__ptr+1]+'|'
    return __val

def Catchall29(self, __stack, __ptr):
    """
    from wikishort.bgen, line 323
    Catchall: H_START
    """
    __val = 'H_START|'+__stack[__ptr+1]+'|'
    return __val

def Catchall30(self, __stack, __ptr):
    """
    from wikishort.bgen, line 324
    Catchall: H_END
    """
    __val = 'H_END|'+__stack[__ptr+1]+'|'
    return __val

def Catchall31(self, __stack, __ptr):
    """
    from wikishort.bgen, line 325
    Catchall: NOTHING
    """
    __val = ''
    return __val

def Catchall32(self, __stack, __ptr):
    """
    from wikishort.bgen, line 326
    Catchall: XMLLT
    """
    __val = 'XMLLT'+__stack[__ptr+1]
    return __val

def Catchall33(self, __stack, __ptr):
    """
    from wikishort.bgen, line 327
    Catchall: XML_CLOSE
    """
    __val = 'XML_CLOSE'+__stack[__ptr+1]
    return __val

def Catchall34(self, __stack, __ptr):
    """
    from wikishort.bgen, line 328
    Catchall: XML_TAGTYPE
    """
    __val = 'XML_TAGTYPE'+__stack[__ptr+1]
    return __val

def Catchall35(self, __stack, __ptr):
    """
    from wikishort.bgen, line 329
    Catchall: XML_ATTRS
    """
    __val = 'XML_ATTR_PAIR'+__stack[__ptr+1]
    return __val

def Catchall36(self, __stack, __ptr):
    """
    from wikishort.bgen, line 330
    Catchall: XMLGT
    """
    __val = 'XMLGT'+__stack[__ptr+1]
    return __val

def Catchall37(self, __stack, __ptr):
    """
    from wikishort.bgen, line 331
    Catchall: PROCESSOR_CONTENT
    """
    __val = '*'+__stack[__ptr+1]+'|'
    return __val

def Catchall38(self, __stack, __ptr):
    """
    from wikishort.bgen, line 332
    Catchall: PRE_CONTENT
    """
    __val = '*'+__stack[__ptr+1]+'|'
    return __val

def Catchall39(self, __stack, __ptr):
    """
    from wikishort.bgen, line 333
    Catchall: NOWIKI_CONTENT
    """
    __val = '*'+__stack[__ptr+1]+'|'
    return __val

def Catchall40(self, __stack, __ptr):
    """
    from wikishort.bgen, line 334
    Catchall: ANY
    """
    __val = '*'+__stack[__ptr+1]+'|'
    return __val

def Catchall41(self, __stack, __ptr):
    """
    from wikishort.bgen, line 335
    Catchall: XML_TABLE
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall42(self, __stack, __ptr):
    """
    from wikishort.bgen, line 336
    Catchall: XML_TABLE_CLOSE
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall43(self, __stack, __ptr):
    """
    from wikishort.bgen, line 337
    Catchall: XML_BR
    """
    __val = 'brbr'+__stack[__ptr+1]
    return __val

def Catchall44(self, __stack, __ptr):
    """
    from wikishort.bgen, line 338
    Catchall: XML_DIV
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall45(self, __stack, __ptr):
    """
    from wikishort.bgen, line 339
    Catchall: XML_DIV_CLOSE
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall46(self, __stack, __ptr):
    """
    from wikishort.bgen, line 340
    Catchall: XML_TR
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall47(self, __stack, __ptr):
    """
    from wikishort.bgen, line 341
    Catchall: XML_TR_CLOSE
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall48(self, __stack, __ptr):
    """
    from wikishort.bgen, line 342
    Catchall: XML_TD
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall49(self, __stack, __ptr):
    """
    from wikishort.bgen, line 343
    Catchall: XML_TD_CLOSE
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall50(self, __stack, __ptr):
    """
    from wikishort.bgen, line 344
    Catchall: XML_LI
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall51(self, __stack, __ptr):
    """
    from wikishort.bgen, line 345
    Catchall: XML_LI_CLOSE
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall52(self, __stack, __ptr):
    """
    from wikishort.bgen, line 346
    Catchall: XML_UL
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall53(self, __stack, __ptr):
    """
    from wikishort.bgen, line 347
    Catchall: XML_UL_CLOSE
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall54(self, __stack, __ptr):
    """
    from wikishort.bgen, line 348
    Catchall: XML_OL
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall55(self, __stack, __ptr):
    """
    from wikishort.bgen, line 349
    Catchall: XML_OL_CLOSE
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall56(self, __stack, __ptr):
    """
    from wikishort.bgen, line 350
    Catchall: XML_DL
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall57(self, __stack, __ptr):
    """
    from wikishort.bgen, line 351
    Catchall: XML_DL_CLOSE
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall58(self, __stack, __ptr):
    """
    from wikishort.bgen, line 352
    Catchall: XML_DT
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall59(self, __stack, __ptr):
    """
    from wikishort.bgen, line 353
    Catchall: XML_DT_CLOSE
    """
    __val = ''+__stack[__ptr+1]
    return __val

def Catchall60(self, __stack, __ptr):
    """
    from wikishort.bgen, line 354
    Catchall: XML_HR
    """
    __val = 'HR'+__stack[__ptr+1]
    return __val

def Catchall61(self, __stack, __ptr):
    """
    from wikishort.bgen, line 355
    Catchall: ANY
    """
    __val = ''+__stack[__ptr+1]
    return __val

action_routines = [None,
                   Root1,
                   Root2,
                   None,
                   None,
                   None,
                   None,
                   Inlines2,
                   Inline1,
                   Inline2,
                   Inline3,
                   Inline4,
                   Inline5,
                   Inline6,
                   Inline7,
                   Inline8,
                   Inline9,
                   Inline10,
                   None,
                   Inlines_pluslink2,
                   None,
                   Inline_pluslink2,
                   None,
                   None,
                   Flows2,
                   Flow1,
                   Flow2,
                   Flow3,
                   None,
                   None,
                   BlocklevelS2,
                   None,
                   Blocklevel2,
                   Blocklevel3,
                   None,
                   Header1,
                   None,
                   Link1,
                   Link2,
                   None,
                   None,
                   None,
                   ANYs2,
                   Small1,
                   None,
                   Big1,
                   None,
                   Macro1,
                   None,
                   ListItem1,
                   None,
                   ListItem3,
                   ListItem4,
                   XMLTag1,
                   XMLTag2,
                   XMLTag3,
                   XMLTag4,
                   XMLTag5,
                   XMLTag6,
                   None,
                   Catchall1,
                   None,
                   Catchall3,
                   Catchall4,
                   Catchall5,
                   Catchall6,
                   Catchall7,
                   Catchall8,
                   Catchall9,
                   Catchall10,
                   Catchall11,
                   Catchall12,
                   Catchall13,
                   Catchall14,
                   Catchall15,
                   Catchall16,
                   Catchall17,
                   Catchall18,
                   Catchall19,
                   Catchall20,
                   Catchall21,
                   Catchall22,
                   Catchall23,
                   Catchall24,
                   Catchall25,
                   Catchall26,
                   Catchall27,
                   Catchall28,
                   Catchall29,
                   Catchall30,
                   Catchall31,
                   Catchall32,
                   Catchall33,
                   Catchall34,
                   Catchall35,
                   Catchall36,
                   Catchall37,
                   Catchall38,
                   Catchall39,
                   Catchall40,
                   Catchall41,
                   Catchall42,
                   Catchall43,
                   Catchall44,
                   Catchall45,
                   Catchall46,
                   Catchall47,
                   Catchall48,
                   Catchall49,
                   Catchall50,
                   Catchall51,
                   Catchall52,
                   Catchall53,
                   Catchall54,
                   Catchall55,
                   Catchall56,
                   Catchall57,
                   Catchall58,
                   Catchall59,
                   Catchall60,
                   Catchall61,
                   ]

# start condition definitions for the lexer
XMLTAGCHECK = 2
INITIAL = 1
XMLINNERTAG = 4
URLSCHEMAS = 5
MOINLIST = 6
XMLTAG = 7
PROCESSOR_PRE = 3
TILDE = 8
LS_BAR = 9
PROCESSOR = 10
PROCESSOR_NOWIKI = 11
LINESTART = 12

# the expressions and information for each rule
import re
patterns = {
    XMLTAGCHECK : re.compile(u'(?P<p00>(?=<[^<>]{0,90}>))|(?P<p01>.)', re.M),
    PROCESSOR_PRE : re.compile(u'(?P<p02></pre>)|(?P<p03>[^<]+)|(?P<p04>.)', re.M),
    XMLINNERTAG : re.compile(u'(?P<p05>/)|(?P<p06>[A-Za-z:]+)|(?P<p07>\\s*[^/>])|(?P<p08>>)', re.M),
    URLSCHEMAS : re.compile(u'(?P<p09>(http|https|ftp|nntp|news|mailto|telnet|wiki|file)://[^/\\s]+\\.[^/\\s\':,]+/?[^\\s]*(?=([,\\.:\'"\\)\\(]+\\s)|\\s))|(?P<p10>.)', re.M),
    MOINLIST : re.compile(u'(?P<p11>(([0-9]+|[aAiI])\\.(?:#\\d+)?|\\*)\\s)|(?P<p12>)', re.M),
    XMLTAG : re.compile(u'(?P<p13><pre\\s*>)|(?P<p14><nowiki\\s*>)|(?P<p15><)|(?P<p16>(?iu)table)|(?P<p17>(?iu)/table)|(?P<p18>(?iu)br)|(?P<p19>(?iu)div)|(?P<p20>(?iu)/div)|(?P<p21>(?iu)tr)|(?P<p22>(?iu)/tr)|(?P<p23>(?iu)td)|(?P<p24>(?iu)/td)|(?P<p25>(?iu)li)|(?P<p26>(?iu)/li)|(?P<p27>(?iu)ul)|(?P<p28>(?iu)/ul)|(?P<p29>(?iu)ol)|(?P<p30>(?iu)/ol)|(?P<p31>(?iu)dl)|(?P<p32>(?iu)/dl)|(?P<p33>(?iu)dt)|(?P<p34>(?iu)/dt)|(?P<p35>(?iu)hr)|(?P<p36>)', re.M),
    INITIAL : re.compile(u'(?P<p37>\\r?\\n|\\A)|(?P<p38>[^}{\\[\\]\\n\\r=~:\'*#^,_\\-+|<hfi]+)|(?P<p39>(http|https|ftp|nntp|news|mailto|telnet|wiki|file)://[^/\\s]+\\.[^/\\s\':,]+/?[^\\s]*(?=([,\\.:\'"\\)\\(]+\\s)|\\s))|(?P<p40>={1,6}$)|(?P<p41>\'\'+)|(?P<p42>\\[{1,4})|(?P<p43>\\]{1,4}\\w*)|(?P<p44>:: )|(?P<p45>(?<= ): )|(?P<p46>{{{(?!{))|(?P<p47>\\|\\|)|(?P<p48>{{)|(?P<p49>}})|(?P<p50>(?=<))|(?P<p51>(?=~))|(?P<p52>-~)|(?P<p53>\\+~)|(?P<p54>,,[^,\\n\\r]{1,60},,)|(?P<p55>\\^[^^\\n\\r]{1,60}\\^)|(?P<p56>.)', re.M),
    TILDE : re.compile(u'(?P<p57>~~~~~)|(?P<p58>~~~~)|(?P<p59>~~~)|(?P<p60>~-)|(?P<p61>~\\+)|(?P<p62>.)', re.M),
    LS_BAR : re.compile(u'(?P<p63>\\|\\|)|(?P<p64>\\|-+)|(?P<p65>\\|})|(?P<p66>\\|)|(?P<p67>.)', re.M),
    PROCESSOR : re.compile(u'(?P<p68>}}})|(?P<p69>[^}]+)|(?P<p70>.)', re.M),
    PROCESSOR_NOWIKI : re.compile(u'(?P<p71></nowiki>)|(?P<p72>[^<]+)|(?P<p73>.)', re.M),
    LINESTART : re.compile(u'(?P<p74>(?=\\|))|(?P<p75>[*#:;]+)|(?P<p76> +)|(?P<p77>={1,6})|(?P<p78>{\\|)|(?P<p79>-{4,})|(?P<p80>)', re.M),
}
pattern_actions = {
    'p00' : (XMLTAG, NOTHING),
    'p01' : (INITIAL, ANY),
    'p02' : (INITIAL, THREEBRACE_END),
    'p03' : (None, PRE_CONTENT),
    'p04' : (None, PRE_CONTENT),
    'p05' : (None, XML_CLOSE),
    'p06' : (None, XML_TAGTYPE),
    'p07' : (None, XML_ATTRS),
    'p08' : (INITIAL, XMLGT),
    'p09' : (INITIAL, URL),
    'p10' : (INITIAL, ANY),
    'p11' : (INITIAL, LIST),
    'p12' : (INITIAL, NOTHING),
    'p13' : (PROCESSOR_PRE, THREEBRACE_START),
    'p14' : (PROCESSOR_NOWIKI, THREEBRACE_START),
    'p15' : (None, XMLLT),
    'p16' : (XMLINNERTAG, XML_TABLE),
    'p17' : (XMLINNERTAG, XML_TABLE_CLOSE),
    'p18' : (XMLINNERTAG, XML_BR),
    'p19' : (XMLINNERTAG, XML_DIV),
    'p20' : (XMLINNERTAG, XML_DIV_CLOSE),
    'p21' : (XMLINNERTAG, XML_TR),
    'p22' : (XMLINNERTAG, XML_TR_CLOSE),
    'p23' : (XMLINNERTAG, XML_TD),
    'p24' : (XMLINNERTAG, XML_TD_CLOSE),
    'p25' : (XMLINNERTAG, XML_LI),
    'p26' : (XMLINNERTAG, XML_LI_CLOSE),
    'p27' : (XMLINNERTAG, XML_UL),
    'p28' : (XMLINNERTAG, XML_UL_CLOSE),
    'p29' : (XMLINNERTAG, XML_OL),
    'p30' : (XMLINNERTAG, XML_OL_CLOSE),
    'p31' : (XMLINNERTAG, XML_DL),
    'p32' : (XMLINNERTAG, XML_DL_CLOSE),
    'p33' : (XMLINNERTAG, XML_DT),
    'p34' : (XMLINNERTAG, XML_DT_CLOSE),
    'p35' : (XMLINNERTAG, XML_HR),
    'p36' : (XMLINNERTAG, NOTHING),
    'p37' : (LINESTART, NL),
    'p38' : (None, ANY),
    'p39' : (None, URL),
    'p40' : (None, H_END),
    'p41' : (None, TICKS),
    'p42' : (None, LINK_START),
    'p43' : (None, LINK_END),
    'p44' : (None, DLIST_MOIN),
    'p45' : (None, DLIST_MW),
    'p46' : (PROCESSOR, THREEBRACE_START),
    'p47' : (None, TD),
    'p48' : (None, MACRO_START),
    'p49' : (None, MACRO_END),
    'p50' : (XMLTAGCHECK, NOTHING),
    'p51' : (TILDE, NOTHING),
    'p52' : (None, SMALLCLOSE),
    'p53' : (None, BIGCLOSE),
    'p54' : (None, SUB),
    'p55' : (None, SUP),
    'p56' : (None, ANY),
    'p57' : (INITIAL, FIVETILDE),
    'p58' : (INITIAL, FOURTILDE),
    'p59' : (INITIAL, THREETILDE),
    'p60' : (INITIAL, SMALLOPEN),
    'p61' : (INITIAL, BIGOPEN),
    'p62' : (INITIAL, ANY),
    'p63' : (INITIAL, TR_TD),
    'p64' : (INITIAL, TR),
    'p65' : (INITIAL, TABLE_END),
    'p66' : (INITIAL, TD),
    'p67' : (INITIAL, ANY),
    'p68' : (INITIAL, THREEBRACE_END),
    'p69' : (None, PROCESSOR_CONTENT),
    'p70' : (None, PROCESSOR_CONTENT),
    'p71' : (INITIAL, THREEBRACE_END),
    'p72' : (None, NOWIKI_CONTENT),
    'p73' : (None, NOWIKI_CONTENT),
    'p74' : (LS_BAR, NOTHING),
    'p75' : (INITIAL, LIST),
    'p76' : (MOINLIST, LEADINGWS),
    'p77' : (INITIAL, H_START),
    'p78' : (INITIAL, TABLE_START),
    'p79' : (INITIAL, HR),
    'p80' : (INITIAL, NOTHING),
}
if __name__ == '__main__':
    import sys
    try: import readline
    except: pass

    try:
        import wikic
        parser = wikic.new(1)
        print 'Using C parser'
    except:
        import wiki
        parser = wiki.new(1)
        print 'Using Python parser'

    if len(sys.argv) > 1:
        result = parser.parse(sys.argv[1])
        result.pprint()
        raise SystemExit()
    print 'Use <Ctrl>-C to exit.'
    try:
        while 1:
            expr = raw_input('>>>')
            print parser.parse(expr)
    except KeyboardInterrupt:
        raise SystemExit

