String.cta

string_backslash:
    if_unstarted:
        match /\\\\.$/
        stop
        halt.all
        this:handleStringBackslash
string_instructions:
    if_unstarted:
        rewind 1
        buffer.clear
        forward 1
        then :string_backslash
    if_started:
        this:handleString
        rewind 1
        directive.pop
string_single_stop:
    if_unstarted:
        this:handleString
        rewind 1
        directive.pop
string_single:
    if_unstarted:
        match /^'$/
        inherit :string_instructions.start
        :string_single_stop
    if_started:
        match '
        buffer.clear
string_double_stop:
    if_unstarted:
        buffer.ends_with "
        buffer.clear
string_double:
    if_unstarted:
        match /^"$/
        inherit :string_instructions.start
        :string_double_stop
    if_started:
        buffer.match "
        buffer.clear
heredoc:
    if_unstarted:
        buffer.match <<<
        :heredoc_key
    if_started:
        buffer.rewind 1
        stop
heredoc_key:
    if_unstarted:
        match /\'?([a-zA-Z\_0-9]+)\'?[^a-zA-Z0-9_]/
        rewind 1
        previous.set heredoc_key $1
    if_started:
        buffer.match !previous.get heredoc_key
        previous.set string
        buffer.clear
        directive.pop