Author: Stan Eisenstat
Subject: Re: Question about escape and line splices
Date: Wednesday, 29 Jan 2020, 06:59:01
> Hi, my name is XXXXXX, and I am in your CS223 class. I just wanted to > clarify the use of escape characters and line splices in the following > cases. When multiple backslashes are inside a string, I get confused > what the logic is. The easiest way to answer questions like this is to run the staff solution, but to ask when the results are not what you expect. ===== > Case 1: > "example\\ > \ > \ > "end" After the three line splices are removed, the input is "example\"end" which is a string. Thus Cxref outputs nothing. ===== > Case 2: > "example\\ > \ > \ > \"end" After the three line splices are removed, the input is "example\\"end" which is a string followed by the identifier end and an unmatched double quote (which means that the input is not a legitimate C program and the only requirement is to fail gracefully). Nonetheless, Hwk1/Cxref outputs end:4 and then ignores the unterminated string. ===== > Case 3: > "example > \ > \ > \"end" After the two line splices are removed, the input is "example \"end" which begins with an unterminated string (since strings may not contain newlines) and is not a legitimate C program. Since Hwk1/Cxref allows newlines in strings, it treats the entire input as a string and outputs nothing. Best, --Stan-PREV INDEX NEXT