在查看C++语法时,我发现后缀大致定义如下:
Postfix ::= Primary
| Postfix '[' Expression ']'
| Postfix '(' Expression ')'
| Postfix '.' Identifier
| Postfix '->' Identifier
| Postfix '++'
| Postfix '--'
Run Code Online (Sandbox Code Playgroud)
这意味着foo.f++()将是语法上有效的-大概是因为功能是指针,将参考中定义的下一个功能,但是如果没有语义解析的修改const对象中抓到我会感到震惊-为将foo.f()<true>;其没有按似乎没有任何意义foo.++f(),虽然它与第一个或多或少相同,但是不允许.此外,定义了一元表达式,使其++*"hello world"在语法上有效,因为文字被认为与标识符的方式相同.
相反的是:
postfix0 ::= ScopeResolution
| postfix0 '.' postfix2
| postfix0 '->' postfix2
postfix1 ::= postfix0
| postfix1 '<' expression '>'
postfix2 ::= postfix1
| postfix2 '[' expression ']'
| postfix2 '(' expression ']'
postfix3 ::= postfix2
| Literal
| postfix3 '++'
| …Run Code Online (Sandbox Code Playgroud)