Add APDL lexer for ANSYS parametric design language#2199
Add APDL lexer for ANSYS parametric design language#2199mrjanczak wants to merge 1 commit intorouge-ruby:masterfrom
Conversation
Added a new lexer for ANSYS Parametric Design Language (APDL) converted from pygments apdllexer.py.
|
Existing APDL lexers: |
jneen
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Added a new lexer for ANSYS Parametric Design Language (APDL) converted from pygments apdllexer.py.