C++, parse 'this' in expressions.

This commit is contained in:
Jakob Lykke Andersen 2018-01-17 16:12:30 +01:00
parent 7d49a5311f
commit bde93246c6
3 changed files with 17 additions and 1 deletions

View File

@ -36,6 +36,7 @@ Bugs fixed
* #4577: Enumerated sublists with explicit start with wrong number
* #4641: A external link in TOC cannot contain "?" with ``:glob:`` option
* C++, add missing parsing of explicit casts and typeid in expression parsing.
* C++, add missing parsing of ``this`` in expression parsing.
Testing
--------

View File

@ -784,6 +784,17 @@ class ASTStringLiteral(ASTBase):
signode.append(nodes.Text(txt, txt))
class ASTThisLiteral(ASTBase):
def __unicode__(self):
return "this"
def get_id(self, version):
return "fpT"
def describe_signature(self, signode, mode, env, symbol):
signode.append(nodes.Text("this"))
class ASTParenExpr(ASTBase):
def __init__(self, expr):
self.expr = expr
@ -4124,7 +4135,10 @@ class DefinitionParser(object):
res = self._parse_literal()
if res is not None:
return res
# TODO: try 'this' and lambda expression
self.skip_ws()
if self.skip_word("this"):
return ASTThisLiteral()
# TODO: try lambda expression
res = self._parse_fold_or_paren_expression()
if res is not None:
return res

View File

@ -126,6 +126,7 @@ def test_expressions():
expr = '5.0' + suffix
exprCheck(expr, 'L' + expr + 'E')
exprCheck('"abc\\"cba"', 'LA8_KcE') # string
exprCheck('this', 'fpT')
# TODO: test the rest
exprCheck('(... + Ns)', '(... + Ns)')
exprCheck('(5)', 'L5E')