mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
C++, parse 'this' in expressions.
This commit is contained in:
parent
7d49a5311f
commit
bde93246c6
1
CHANGES
1
CHANGES
@ -36,6 +36,7 @@ Bugs fixed
|
|||||||
* #4577: Enumerated sublists with explicit start with wrong number
|
* #4577: Enumerated sublists with explicit start with wrong number
|
||||||
* #4641: A external link in TOC cannot contain "?" with ``:glob:`` option
|
* #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 explicit casts and typeid in expression parsing.
|
||||||
|
* C++, add missing parsing of ``this`` in expression parsing.
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -784,6 +784,17 @@ class ASTStringLiteral(ASTBase):
|
|||||||
signode.append(nodes.Text(txt, txt))
|
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):
|
class ASTParenExpr(ASTBase):
|
||||||
def __init__(self, expr):
|
def __init__(self, expr):
|
||||||
self.expr = expr
|
self.expr = expr
|
||||||
@ -4124,7 +4135,10 @@ class DefinitionParser(object):
|
|||||||
res = self._parse_literal()
|
res = self._parse_literal()
|
||||||
if res is not None:
|
if res is not None:
|
||||||
return res
|
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()
|
res = self._parse_fold_or_paren_expression()
|
||||||
if res is not None:
|
if res is not None:
|
||||||
return res
|
return res
|
||||||
|
@ -126,6 +126,7 @@ def test_expressions():
|
|||||||
expr = '5.0' + suffix
|
expr = '5.0' + suffix
|
||||||
exprCheck(expr, 'L' + expr + 'E')
|
exprCheck(expr, 'L' + expr + 'E')
|
||||||
exprCheck('"abc\\"cba"', 'LA8_KcE') # string
|
exprCheck('"abc\\"cba"', 'LA8_KcE') # string
|
||||||
|
exprCheck('this', 'fpT')
|
||||||
# TODO: test the rest
|
# TODO: test the rest
|
||||||
exprCheck('(... + Ns)', '(... + Ns)')
|
exprCheck('(... + Ns)', '(... + Ns)')
|
||||||
exprCheck('(5)', 'L5E')
|
exprCheck('(5)', 'L5E')
|
||||||
|
Loading…
Reference in New Issue
Block a user