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

Modula lexer bug #129

Closed
1997tn opened this issue Jan 20, 2023 · 8 comments
Closed

Modula lexer bug #129

1997tn opened this issue Jan 20, 2023 · 8 comments
Labels
committed Issue fixed in repository but not in release modula Caused by the Modula lexer

Comments

@1997tn
Copy link

1997tn commented Jan 20, 2023

MOD is a keyword for modulo on both Modula-2 and Modula-3. The problem is, if MOD is part of another word, e.g: HMOD, it will also highlight MOD like this: HMOD. It should only highlight MOD when it's a standalone word!

@nyamatongwe nyamatongwe added the modula Caused by the Modula lexer label Jan 20, 2023
@nyamatongwe
Copy link
Member

Please add an example file that illustrates the problem.

@1997tn
Copy link
Author

1997tn commented Jan 21, 2023

Please add an example file that illustrates the problem.

No example file needed. Open a new file on any Scintilla based editor (e.g: BowPad, it uses Lexilla). Set the lexer to Modula. Type HMOD into it, you will immediately see it's highlighted as HMOD. Only MOD as a standalone word should be highlighted.

@nyamatongwe
Copy link
Member

An example file is necessary to reproduce and fix the problem and then ensure that the fix is checked against future changes. Moving the onus of producing an example file onto bug fixers makes it more difficult to reproduce the bug and less likely that the bug will be addressed at all.

@1997tn
Copy link
Author

1997tn commented Jan 21, 2023

An example file is necessary to reproduce and fix the problem and then ensure that the fix is checked against future changes. Moving the onus of producing an example file onto bug fixers makes it more difficult to reproduce the bug and less likely that the bug will be addressed at all.

If you so wanted it:

INTERFACE Test;

TYPE
  (* Opaque types *)
  HANDLE    = ADDRESS;
  HMOD      = HANDLE;

END Test.

As I told you, just open a Modula-3 source file (.i3 or .m3) and type HMOD, you will see it's highlighted as HMOD. It's so simple like that, why a sample file is even needed? Always asking for a sample file is an overly too rigid discipline that really doesn't needed at all in this situation 👎

@rdipardo
Copy link
Contributor

This appears to be a trivial fix.

Issue129.zip

The keyword matching loop beginning at line 365 has an empty else branch that should be advancing the position indicator by the length of a whole word:

} else {
/** check procedure identifier */
}

The author's memo here suggests he would've corrected the logic himself given more time.

@nyamatongwe
Copy link
Member

@rdipardo,

The patch appears to Forward 1 too many times as there is a Forward at the loop end. For example, the comment immediately following in this example doesn't get comment style:

  HMOD(* Handle of module *)       = HANDLE;

That doesn't occur just after keywords.

@rdipardo
Copy link
Contributor

The patch appears to Forward 1 too many times as there is a Forward at the loop end.

Preventing an early exit with continue seems to keep the final position within bounds.
This updated set also amends the test case by adding an inline comment.

Issue129-iter-2.zip

@nyamatongwe nyamatongwe added the committed Issue fixed in repository but not in release label Jan 22, 2023
@nyamatongwe
Copy link
Member

Fixed in 5.2.2.

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 modula Caused by the Modula lexer
Projects
None yet
Development

No branches or pull requests

3 participants