bblfsh / python-driver

GNU General Public License v3.0
10 stars 16 forks source link

annotated: quotes are not preserved #195

Open bzz opened 5 years ago

bzz commented 5 years ago

Discovered in https://github.com/bblfsh/javascript-driver/pull/81#issuecomment-481845021 and as noted at https://github.com/bblfsh/javascript-driver/pull/81#issuecomment-481852636 - this driver does not handle string literals in annotated mode the same way as other drivers do: it does not preserve the " and ' as part of the literal value in annotated mode.

On

bc = "b\nc"
bcq = 'b\ncq'

Actual

//*[@role='String' and @role='Literal'] XPath query results in

"@token":"b\nc","@type":"Str"
"@token":"b\ncq","@type":"Str"

Expected

For annotated mode, @token values should be:

'b\\ncq'
\"b\\ncq\"
creachadair commented 5 years ago

Other test cases to consider while we're looking at this code: ''' and """ and their variants (e.g., r''', u""", etc.)