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

added: ObjectPascal lexer #883

Merged
merged 13 commits into from
Nov 16, 2023
Merged

added: ObjectPascal lexer #883

merged 13 commits into from
Nov 16, 2023

Conversation

codiacdev
Copy link
Contributor

Initial version (proposal) of an ObjectPascal lexer

  • the assembler state is not in use yet...
  • the Intrinsic Routines rule is commented out and probably not needed...

Initial version (proposal) of an ObjectPascal lexer
- the assembler state is not in use yet...
- the Intrinsic Routines rule is commented out and probably not needed...
@codiacdev
Copy link
Contributor Author

@alecthomas FYI: This is really just a quick proposal. On my machine it works very well and without errors, even on large (45k lines) files but I'm no expert when it comes to regex (performance, etc.) and I just don't have the time to work on that for much longer. Also I don't know how to reevaluate the assembler block with the assembler state or if and how this is even possible so if you should consider to accept the pull request you should probably just delete the assembler state and the commented lines in the file. The same goes for the Intrinsic Routines rule (that would be a bit too much anyway)...

The results of the initial version are absolutely like I would expect them, there is even the brand new Delphi feature of multiline string literals implemented.

Some people (including me) would be very happy to see this in the chroma lexer folder...

@codiacdev codiacdev mentioned this pull request Nov 14, 2023
@alecthomas
Copy link
Owner

Awesome, great start! Can you add one or more test files? See lexers/README.md for details.

@alecthomas
Copy link
Owner

In particular, the test files shouldn't result in any errors.

@codiacdev
Copy link
Contributor Author

@alecthomas I took the testdata from the freepascal repository (https://gitlab.com/freepascal.org/fpc/source).

I actually wanted to create a subfolder in testdata for the objectpascal test files and add the corresponding COPYING file to it, but when I ran the tests with the non-test file present, they unfortunately failed... Maybe this can be changed to fully meet the requirements for using such test data...

@codiacdev
Copy link
Contributor Author

@alecthomas I've gone through everything again, tidied it up and think it's ready now.
What's missing now are a few simple test cases for each rule, but that's beyond my time frame at the moment.
I've tested the lexer extensively against the runtime libraries and I'm pretty sure the lexer is pretty much bug free...
It was fun and I've learned something again...
If you should ever decide to implement a tokenizer for the TextMate grammars (https://macromates.com/manual/en/language_grammars) as well to make chroma the egg-laying jack of all trades, so to speak, I would be happy to contribute to that as well. ;-)

@codiacdev
Copy link
Contributor Author

@alecthomas I've replaced the test data with my own nonsense code that covers most of the rules.

@codiacdev
Copy link
Contributor Author

@alecthomas I've tested everything again and I think that's it now. There is nothing more I can do. I hope the code provided is suitable enough to be merged. If more is needed, please let me know.

@codiacdev
Copy link
Contributor Author

Sorry, there was still a bug....

@codiacdev
Copy link
Contributor Author

It would be nice if there was a special development style for debugging so that all token types could be clearly distinguished in the results output (e.g. html).

@alecthomas
Copy link
Owner

That's not a bad idea. Currently I use chroma -f tokens ... for debugging token issues.

LMK when you're ready to merge.

@codiacdev
Copy link
Contributor Author

I don't see any further issues at the moment, so just do it....

@alecthomas alecthomas merged commit 07a90a9 into alecthomas:master Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants