Preprocessor enhancement

0 votes
asked Nov 22, 2016 in Wanted features by Serge Wenger Work (4,850 points)
Hello,
I do a lot of test with version 8049 and !define and I see some possible enhancement:
 
1) !endif and !else don't like spaces. It is possible to correct it in ifManager.java line 43
protected static final Pattern2 elsePattern = MyPattern.cmpile("^[%s]*!else[%s]*$");
protected static final Pattern2 endifPattern = MyPattern.cmpile("^[%s]*!endif[%s]*$");
 
2) !else, !definelong and !enddefinelong are not defined in language description
LanguageDescriptor.java line 143
preproc.add("!else");
preproc.add("!definelong");
preproc.add("!enddefinelong");
 
3) ifndef is not described in the documentation
 
4) It would be nice to have a !define with the file format output type
For example in Option.java line 84:
public void setFileFormat(FileFormat fileFormat) {
this.fileFormat = fileFormat;
String s = "FILE_FORMAT_" + fileFormat.toString() +"=\"1\"";
manageDefine(s);
}
 
public Option(String... arg) throws InterruptedException, IOException {
if (arg.length == 0) {
OptionFlags.getInstance().setGui(true);
setFileFormat(FileFormat.PNG);
}

1 Answer

0 votes
answered Nov 23, 2016 by plantuml (131,770 points)
selected Nov 24, 2016 by Serge Wenger Work
 
Best answer

Thanks for your contribution. Points 1,2 and 3 are ok. (integrated in last beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar )

About point 4, we have an issue.

We understand the point and the interest of this suggestion.

However in some cases the diagram can be parsed before knowing which format is going to be used for export (depending how you integrate PlantUML). So we have to think about this.

Thanks again

commented Nov 24, 2016 by Serge Wenger Work (4,850 points)
Thanks for points 1) to 3). I check, it is OK.

I try a workaround with the option -DFILE_FORMAT_PNG=value but it seem not working:

java.exe -jar plantuml.8051Beta3.jar -DFILE_FORMAT_PNG=1 TestDefine2.txt

TestDefine2.txt:
@startuml
!ifdef FILE_FORMAT_PNG
Alice -> Bob: png
!else
Alice -> Bob: svg
!endif
@enduml
commented Nov 24, 2016 by plantuml (131,770 points)
Yes, this is a good workaround.

Sorry, there is a bug in 8051beta3 (underscore badly managed in !ifdef, due to new || && implementation).

You can either download 8051beta4 https://dl.dropboxusercontent.com/u/13064071/plantuml.jar that fixes that issue, or use FILEFORMATPNG as variable name with beta3).
commented Nov 24, 2016 by Serge Wenger Work (4,850 points)
8051beta4  is OK. Thanks
commented Dec 2, 2016 by Serge Wenger Work (4,850 points)
Hello,

It is OK with command line, but not with -gui. Sorry.
commented Dec 2, 2016 by plantuml (131,770 points)
Thanks for the report.
Should be ok with last beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar
(Not highly tested)
...