Riverside-Software/sonar-openedge

Quotes in include file argument

Opened this issue · 2 comments

Copied from vscode-abl/vscode-abl#208

DefaultValue.i:

DEFINE VARIABLE MyChar AS CHARACTER NO-UNDO.

ASSIGN MyChar = {&DefaultValue}.

UseDefaultValue.p:

{DefaultValue.i &DefaultValue=""-""}

Precompiles to the expected/wanted:

DEFINE VARIABLE MyChar AS CHARACTER NO-UNDO.

ASSIGN MyChar = "-".

But causes:

[2024-09-10T11:36:45.260+0200] [ERROR] [Glims] Proparse error on 'preprocessor\UseDefaultValue.p'
org.prorefactor.core.ProparseRuntimeException: :2 Unmatched quote
	at org.prorefactor.proparse.Lexer.lexicalThrow(Lexer.java:1402)
	at org.prorefactor.proparse.Lexer.quotedString(Lexer.java:605)
	at org.prorefactor.proparse.Lexer.nextTokenFromQuote(Lexer.java:334)
	at org.prorefactor.proparse.Lexer.nextToken(Lexer.java:227)
	at org.prorefactor.proparse.PostLexer.getNextToken(PostLexer.java:122)
	at org.prorefactor.proparse.PostLexer.nextToken(PostLexer.java:71)
	at org.prorefactor.proparse.ProparseSkipFilter.nextToken(ProparseSkipFilter.java:46)
	at org.prorefactor.proparse.NameDotTokenFilter.fillHeap(NameDotTokenFilter.java:54)
	at org.prorefactor.proparse.NameDotTokenFilter.nextToken(NameDotTokenFilter.java:152)
	at org.prorefactor.proparse.TokenList.fillHeap(TokenList.java:48)
	at org.prorefactor.proparse.TokenList.nextToken(TokenList.java:139)
	at org.prorefactor.proparse.FunctionKeywordTokenFilter.nextToken(FunctionKeywordTokenFilter.java:57)
	at org.prorefactor.proparse.ABLLexer.nextToken(ABLLexer.java:135)
	at org.antlr.v4.runtime.BufferedTokenStream.fetch(BufferedTokenStream.java:169)
	at org.antlr.v4.runtime.BufferedTokenStream.sync(BufferedTokenStream.java:152)
	at org.antlr.v4.runtime.BufferedTokenStream.consume(BufferedTokenStream.java:136)
	at org.antlr.v4.runtime.Parser.consume(Parser.java:571)
	at org.antlr.v4.runtime.Parser.match(Parser.java:205)
	at org.prorefactor.proparse.antlr4.Proparse.statementEnd(Proparse.java:63772)
	at org.prorefactor.proparse.antlr4.Proparse.defineVariableStatement(Proparse.java:37689)
	at org.prorefactor.proparse.antlr4.Proparse.statement(Proparse.java:3815)
	at org.prorefactor.proparse.antlr4.Proparse.blockOrStatement(Proparse.java:1604)
	at org.prorefactor.proparse.antlr4.Proparse.program(Proparse.java:1440)
	at org.prorefactor.treeparser.ParseUnit.parse(ParseUnit.java:340)
	at org.prorefactor.treeparser.ParseUnit.parse(ParseUnit.java:309)
	at org.prorefactor.treeparser.ParseUnit.treeParser01(ParseUnit.java:402)
	at eu.rssw.openedge.ls.builder.y.a(SourceFile:39)
	at eu.rssw.openedge.ls.builder.y.apply(SourceFile:26)
	at java.base/java.util.concurrent.CompletableFuture.uniApplyNow(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture.uniApplyStage(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture.thenApply(Unknown Source)
	at eu.rssw.openedge.ls.builder.x.run(SourceFile:160)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
[2024-09-10T11:36:45.260+0200] [INFO] [Glims] Compilation successful: preprocessor\UseDefaultValue.p

The file compiles and preprocesses fine.

Documentation on using double quotes in include file parameters is not clear to me:
"If you use double quotes (" ") around arguments in an argument list, ABL removes them. However, if you use single quotes (' '), ABL passes them. To pass one set of double quotes, you must use four sets of double quotes."
https://documentation.progress.com/output/ua/OpenEdge_latest/pdsoe/PLUGINS_ROOT/com.openedge.pdt.langref.help/rfi1424919802847.html

But both
{DefaultValue.i &DefaultValue=""-""}
and
{DefaultValue.i &DefaultValue="""-"""}
result in the expected outcome of "-" in the preprocessed file, while using 4 double quotes does not compile...
Using 1 double quote ({DefaultValue.i &DefaultValue="-"}) results in

DEFINE VARIABLE MyChar AS CHARACTER NO-UNDO.

ASSIGN MyChar = -.

The Proparse exception can be prevented by using """-""" apparently, but should this be needed?
Single quotes are also an option of course...
Is this a Proparse bug, or Progress being to relaxed about the input (as it is clearly not following its own documentation).

AFAIK triple quotes are required, not just for proparse, but also for the openedge compile.
could be specific to some of our include files

I've only encountered a single source in our source set using the above, so I guess we can adjust it to use triple double quotes (and not 4 like the documentation hints to...)