Why does BridgePoint grammar allow ? as rval

homepage Forums BridgePoint/xtUML Usage and Training Why does BridgePoint grammar allow ? as rval

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5293
    Bob Mulvey
    Keymaster

    In discussion today, the BP oal grammar was discussed (QMARK in https://github.com/xtuml/bridgepoint/blob/master/src/org.xtuml.bp.als.oal/bnf/oal.bnf ). Specifically, there is support for an rval of ? (qmark in oal.bnf). Looking at the current implementation for this token I see no valid use case. Furthermore, there is inconsistency between the parser and verifier here (parser allows something that the verifier does not support).

    Consider:

    Example 1 (this IS currently valid syntax AND executes):
    test=1;
    test=?;
    LOG::LogInteger(message:test);
    // This displays the value 1

    Example 2 (this is valid syntax, but execution fails on the first assignment because there is no type defined type in BPValue::getValueString):
    test=?;
    test=1;

    I could see where example 2 could be useful to allow syntax where there was an unknown value or even unknown type that was initialized later, for example:

    example 3 (not supported by the parser):
    test=?
    if (test==?)
    test=1;
    else
    test=”string”; // parser error, type already defined
    end if;

    Does anyone understand the history of why this rval “?” is present?

    #5799

    In this discussion, a workaround was shown for how to create an out-of-scope unassigned inst_ref variable. The QMARK seems to be what was put into OAL for this purpose with any type of data variable.

    The problem with inst_ref is the QMARK variable can’t be used inside a select, so a workaround must still be used.
    ref = ?;
    if (true)
    select object instance foo of BAR;
    ref = foo;
    end if;
    if (empty ref)
    end if;

    Verifier should probably support the QMARK. MC-3020 seemed to handle it OK in an experiment I ran.

    In a discussion yesterday, Levi and I surmised that the proper handling of no assignment should be a default value for the type.
    e.g.,
    ref = ?;
    if (false)
    select object instance foo of BAR;
    ref = foo;
    end if;
    ref will be empty here due to no assignment.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.