libeval_compiler: fixhandling of method calls with empty argument list (e.g. 'A.method()' )

This commit is contained in:
Tomasz Wlostowski 2020-08-27 00:00:42 +02:00
parent 5096ac815f
commit 466cbe2f00
4 changed files with 20 additions and 2 deletions

View File

@ -199,3 +199,10 @@ nt(A) ::= G_IDENTIFIER(F) G_PARENL nt(B) G_PARENR.
A->leaf[0] = newNode( pEval, TR_IDENTIFIER, F.value);
A->leaf[1] = B;
}
nt(A) ::= G_IDENTIFIER(F) G_PARENL G_PARENR.
{
A = newNode( pEval, TR_OP_FUNC_CALL );
A->leaf[0] = newNode( pEval, TR_IDENTIFIER, F.value);
A->leaf[1] = newNode( pEval, TR_NULL );
}

View File

@ -542,6 +542,9 @@ void dumpNode( wxString& buf, TREE_NODE* tok, int depth = 0 )
{
wxString str;
if( !tok )
return;
str.Printf( "\n[%p L0:%-20p L1:%-20p] ", tok, tok->leaf[0], tok->leaf[1] );
buf += str;

View File

@ -89,7 +89,8 @@ enum TOKEN_TYPE_T
TR_ASSIGN = 3,
TR_STRUCT_REF = 4,
TR_STRING = 5,
TR_UNIT = 6
TR_UNIT = 6,
TR_NULL = 7
};
class UOP;

View File

@ -78,7 +78,8 @@ const static std::vector<EXPR_TO_TEST> introspectionExpressions = {
{ "(A.Netclass == 'HV') && (B.netclass == 'otherClass') && (B.netclass != 'F.Cu')", false, VAL( 1.0 ) },
{ "A.Netclass + 1.0", false, VAL( 1.0 ) },
{ "A.type == 'Track' && B.type == 'Track' && A.layer == 'F.Cu'", false, VAL( 1.0 ) },
{ "(A.type == 'Track') && (B.type == 'Track') && (A.layer == 'F.Cu')", false, VAL( 1.0 ) }
{ "(A.type == 'Track') && (B.type == 'Track') && (A.layer == 'F.Cu')", false, VAL( 1.0 ) },
{ "A.type == 'Via' && A.isMicroVia()", false, VAL(0.0) }
};
@ -92,12 +93,18 @@ static bool testEvalExpr( const wxString& expr, LIBEVAL::VALUE expectedResult,
context.SetItems( itemA, itemB );
BOOST_TEST_MESSAGE("Expr: '" << expr.c_str() << "'");
bool error = !compiler.Compile( expr, &ucode, &preflightContext );
BOOST_CHECK_EQUAL( error, expectError );
if( error != expectError )
{
BOOST_TEST_MESSAGE( "Result: FAIL: " << compiler.GetError().message.c_str() <<
" (code pos: " << compiler.GetError().srcPos << ")" );
return false;
}