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

Upgrading APDL lexer #2314

Merged
merged 5 commits into from
Jan 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 14 additions & 9 deletions pygments/lexers/apdlexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from pygments.lexer import RegexLexer, include, words
from pygments.token import Comment, Keyword, Name, Number, Operator, \
String, Generic, Punctuation, Whitespace
String, Generic, Punctuation, Whitespace, Escape

__all__ = ['apdlexer']

Expand Down Expand Up @@ -144,7 +144,7 @@ class apdlexer(RegexLexer):
"CMDELE", "CMDOMEGA", "CMEDIT", "CMGRP", "CMLIST",
"CMMOD", "CMOMEGA", "CMPLOT", "CMROTATE", "CMSEL",
"CMSFILE", "CMSOPT", "CMWRITE", "CNCHECK", "CNKMOD",
"CNTR", "CNVTOL", "/COLOR", "/COM", "*COMP", "COMBINE",
"CNTR", "CNVTOL", "/COLOR", "*COMP", "COMBINE",
"COMPRESS", "CON4", "CONE", "/CONFIG", "CONJUG",
"/CONTOUR", "/COPY", "CORIOLIS", "COUPLE", "COVAL",
"CP", "CPCYC", "CPDELE", "CPINTF", "/CPLANE", "CPLGEN",
Expand All @@ -158,7 +158,7 @@ class apdlexer(RegexLexer):
"DADELE", "DALIST", "DAMORPH", "DATA", "DATADEF",
"DCGOMG", "DCUM", "DCVSWP", "DDASPEC", "DDELE",
"DDOPTION", "DEACT", "DEFINE", "*DEL", "DELETE",
"/DELETE", "DELTIM", "DEMORPH", "DERIV", "DESIZE",
"/DELETE", "DELTIM", "DELTIME", "DEMORPH", "DERIV", "DESIZE",
"DESOL", "DETAB", "/DEVDISP", "/DEVICE", "/DFLAB",
"DFLX", "DFSWAVE", "DIG", "DIGIT", "*DIM",
"/DIRECTORY", "DISPLAY", "/DIST", "DJ", "DJDELE",
Expand Down Expand Up @@ -350,7 +350,7 @@ class apdlexer(RegexLexer):
"SSBT", "/SSCALE", "SSLN", "SSMT", "SSPA", "SSPB",
"SSPD", "SSPE", "SSPM", "SSUM", "SSTATE", "STABILIZE",
"STAOPT", "STAT", "*STATUS", "/STATUS", "STEF",
"/STITLE", "STORE", "SUBOPT", "SUBSET", "SUCALC",
"STORE", "SUBOPT", "SUBSET", "SUCALC",
"SUCR", "SUDEL", "SUEVAL", "SUGET", "SUMAP", "SUMTYPE",
"SUPL", "SUPR", "SURESU", "SUSAVE", "SUSEL", "SUVECT",
"SV", "SVPLOT", "SVTYP", "SWADD", "SWDEL", "SWGEN",
Expand All @@ -359,13 +359,13 @@ class apdlexer(RegexLexer):
"TBEO", "TBIN", "TBFIELD", "TBFT", "TBLE", "TBLIST",
"TBMODIF", "TBPLOT", "TBPT", "TBTEMP", "TCHG", "/TEE",
"TERM", "THEXPAND", "THOPT", "TIFF", "TIME",
"TIMERANGE", "TIMINT", "TIMP", "TINTP", "/TITLE",
"TIMERANGE", "TIMINT", "TIMP", "TINTP",
"/TLABEL", "TOFFST", "*TOPER", "TORQ2D", "TORQC2D",
"TORQSUM", "TORUS", "TRANS", "TRANSFER", "*TREAD",
"TREF", "/TRIAD", "/TRLCY", "TRNOPT", "TRPDEL",
"TRPLIS", "TRPOIN", "TRTIME", "TSHAP", "/TSPEC",
"TSRES", "TUNIF", "TVAR", "/TXTRE", "/TYPE", "TYPE",
"/UCMD", "/UDOC", "/UI", "UIMP", "/UIS", "*ULIB",
"/UCMD", "/UDOC", "/UI", "UIMP", "/UIS", "*ULIB", "/UPF",
"UNDELETE", "UNDO", "/UNITS", "UNPAUSE", "UPCOORD",
"UPGEOM", "*USE", "/USER", "USRCAL", "USRDOF",
"USRELEM", "V", "V2DOPT", "VA", "*VABS", "VADD",
Expand Down Expand Up @@ -416,14 +416,19 @@ class apdlexer(RegexLexer):
"/ANNOT", "ANORM", "ANPRES", "ANSOL", "ANSTOAQWA",
"ANSTOASAS", "ANTIME", "ANTYPE")

special_ = ("/COM", "/TITLE", "STITLE")
germa89 marked this conversation as resolved.
Show resolved Hide resolved

tokens = {
'root': [
(r'!.*\n', Comment),
# (r'/com.*\n', Comment),
germa89 marked this conversation as resolved.
Show resolved Hide resolved
(r'%.*%', Escape),
include('strings'),
include('core'),
include('nums'),
(words((elafunb+elafunc+elafund+elafune+elafunh), suffix=r'\b'), Keyword),
(words((elafunb+elafunc+elafund+elafune+elafunh), suffix=r'\b', prefix=r'\s*'), Keyword),
germa89 marked this conversation as resolved.
Show resolved Hide resolved
(words((special_), prefix=r'\s*', suffix=r'\b'), Keyword),
germa89 marked this conversation as resolved.
Show resolved Hide resolved
(words((elafunf+elafung), suffix=r'\b'), Name.Builtin),
include('core'),
(r'AR[0-9]+', Name.Variable.Instance),
(r'[a-z][a-z0-9_]*', Name.Variable),
(r'[\s]+', Whitespace),
Expand All @@ -432,7 +437,7 @@ class apdlexer(RegexLexer):
# Operators
(r'(\*\*|\*|\+|-|\/|<|>|<=|>=|==|\/=|=)', Operator),
(r'/EOF', Generic.Emph),
(r'[(),:&;]', Punctuation),
(r'[\.(),:&;]', Punctuation),
],
'strings': [
(r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
Expand Down