Fix parsing of a::b.c() and x::y.z

Fixes #3197
This commit is contained in:
Olly Betts 2025-06-17 15:23:15 +12:00
parent 3f4ed82945
commit 61c542162c
3 changed files with 19 additions and 8 deletions

View File

@ -8,9 +8,10 @@ Version 4.4.0 (in progress)
===========================
2025-06-17: olly
#3197 Improve parsing of expressions related to functions calls.
For example, the following no longer give parse errors: `g().d()`,
`g().D`, `(f(1) < g(2))`, `sizeof f(a,b)`
#3197 Improve parsing of expressions related to functions calls
and/or member access. For example, the following no longer give
parse errors: `g().d()`, `g().D`, `a::b.c()`, `x::y.z`, `(f(1) <
g(2))`, `sizeof f(a,b)`
2025-06-11: wsfulton
[Python] Add support for -builtin and heap types turned on with

View File

@ -8,8 +8,10 @@
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK) UsdGeomTokensPtr;
%immutable UsdGeomTokens;
// helper() only exists to test we can parse more complex expressions.
// These helpers only exists to test we can parse more complex expressions.
%ignore helper;
%ignore H::helper;
%ignore H::helping;
// Don't call our getters get_xxx() as that collides with generated getters in
// some languages (e.g. csharp).
@ -76,8 +78,16 @@ void CreateMaterialBindSubsetz(int num = UsdGeomTokens.g_face(1,2).g_val().g_val
// Regression tests for #3197.
Tokens& helper(bool = false, bool = false) { return UsdGeomTokens; }
namespace H {
Tokens& helper(bool = false, bool = false) { return UsdGeomTokens; }
static Tokens helping;
}
void ParseTest1(int num = helper().face.val.val) {}
void ParseTest2(int num = helper().g_face().val.val) {}
void ParseTest3(int num = H::helper().face.val.val) {}
void ParseTest4(int num = H::helper().g_face().val.val) {}
void ParseTest5(int num = H::helping.face.val.val) {}
void ParseTest6(int num = H::helping.g_face().val.val) {}
void ParseTestN(bool b = (helper().g_face().val.val < helper().face.val.val)) {}
%}

View File

@ -6760,17 +6760,17 @@ expr : valexpr
;
/* member access expressions and function calls */
exprmem : ID[lhs] ARROW ID[rhs] {
exprmem : idcolon ARROW ID {
$$ = default_dtype;
$$.val = NewStringf("%s->%s", $lhs, $rhs);
$$.val = NewStringf("%s->%s", $idcolon, $ID);
}
| exprmem[in] ARROW ID {
$$ = $in;
Printf($$.val, "->%s", $ID);
}
| ID[lhs] PERIOD ID[rhs] {
| idcolon PERIOD ID {
$$ = default_dtype;
$$.val = NewStringf("%s.%s", $lhs, $rhs);
$$.val = NewStringf("%s.%s", $idcolon, $ID);
}
| exprmem[in] PERIOD ID {
$$ = $in;