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

Code import failure on string literals containing tab characters #1151

Closed
codemanyak opened this issue Mar 20, 2024 · 3 comments
Closed

Code import failure on string literals containing tab characters #1151

codemanyak opened this issue Mar 20, 2024 · 3 comments
Assignees
Labels
bug Fixed Implemented (though possibly still not delivered)
Milestone

Comments

@codemanyak
Copy link
Collaborator

codemanyak commented Mar 20, 2024

Java import fails if the source file contains string literals where // occurs as substring:

error.lexical in file "D:\SW-Produkte\Structorizer\tests\Issue1151_Java_import_mystic_error\PHPGenerator_2.java"

Preceding source context:
    1:   public class Test1151 
    2:   {
    3:   
    4:       protected String getInputReplacer(boolean withPrompt)
    5:       {
    6:           return » "$2 = \\$_REQUEST[$1];    // TODO form a sensible input opportunity";

Found token (Error) (")

Expected: 

The same happens if the string literal contains /*, no matter whether or not */ follows within the string literal.
Obviously, the comment detection does not correctly work with the GOLD engine used in Structorizer. Interestingly, the GOLDBuilder successfully parses the very same files using the very same grammar. Hence, it is possible that the Structorizer hack to associate comments to Productions during the parsing is to be blamed for the bug.

@codemanyak codemanyak added the bug label Mar 20, 2024
@codemanyak codemanyak self-assigned this Mar 20, 2024
@codemanyak

This comment was marked as outdated.

@codemanyak codemanyak changed the title Java import failure on string literals containing line comment symbols Code import failure on string literals containing line comment symbols after a tab character Mar 20, 2024
@codemanyak codemanyak changed the title Code import failure on string literals containing line comment symbols after a tab character Code import failure on string literals containing tab characters Mar 20, 2024
@codemanyak
Copy link
Collaborator Author

codemanyak commented Mar 20, 2024

It wasn't the comment symbol at all, but just the occurrence of a tab character in the string literal, that causes the failure. And the code passed the GOLDBuilder only because it automatically replaces the tab characters by blanks on loading the file 😠 .
Hence, it's just the grammars that are to be blamed. Apparently the character set {all_printable} does not include tab as member.

Workaround: Replace tab characters in string literals by \t.

@codemanyak codemanyak added this to the Release 3.33 milestone Mar 20, 2024
@codemanyak
Copy link
Collaborator Author

codemanyak commented Mar 20, 2024

Grammars for Java SE8 and ANSI-C99 now allow tab characters in string literals. Ready for version 3.32-19.

@codemanyak codemanyak added the Fixed Implemented (though possibly still not delivered) label Mar 20, 2024
@fesch fesch closed this as completed in 3a1ec02 Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixed Implemented (though possibly still not delivered)
Projects
None yet
Development

No branches or pull requests

1 participant