-
Notifications
You must be signed in to change notification settings - Fork 739
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
Add a lexer, tests and examples for COBOL #2067
Conversation
The CI fails for 2.7 because of this:
Since it doesn't seem related to my changes, I opened the PR #2068 to fix this. |
lib/rouge/lexers/cobol.rb
Outdated
|
||
# List of COBOL keywords | ||
# sourced from https://www.ibm.com/docs/en/cobol-zos/6.4?topic=appendixes-reserved-words | ||
KEYWORDS = %w[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Could we convert this into a class variable to take advantage of lazy loading? Constants are eagerly loaded when the class is defined, which can slow down startup time. Also, since the collection is rather big, Sets can be more memory-efficient due to their hash-based implementation.
def keywords
@keywords ||= Set.new(%w(ACCEPT ACCESS ...))
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied this, and two of your other suggestions. Hope it is what you meant, Ruby is a relatively new language to me so I had to do some learning about class variables and lazy loading.
Thank you for your work on this PR, @bartbroere 🙇🏼♂️. The changes look good overall. I've left some suggestions. Please let me know what you think 🙏🏼 |
@bartbroere What do you think about 5b32755? I have extracted the keywords, divisions, etc. to class methods and rejig the rule for better performant. |
Thanks for that! I can follow what happens, and if it positively impacts (startup) performance that's even better |
In this PR I add a lexer for COBOL, some tests and an example sourced from a Creative Commons repository.
Hopefully this PR is complete enough. Let me know if I should add or fix some things.
Resolves #1569