def unscalar_lex(arg):
    """Lexically unwraps a string containing a string or numeric constant,
    such as are created by the PyTT parser.

    If the argument (presumed to be a string) starts with the string "scalar("
    and ends with the string ")", evaluates and returns the portion of the
    argument between those strings; otherwise just returns the argument.
    """
    if arg.startswith("scalar(") and arg.endswith(")"):
        return eval(arg[7:-1])
    else:
        return arg