|
FUNCTION free_variables_of (expr : generic_expression) : SET [0:?] OF generic_variable; LOCAL typenames : SET OF STRING := stripped_typeof ( expr ) ; result : SET OF generic_variable := [ ] ; exprs : LIST OF generic_expression := [ ] ; END_LOCAL ; IF 'generic_literal' IN typenames THEN RETURN ( result ) ; END_IF ; IF 'generic_variable' IN typenames THEN result := result + expr ; RETURN ( result ) ; END_IF ; IF 'quantifier_expression' IN typenames THEN exprs := QUERY ( ge <* expr \ multiple_arity_generic_expression . operands | NOT ( ge IN expr \ quantifier_expression . variables ) ) ; REPEAT i := 1 TO SIZEOF ( exprs ) ; result := result + free_variables_of ( exprs [ i ] ) ; END_REPEAT ; REPEAT i := 1 TO SIZEOF ( expr \ quantifier_expression . variables ) ; result := result - expr \ quantifier_expression . variables [ i ] ; END_REPEAT ; RETURN ( result ) ; END_IF ; IF 'unary_generic_expression' IN typenames THEN RETURN ( free_variables_of ( expr \ unary_generic_expression . operand ) ) ; END_IF ; IF 'binary_generic_expression' IN typenames THEN result := free_variables_of ( expr \ binary_generic_expression . operands [ 1 ] ) ; RETURN ( result + free_variables_of ( expr \ binary_generic_expression . operands [ 2 ] ) ) ; END_IF ; IF 'multiple_arity_generic_expression' IN typenames THEN REPEAT i := 1 TO SIZEOF ( expr \ multiple_arity_generic_expression . operands ) ; result := result + free_variables_of ( expr \ multiple_arity_generic_expression . operands [ i ] ) ; END_REPEAT ; RETURN ( result ) ; END_IF ; RETURN ( result ) ; END_FUNCTION; -- free_variables_of |
|
public class FFree_variables_of public static Value run(SdaiContext _context, Value expr) |