Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Efratror opened this issue Mar 21, 2022 · 0 comments · May be fixed by #18
Open

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

Efratror opened this issue Mar 21, 2022 · 0 comments · May be fixed by #18

Comments

@Efratror
Copy link

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".

@Efratror Efratror changed the title Escaped characters and addition of multiple lines in a string give compilation errors [BUG] Escaped characters and addition of multiple lines in a string give compilation errors Mar 21, 2022
@Efratror Efratror linked a pull request Mar 22, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant