import re


def GetPatternLineFromHlslLine(line):
    """
    Returns a string, with the pattern version of the input string.
    Example:
    The following HLSL line produced by AZSLc:
        float2 samplePos = ::PassSrg_GetSamplePosition ( IN . m_sampleIndex ) ;
    Will become like this when converted to pattern line as required by testhelper.verifyEmissionPattern():
        "float2 samplePos = :: PassSrg_GetSamplePosition ( IN . m_sampleIndex ) ;"
    The '"' characters are also included in the returned string, which is required
    by testhelper.verifyEmissionPattern().
    """
    line = line.rstrip("\r\n")
    if line == "":
        return None
    allidents = re.split("([a-zA-Z_]+[a-zA-Z_0-9]*)|(;)|(\()|(\))|(<)|(>)|( )", line)
    allidents = filter(lambda s: s is not None and s!="" and s!=" ", allidents)  # remove empties from ['', 'code', '', 'piece']...
    line = " ".join(allidents)
    return f"\"{line}\""