def test_concat(self): """test : concat""" cases = [ (list('abcde'), '(abcde)'), (list('(abcde)'), '(\(abcde\))'), (['a', 'b'], '(ab)'), (['a'], '(a)'), ] for case in cases: self.assertEqual(yare.concat(case[0]), case[1])
'LPAREN', 'RPAREN', 'LBRACKET', 'RBRACKET', 'LBRACE', 'RBRACE', # Newlines 'NEWLINE', # Whitespaces 'WHITESPACE', # Identifiers 'ID', ) # Types t_CHAR = yare.concat(list('char')) t_INT = yare.concat(list('int')) t_VOID = yare.concat(list('void')) # Keywords t_ELSE = yare.concat(list('else')) t_EXTERN = yare.concat(list('extern')) t_IF = yare.concat(list('if')) t_RETURN = yare.concat(list('return')) t_WHILE = yare.concat(list('while')) # Literals def t_INTCON(t): t.value = int(t.value) return t t_INTCON.__doc__ = yare.concat([
'RBRACKET', 'LBRACE', 'RBRACE', # Newlines 'NEWLINE', # Whitespaces 'WHITESPACE', # Identifiers 'ID', ) # Types t_CHAR = yare.concat(list('char')) t_INT = yare.concat(list('int')) t_VOID = yare.concat(list('void')) # Keywords t_ELSE = yare.concat(list('else')) t_EXTERN = yare.concat(list('extern')) t_IF = yare.concat(list('if')) t_RETURN = yare.concat(list('return')) t_WHILE = yare.concat(list('while')) # Literals def t_INTCON(t): t.value = int(t.value) return t