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

Visual Prolog: multiple cases of different styles between \r and \n #83

Closed
rdipardo opened this issue May 17, 2022 · 5 comments
Closed
Labels
committed Issue fixed in repository but not in release prolog Caused by the visual prolog lexer

Comments

@rdipardo
Copy link
Contributor

rdipardo commented May 17, 2022

Similar to #57, testing LexVisualProlog found mixed styles at CRLF line ends wherever StyleContext::atLineEnd is used to find newlines:

~/../AllStyles.pro: 1: different styles between \r and \n at   33: 5, 0
~/../AllStyles.pro: 4: different styles between \r and \n at   75: 5, 0
~/../AllStyles.pro: 7: different styles between \r and \n at  126: 5, 0
~/../AllStyles.pro:10: different styles between \r and \n at  176: 5, 0
~/../AllStyles.pro:25: different styles between \r and \n at  561: 5, 0
~/../AllStyles.pro:26: different styles between \r and \n at  572: 5, 0
~/../AllStyles.pro:27: different styles between \r and \n at  584: 5, 0
~/../AllStyles.pro:29: different styles between \r and \n at  618: 5, 0
~/../AllStyles.pro:33: different styles between \r and \n at  679: 5, 0
~/../AllStyles.pro:36: different styles between \r and \n at  732: 5, 0
~/../AllStyles.pro:39: different styles between \r and \n at  781: 5, 0
~/../AllStyles.pro:40: different styles between \r and \n at  795: 16, 19
~/../AllStyles.pro:42: different styles between \r and \n at  838: 5, 0
~/../AllStyles.pro:45: different styles between \r and \n at  909: 5, 0
~/../AllStyles.pro:48: different styles between \r and \n at  988: 5, 0
~/../AllStyles.pro:49: different styles between \r and \n at 1002: 20, 22
~/../AllStyles.pro:50: different styles between \r and \n at 1014: 20, 22

Namely:

  • line comment style (id 5) ends mid-EOL:

sce_visualprolog_comment_line

  • an error indicator style for unterminated string literals (SCE_VISUALPROLOG_STRING_EOL_OPEN [id 19]), is applied too late:

sce_visualprolog_string_eol_open

  • a line continuation indicator style for multi-line verbatim strings (SCE_VISUALPROLOG_STRING_VERBATIM_EOL [id 22]), is also applied too late:

sce_visualprolog_verbatim_eol

Here are the test cases that currently raise the diagnostics: visualprolog.zip

Note that style ids 13, 14 and 15 are not implemented:

git grep -E "SCE_VISUALPROLOG_CHARACTER(|_TOO_MANY|_ESCAPE_ERROR)" -- *.cxx

echo $?
1

This patch fixes the EOL splitting: 0001-LexVisualProlog-Prefer-MatchLineEnd-to-atLineEnd.diff.txt

@rdipardo
Copy link
Contributor Author

[Correction]: all the faulty state changes including line comments are caused by late detection of DOS EOLs

@nyamatongwe nyamatongwe added the prolog Caused by the visual prolog lexer label May 17, 2022
@nyamatongwe
Copy link
Member

Note that style ids 13, 14 and 15 are not implemented

Character and string literals only differ in there being a single character between the quotes for a SCE_VISUALPROLOG_CHARACTER character literal. Thus SCE_VISUALPROLOG_CHARACTER_TOO_MANY doesn't seem to make sense.

https://wiki.visual-prolog.com/index.php?title=Language_Reference/Lexical_Elements#Character_Literals

@rdipardo
Copy link
Contributor Author

Character and string literals only differ in there being a single character between the quotes for a SCE_VISUALPROLOG_CHARACTER character literal.

Perhaps the unrealized intention was to enforce a pedantic limit on the length of isolated escape characters or UTF-8 codepoints.

You may also notice the proposed test cases don't iterate every possible combination of verbatim string delimiter.
I figure the behaviour under test is what happens after a style's case label is reached, not the domain-specific logic that leads control to there.

@nyamatongwe
Copy link
Member

0001-LexVisualProlog-Prefer-MatchLineEnd-to-atLineEnd.diff.txt seems fine but Lexilla is in release freeze so will be looked at after release.

I meant AllStyles.* to have examples of all styles as it is sometimes difficult to work out the purposes of styles. Exhaustive coverage of cases (or paths in the code) is a lot more work so hasn't been a priority.

nyamatongwe pushed a commit that referenced this issue May 27, 2022
@nyamatongwe
Copy link
Member

Committed with addition of Unicode escape example '\uAB12'.

@nyamatongwe nyamatongwe added the committed Issue fixed in repository but not in release label Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
committed Issue fixed in repository but not in release prolog Caused by the visual prolog lexer
Projects
None yet
Development

No branches or pull requests

2 participants