2015-10-19 18:22:07 -04:00
|
|
|
# The following sources do not contain the same string literals so that
|
2022-10-23 21:49:13 +02:00
|
|
|
# testcases can check the reparsing actually worked.
|
2015-10-19 18:22:07 -04:00
|
|
|
|
2017-02-24 11:14:54 +01:00
|
|
|
src_buffer_iso_8859_1 = b"""with Ada.Text_IO; use Ada.Text_IO;
|
2015-10-19 18:22:07 -04:00
|
|
|
|
|
|
|
|
procedure Test is
|
|
|
|
|
begin
|
|
|
|
|
Put_Line("H\xe9llo w\xf6rld!");
|
|
|
|
|
end Test;
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
2017-02-24 11:14:54 +01:00
|
|
|
src_buffer_utf_8 = b"""with Ada.Text_IO; use Ada.Text_IO;
|
2015-10-19 18:22:07 -04:00
|
|
|
|
|
|
|
|
procedure Test is
|
|
|
|
|
begin
|
|
|
|
|
Put_Line("H\xc3\xa8llo w\xc3\xb5rld!");
|
|
|
|
|
end Test;
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_string_literal(unit):
|
|
|
|
|
"""
|
2016-04-12 12:46:58 +02:00
|
|
|
Assuming UNIT is one of the above source that is parsed successfuly, return
|
2015-10-19 18:22:07 -04:00
|
|
|
the text associated to the string literal in the Put_Line call.
|
|
|
|
|
"""
|
|
|
|
|
node = unit.root
|
2016-04-29 12:54:23 +02:00
|
|
|
subp = node.f_body.f_item
|
2016-11-04 11:34:19 +01:00
|
|
|
call = subp.f_stmts.f_stmts[0]
|
2017-02-14 14:37:41 +01:00
|
|
|
str_lit = call.f_call.f_suffix[0].f_r_expr
|
2018-01-24 13:50:26 +01:00
|
|
|
return str_lit.text
|