-
Notifications
You must be signed in to change notification settings - Fork 67
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
Test files for LexPascal and some issue with TestLexers #295
Comments
This indicates a bug in the lexer with its handling of 'asm' sections. The first run, with no .styled file, will produce a .styled.new file but will only perform limited tests as there is no current .styled file to compare to. When the .styled.new file is copied to .styled, then TestLexers has (hopefully) correct style data that it will test in more ways. Lexing is incremental: that is if you modify line 100 of the file then the first 99 lines do not have to be processed again - just from the change to the bottom of the window. A common type of lexer bug is for the lexer to not completely recreate its state at the position its been asked to start at, perhaps forgetting it is in (or out of) 'asm' sections. To check for these problems, TestLexers runs the lexer once over the whole file then once lexing each line individually and reports any difference. Another cause of problems is with Windows versus Unix line endings '\r\n' versus '\n' as lexer authors commonly only use one operating system and only test for the line ends they use. This looks like the case here: there appears to be different behaviour when the file has '\n' line ends (as it was downloaded) with 'asm' sections not terminating at the 'end'. This can be reproduced interactively with
The problem is likely to be with remembering the |
The bug can be fixed by move @@ -225,18 +225,14 @@ static void ColourisePascalDoc(Sci_PositionU startPos, Sci_Position length, int
CharacterSet setHexNumber(CharacterSet::setDigits, "abcdefABCDEF");
CharacterSet setOperator(CharacterSet::setNone, "#$&'()*+,-./:;<=>@[]^{}");
- Sci_Position curLine = styler.GetLine(startPos);
- int curLineState = curLine > 0 ? styler.GetLineState(curLine - 1) : 0;
+ int curLineState = 0;
StyleContext sc(startPos, length, initStyle, styler);
+ if (sc.currentLine > 0) {
+ curLineState = styler.GetLineState(sc.currentLine - 1);
+ }
for (; sc.More(); sc.Forward()) {
- if (sc.atLineEnd) {
- // Update the line state, so it can be seen by next line
- curLine = styler.GetLine(sc.currentPos);
- styler.SetLineState(curLine, curLineState);
- }
-
// Determine if the current state should terminate.
switch (sc.state) {
case SCE_PAS_NUMBER:
@@ -335,6 +331,11 @@ static void ColourisePascalDoc(Sci_PositionU startPos, Sci_Position length, int
sc.SetState(SCE_PAS_ASM);
}
}
+
+ if (sc.atLineEnd) {
+ // Update the line state, so it can be seen by next line
+ styler.SetLineState(sc.currentLine, curLineState);
+ }
}
if (sc.state == SCE_PAS_IDENTIFIER && setWord.Contains(sc.chPrev)) {
|
My assumption was, on every run same tests are executed. Thanks for that excellent research and explanation. As I can see, patch is already existing. Thanks and br HoTschir |
There appears to be 3 identical sections in Some other lexers track the preprocessor state and can style inactive code in a distinctive way. The duplication might be useful for such a lexer but the Pascal lexer does not support this feature so it would be better to remove the copies from this test file. |
AllStyles.pas was already prepared for a feature enhancement to LexPascal, where inactive preprocessor block is styled differently than active block. Attached a correction patch to remove 2 sections. |
Add test files for Pascal from HoTschir.
Hi,
attached a patch, which includes test files for LexPascal lexer.
It will add following files:
There is some issue while testing, how to explain?
Testing with attached files will fail the LexPascal. But there is strange behavior, because resulted style file is o.k. for the first run, when AllStyles.pas.styled does not exist yet, but different for all other runs, when AllStyles.pas.styled.new is renamed to AllStyles.pas.styled. Accordingly for other files SCE_PAS_ASM comes into use.
How you can verify the issue:
you will see among other things following diff:
which is correct!
So only that code styling is correct, if no *.styled (without .new) file exist.
I'm not sure, the problem is located in TestLexers?
br
HoTschir
lexilla.devLexPascal.ufjn2a7iroa1j70j.patch.zip
The text was updated successfully, but these errors were encountered: