def p_asm_expression(p): '''asm_expression : __ASM__ volatile_opt '(' string_literal ')' | __ASM__ volatile_opt '(' string_literal ':' str_opt_expr_pair_list ')' | __ASM__ volatile_opt '(' string_literal ':' str_opt_expr_pair_list ':' str_opt_expr_pair_list ')' | __ASM__ volatile_opt '(' string_literal ':' str_opt_expr_pair_list ':' str_opt_expr_pair_list ':' str_opt_expr_pair_list ')' ''' # Definitely not ISO C, adapted from example ANTLR GCC parser at # http://www.antlr.org/grammar/cgram//grammars/GnuCParser.g # but more lenient (expressions permitted in optional final part, when # they shouldn't be -- avoids shift/reduce conflict with # str_opt_expr_pair_list). p[0] = expressions.UnsupportedExpressionNode("This node is ASM assembler.")
def p_identifier(p): '''identifier : IDENTIFIER | IDENTIFIER PP_IDENTIFIER_PASTE identifier | PP_MACRO_PARAM PP_IDENTIFIER_PASTE identifier | IDENTIFIER PP_IDENTIFIER_PASTE PP_MACRO_PARAM | PP_MACRO_PARAM PP_IDENTIFIER_PASTE PP_MACRO_PARAM ''' if len(p) == 2: p[0] = expressions.IdentifierExpressionNode(p[1]) else: # Should it be supported? It wouldn't be very hard to add support. # Basically, it would involve a new ExpressionNode called # an IdentifierPasteExpressionNode that took a list of strings and # ParameterExpressionNodes. Then it would generate code like # "locals()['%s' + '%s' + ...]" where %s was substituted with the # elements of the list. I haven't supported it yet because I think # it's unnecessary and a little too powerful. p[0] = expressions.UnsupportedExpressionNode("Identifier pasting is " \ "not supported by ctypesgen.")