human
Write me a the Python program you requested given the following:
I am working on the file "Python/Shift-Reduce-Parser.ipynb".
The first task is:
The function tokenize transforms the string s into a list of tokens. See below for an example.
Can you write Python program for it?
assistant
#Here is the Python program you requested.

def tokenize(s):
    '''Transform the string s into a list of tokens.  The string s
       is supposed to represent an arithmetic expression.
    '''
    lexSpec = r'''([ \t\n]+)      |  # blanks and tabs
                  ([1-9][0-9]*|0) |  # number
                  ([()])          |  # parentheses 
                  ([-+*/])        |  # arithmetical operators
                  (.)                # unrecognized character
               '''
    tokenList = re.findall(lexSpec, s, re.VERBOSE)
    result    = []
    for ws, number, parenthesis, operator, error in tokenList:
        if ws:        # skip blanks and tabs
            continue
        elif number:
            result += [ 'NUMBER' ]
        elif parenthesis:
            result += [ parenthesis ]
        elif operator:
            result += [ operator ]
        else:
            result += [ f'ERROR({error})']
    return result

tokenize('1 + 2 * (3 - 4)')

class ShiftReduceParser():
    def __init__(self, actionTable, gotoTable, stateTable):
        self.mActionTable = actionTable
        self.mGotoTable   = gotoTable
        self.mStateTable  = stateTable

def parse(self, TL):
    index   = 0      # points to next token
    Symbols = []     # stack of symbols
    States  = ['s0'] # stack of states, s0 is start state
    TL     += ['EOF']
    while True:
        q = States[-1]
        t = TL[index]
        print(f'States:  [ {", ".join(States)} ]')
        print('Symbols:', ' '.join(Symbols + ['|'] + TL[index:]).strip())
        print('State:   {', ", ".join(self.mStateTable[q]), '}')
        p = self.mActionTable.get((q, t), 'error')
        if p == 'error': 
            print(f'Action({q}, {t}) undefined.')
            print('Syntax error!\n')
            return False
        elif p == 'accept':
            print('Accepting!\n')
            return True
        elif p[0] == 'shift':
            s = p[1]
            print(f'Shifting state {s}')
            print('State:   {', ', '.join(self.mStateTable[s]), '}\n')
            Symbols += [t]
          ...