def XXXX_cast_expression(self):
"""A function returning a parser for parsing cast expressions.
Args:
expression: a pyparsing parser for parsing an expression to be cast.
Returns:
A (pyparsing) parser for parsing cast expressions.
"""
word = pyparsing.Word(pyparsing.alphanums + '_*[]')
nested = pyparsing.Forward().setName("nested")
nested << pyparsing.Combine(
pyparsing.Literal('(').suppress()
+ pyparsing.Combine(
pyparsing.ZeroOrMore(self._integer() | word | nested))
+ pyparsing.Literal(')').suppress()
)
typeof_expression = (
_OPEN_PARENTHESIS
+ pyparsing.Keyword('typeof')
+ nested("typeof_arg")
+ _CLOSE_PARENTHESIS
)
type_expression = (
typeof_expression
| nested("simple_type")
)
return (
type_expression
+ ~(_PLUS | _MINUS)
+ self.expression("expression")
).setParseAction(self._create_cast_expression)
评论列表
文章目录