Skip to content

Add APDL lexer for ANSYS parametric design language#2199

Open
mrjanczak wants to merge 1 commit intorouge-ruby:masterfrom
mrjanczak:master
Open

Add APDL lexer for ANSYS parametric design language#2199
mrjanczak wants to merge 1 commit intorouge-ruby:masterfrom
mrjanczak:master

Conversation

@mrjanczak
Copy link

Added a new lexer for ANSYS Parametric Design Language (APDL) converted from pygments apdllexer.py.

Added a new lexer for ANSYS Parametric Design Language (APDL) converted from pygments apdllexer.py.
@mrjanczak
Copy link
Author

Existing APDL lexers:

pygments.org

Copy link
Member

@jneen jneen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the lexer! I've left a few comments - I think other than a few pygments-style things that we (try to) do a bit differently here this looks good.


KEYWORD_RE = Regexp.new('\\b(?:' + (ELAFUNB + ELAFUNC + ELAFUND + ELAFUNE + ELAFUNH + SPECIAL).map { |s| Regexp.escape(s) }.join('|') + ')\\b', Regexp::IGNORECASE)
BUILTIN_RE = Regexp.new('\\b(?:' + (ELAFUNF + ELAFUNG).map { |s| Regexp.escape(s) }.join('|') + ')\\b', Regexp::IGNORECASE)
ELEMENTS_RE = Regexp.new('\\b(?:' + ELEMENTS.map { |s| Regexp.escape(s) }.join('|') + ')\\b', Regexp::IGNORECASE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We see this pattern quite a bit in lexers ported from Pygments, but we tend to try and avoid massive regular expressions like this in Rouge lexers. The C lexer is a decent example of how we prefer to do it - match a generic name, and check for inclusion in a class-level Set.

TSHAP /TSPEC TSRES TUNIF TVAR /TXTRE /TYPE TYPE /UCMD /UDOC /UI UIMP /UIS *ULIB /UPF UNDELETE UNDO /UNITS
UNPAUSE UPCOORD UPGEOM *USE /USER USRCAL USRDOF USRELEM V V2DOPT VA *VABS VADD VARDEL VARNAM VATT VCLEAR
*VCOL /VCONE VCROSS *VCUM VDDAM VDELE VDGL VDOT VDRAG *VEC *VEDIT VEORIENT VEXT *VFACT *VFILL VFOPT VFQUERY
VFSM *VFUN VGEN *VGET VGET VGLUE /VIEW VIMP VINP VINV *VITRP *VLEN VLIST VLSCALE *VMASK VMESH VOFFST VOLUMES
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For keyword lists of this size, it is worth having them lazily loaded, and ideally generated from documentation rather than manually maintained, similar to how it's done for the Lua and PHP lexers, among others. Is there a stable URL for documentation that we might parse? For this it might make sense to wait until #2202 drops though, since both the lazy-loading and keyword generators are undergoing a bit of an overhaul.

@mrjanczak mrjanczak requested a review from jneen February 3, 2026 23:10
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