Skip to content

[BUG] Escaped characters and addition of multiple lines in a string give compilation errors #11

Open
@Efratror

Description

@Efratror

Bug:

code like:

String s = "\n";
String s= "\"";

println("X" +
"X");

Give compilation errors due to the fact the quotation character is replaced with multiple escaped characters ("\"")

export function mapperPipeline(newUnProcessedText: String): string{
let localUnProcessedText = newUnProcessedText.replace(/([0-9]+\.[0-9]+)/g,'$1f')
conversionTuples.forEach(function(tuple){
localUnProcessedText = localUnProcessedText.replace(tuple[0],tuple[1])
})
localUnProcessedText = localUnProcessedText.replace(preprocessing.singleLineComment,``)
// localUnProcessedText = localUnProcessedText.replace(/[\']{1}/g,"\\\'")
localUnProcessedText = localUnProcessedText.replace(/[\"]{1}/g,"\\\"")
return localUnProcessedText
}

Possible Solution

I think the problem lies at the method to create the java file:

try{
childProcess.execSync(`echo \"${processedText}\" > ${__dirname}/compile/${pStandards.defaultClassName}.java`)
log.writeLog(`Java File creation successful`)
} catch(e) {
log.writeLog(`[[ERR]] - Error in Java File Creation`)
}
It now uses an echo command to create the file. If instead a method like fs.writeFileSync() is used there is no need for escaping quotation characters to write the java file. All characters should be written to the file "as is".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions