Commit aa81a087 authored by Maxime Perrotin's avatar Maxime Perrotin

Generate proper code when write[ln] arguments includes newlines

parent df3e57d0
......@@ -139,6 +139,7 @@ Changelog
- Relax range check for substrings
- Save/restore windows geometry when quitting/opening the tool
- Make datatypes fully visible in the data dictionary window
- write[ln] operator now supports embedded newlines
2.0.33 (04/2019)
- Fix unicode issue in Ada backend when using substrings
......
......@@ -61,7 +61,7 @@
this pattern is straightforward, once the generate function for each AST
entry is properly implemented).
Copyright (c) 2012-2013 European Space Agency
Copyright (c) 2012-2019 European Space Agency
Designed and implemented by Maxime Perrotin
......@@ -1186,8 +1186,12 @@ def write_statement(param, newline):
elif type_kind.endswith('StringType'):
if isinstance(param, ogAST.PrimStringLiteral):
# Raw string
code.append(u'Put("{}");'
.format(param.value[1:-1].replace('"', "'")))
# First remove the newline statements
text = param.value[1:-1].replace('"', "'").split('\n')
for idx, val in enumerate(text):
code.append(u'Put("{}");'.format(val))
if len(text) > 1 and idx < len(text) - 1:
code.append(u'New_Line;')
else:
code, string, local = expression(param, readonly=1)
if type_kind == 'OctetStringType':
......
......@@ -33,6 +33,21 @@ system og;
dcl test Some_Thing := 4;
/* CIF ENDTEXT */
/* CIF procedure (430, 404), (78, 35) */
procedure enum1
/* CIF comment (528, 404), (206, 35) */
comment 'same name as an enum item';
endprocedure;
/* CIF procedure (414, 353), (124, 35) */
procedure default_seqof
/* CIF comment (558, 353), (189, 35) */
comment 'same name as a constant';
endprocedure;
/* CIF procedure (439, 309), (70, 35) */
procedure haha
/* CIF comment (529, 309), (184, 35) */
comment 'same name as a variable';
endprocedure;
/* CIF procedure (404, 228), (73, 35) */
procedure aProc;
/* CIF TEXT (542, 127), (287, 140) */
......@@ -49,24 +64,12 @@ system og;
/* CIF return (181, 263), (35, 35) */
return ;
endprocedure;
/* CIF procedure (439, 309), (70, 35) */
procedure haha
/* CIF comment (529, 309), (184, 35) */
comment 'same name as a variable';
endprocedure;
/* CIF procedure (414, 353), (124, 35) */
procedure default_seqof
/* CIF comment (558, 353), (189, 35) */
comment 'same name as a constant';
endprocedure;
/* CIF procedure (430, 404), (78, 35) */
procedure enum1
/* CIF comment (528, 404), (206, 35) */
comment 'same name as an enum item';
endprocedure;
/* CIF START (155, 216), (70, 35) */
START;
/* CIF NEXTSTATE (155, 266), (70, 35) */
/* CIF PROCEDURECALL (135, 271), (109, 38) */
call writeln('hello
world');
/* CIF NEXTSTATE (155, 327), (70, 35) */
NEXTSTATE wait;
/* CIF state (296, 231), (70, 35) */
state wait;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment