Skip to content

Commit

Permalink
Syntax overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
vrognas committed Sep 4, 2024
1 parent d068478 commit fa3a67f
Showing 1 changed file with 149 additions and 44 deletions.
193 changes: 149 additions & 44 deletions syntaxes/nmtran.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,96 @@
"name": "NMTRAN",
"scopeName": "source.nmtran",
"patterns": [
{ "include": "#verbatim" },
{ "include": "#comments" },
{ "include": "#numericals" },
{ "include": "#constants" },
{ "include": "#control-records" },
{ "include": "#control-record-options" },
{ "include": "#control-record-syntax" },
{ "include": "#parameters" },
{ "include": "#reserved" },
{ "include": "#operators" }
],
"repository": {
"verbatim": {
"patterns": [{
"comment": "Verbatim FORTRAN code",
"name": "markup.raw.verbatim.nmtran",
"match": "^\".*$"
}]
},
"comments": {
"patterns": [{
"name": "comment.line.nmtran",
"name": "comment.line.semicolon.nmtran",
"match": ";.*$"
}]
},
"numericals": {
"constants": {
"patterns": [{
"comment": "numbers",
"name": "constant.numeric.nmtran",
"match": "-?\\d+"
},
{
"comment": "Special constants",
"name": "constant.language.special.nmtran",
"match": "(?i:\\b(TRUE|FALSE|NULL|\\-Inf|Inf)\\b)"
}]
},
"control-records": {
"patterns": [{
"name": "string.nmtran",
"match": "(?i:\\$[\\w]+)"
"name": "markup.heading.1.controlrecord.nmtran",
"match": "(?i:^\\$[A-Z]+)"
}]
},
"control-record-options": {
"control-record-syntax": {
"patterns": [{
"comment": "subroutines",
"name": "support.type.nmtran",
"name": "support.type.subroutines.nmtran",
"match": "(?i:\\b(ADVAN(\\=)?[\\d]+|TRANS(\\=)?\\d+)|((TN|NW)PRI))"
},
{
"comment": "Control record options",
"name": "support.type.nmtran",
"match": "(?i:\\b(PROTECT)|(DATA|IGNORE|NULL|(NO)?(PRINT|WIDE|REWIND|ABORT|RESCALE|REPEAT|INTERACTION|LAPLACIAN|POSTHOC)|CHECKOUT|RECORDS|LRECL|SUBROUTINES|COM(RES|SAV)|DERIV2|NUMBERPOINTS|DIAGONAL\\(\\d+\\)|BLOCK(\\(\\d+\\))?|SAME|FIX(ED)?|NPOPETAS|NORMAL|UNIFORM|NEW|SUBPROBLEMS|ONLYSIM(ULATION)?|METH(OD)?|SIG((DIG)?ITS)?|MAXEVAL(S)?|MSFO|SPECIAL|MATRIX|(UN)?CONDITIONAL|(NO|ONE)HEADER|VS|BY|UNIT|FROM|(A|SS)?TO(L(ERANCE)?)?|(N)?COMP(ARTMENT(S)?)?|NEQUILIBRIUM|NPARAMETERS|LINK|LIKE(LIHOOD)?|SADDLE_RESET)\\b)"
"comment": "General control record options",
"name": "support.type.controlrecord.options.nmtran",
"match": "(?i:\\b((DIAGONAL|BLOCK)\\(\\d+\\)))"
},
{
"comment": "SIZES record options",
"name": "support.type.nmtran",
"comment": "General control record options",
"name": "support.type.controlrecord.options.nmtran",
"match": "(?i:\\b(PROTECT|DATA|IGNORE|(NO)?(PRINT|WIDE|REWIND|ABORT|RESCALE|REPEAT|INTERACTION|LAPLACIAN|POSTHOC)|CHECKOUT|OMITTED|RECORDS|LRECL|SUBROUTINES|DERIV2|NUMBERPOINTS|SAME|NPOPETAS|NORMAL|UNIFORM|NEW|SUBPROBLEMS|ONLYSIM(ULATION)?|METH(OD)?|SIG((DIG)?ITS)?|MAXEVAL(S)?|MSFO|SPECIAL|MATRIX|(UN)?CONDITIONAL|(NO|ONE)HEADER|VS|BY|UNIT|FROM|(A)?TOL|(N)?COMP(ARTMENT(S)?)?|NEQUILIBRIUM|NPARAMETERS|LINK|LIKE(LIHOOD)?)\\b)"
},
{
"comment": "$PROBLEM syntax",
"name": "string.quoted.problem.specification.nmtran",
"match": "(?i:(?<=\\$PROB(LEM)?\\b).*)"
},
{
"comment": "Specific $SIZES record options",
"name": "support.type.controlrecord.options.sizes.nmtran",
"match": "(?i:\\b(LTH|LVR|LVR2|NO|MMX|LNP4|LSUPP|LIM7|LWS3|MAXIDS|LIM1|LIM2|LIM3|LIM4|LIM5|LIM6|LIM8|LIM11|LIM13|LIM15|LIM16|MAXRECID|PC|PCT|PIR|PD|PDT|PAL|MAXFCN|DIMTMP|DIMCNS|DIMNEW|DIMVRB|PL|NPOPMIXMAX|MAXOMEG|MAXPTHETA|MAXITER|ISAMPLEMAX|MAXSIDL|PNM_MAXNODES)\\b)"
},
{
"comment": "PRIOR record options",
"name": "support.type.nmtran",
"comment": "Specific $PRIOR record options",
"name": "support.type.controlrecord.options.prior.nmtran",
"match": "(?i:\\b(ITYP|NSAM|ISS|PLEV|CNT)|(NTHETA|NETA|NEPS|NTHP|NETP|NEPP|NPEXP)|(IFND|MODE|IVAR)(DISPLAY|ICMAX)\\b)"
},
{
"comment": "$ESTIMATION record options",
"name": "support.type.nmtran",
"match": "(?i:\\b(-2LL|ATOL|AUTO|CALPHA|CENTERING|CINTERVAL|CITER|CNSAMP|(UN)?COND(ITIONAL)?|CONSTRAIN|CTYPE|DERCONT|DF(S)?|EONLY|ETA(BARCHECK|DER|SAMPLES|STYPE)|FILE|FNLETA|FORMAT|DELIM|FPARAFILE|GRD|GRDQ|GRID|HYBRID|IACCEPT(L)?|INTER(ACTION)?|IKAPPA|ISAMPEND|ISAMPLE(_M(1(A|B)?|2|3))?|ISCALE_(MAX|MIN)|KAPPA|LAPLACE|LEVWT|LIKE(LIHOOD)?|LNTWOPI|MADAPT|MAPCOV|MAPI(N)?TER|MASSRESET|MAXEVAL(S)?|MCETA|MSFO|MUM|N(BURN|ITER|SAMPLE)?|(NO)?(ABORT|(THETA|OMEGA|SIGMA)BOUNDTEST)|NO(COV|HABORT|LABEL|NINFETA|PRIOR(C)?|SUB|TITLE)|NSIG|SIGDIGITS|NUMDER|NUMERICAL|NUTS_(BASE|DELTA|EPARAM|GAMMA|INIT|MASS|MAXDEPTH|OPARAM|REG|SPARAM|STEPINTER|STEPITER|TERM|TEST|TRANSFORM)|OACCEPT|OLKJDF|OLNTWOPI|OMEGABOUNDTEST|OMITTED|OPTMAP|ORDER|OSAMPLE_(M1|M2)?|OVARF|PACCEPT|PARAFILE|PARAFPRINT|PHITYPE|POSTHOC|PREDICTION|PRINT|PSAMPLE_(M1|M2|M3|MAX|MIN)|RANMETHOD|REPEAT(1|2)?|SADDLE_(HESS|RESET)|SEED|SIGL(O)?|SLKJDF|FAST|SORT|STDOBJ|STIELTJES|SVARF|THIN|TTDF|ZERO)\\b)"
"comment": "Specific $ESTIMATION record options",
"name": "support.type.controlrecord.options.estimation.nmtran",
"match": "(?i:\\b(-2LL|AUTO|CALPHA|CENTERING|CINTERVAL|CITER|CNSAMP|(UN)?COND(ITIONAL)?|CONSTRAIN|CTYPE|DERCONT|DF(S)?|EONLY|ETA(BARCHECK|DER|SAMPLES|STYPE)|FILE|FNLETA|FORMAT|DELIM|FPARAFILE|GRD|GRDQ|GRID|HYBRID|IACCEPT(L)?|INTER(ACTION)?|IKAPPA|ISAMPEND|ISAMPLE(_M(1(A|B)?|2|3))?|ISCALE_(MAX|MIN)|KAPPA|LAPLACE|LEVWT|LIKE(LIHOOD)?|LNTWOPI|MADAPT|MAPCOV|MAPI(N)?TER|MASSRESET|MAXEVAL(S)?|MCETA|MSFO|MUM|N(BURN|ITER|SAMPLE)|(NO)?(ABORT|(THETA|OMEGA|SIGMA)BOUNDTEST)|NO(COV|HABORT|LABEL|NINFETA|PRIOR(C)?|SUB|TITLE)|NSIG|SIGDIGITS|NUMDER|NUMERICAL|NUTS_(BASE|DELTA|EPARAM|GAMMA|INIT|MASS|MAXDEPTH|OPARAM|REG|SPARAM|STEPINTER|STEPITER|TERM|TEST|TRANSFORM)|OACCEPT|OLKJDF|OLNTWOPI|OMEGABOUNDTEST|OPTMAP|ORDER|OSAMPLE_(M1|M2)?|OVARF|PACCEPT|PARAFILE|PARAFPRINT|PHITYPE|POSTHOC|PREDICTION|PRINT|PSAMPLE_(M1|M2|M3|MAX|MIN)|RANMETHOD|REPEAT(1|2)?|SADDLE_(HESS|RESET)|SEED|SIGL(O)?|SLKJDF|FAST|SORT|STDOBJ|STIELTJES|SVARF|THIN|TTDF|ZERO)\\b)"
},
{
"comment": "$SIMULATION record options",
"name": "support.type.nmtran",
"comment": "Specific $SIMULATION record options",
"name": "support.type.controlrecord.options.simulation.nmtran",
"match": "(?i:\\b(NSUB)\\b)"
},
{
"comment": "$COVARIANCE record options",
"name": "support.type.nmtran",
"match": "(?i:\\b(SIR(THBND|SAMPLE|DF|NITER|CENTER|PRINT))|((PRE|PF)?COND(S)?)|(FPOSDEF|RESUME|PRETYPE|COMPRESS)|(IACCEPT(L)?)\\b)"
"comment": "Specific $COVARIANCE record options",
"name": "support.type.controlrecord.options.covariance.nmtran",
"match": "(?i:\\b(SPECIAL|MATRIX|SIR(THBND|SAMPLE|DF|NITER|CENTER))|((PRE|PF)?COND(S)?)|(FPOSDEF|RESUME|PRETYPE|COMPRESS|NOFCOV)|(IACCEPT(L)?)\\b)"
},
{
"comment": "$TABLE record options",
"name": "support.type.nmtran",
"comment": "Specific $TABLE record options",
"name": "support.type.controlrecord.options.table.nmtran",
"match": "(?i:\\b(NOAPPEND)\\b)"
},
{
Expand All @@ -78,45 +103,125 @@
{
"comment": "Control record option arguments",
"name": "support.type.nmtran",
"match": "(?i:\\b(INITIALOFF|NOOFF|NODOSE|EQUILIBRIUM|EXCLUDE|DEFOBSERVATION|DEFDOSE|DEFDOS|CENT|CENTRAL|DEFOBS|DEPOT|INITIAL|FINAL|PRIOR|NO|NOCOMMON|FULL|COMPACT|ZERO|HYBRID|SS(1|2|3|4|5|6|7|8|9|10|11|12))\\b)"
"match": "(?i:\\b(INITIALOFF|NOOFF|NODOSE|EQUILIBRIUM|EXCLUDE|DEFOBSERVATION|DEFDOSE|DEFDOS|CENT|CENTRAL|DEFOBS|DEPOT|INITIAL|FINAL|PRIOR|NO|NOCOMMON|FULL|COMPACT|ZERO|HYBRID|SS(1|2|3|4|5|6|7|8|9|10|11|12))?=\\b)"
}]
},
"parameters": {
"patterns": [{
"name": "variable.parameter.nmtran",
"match": "(?i:(A\\([\\d]+\\)|ALAG[\\d]+|F[\\d]+|THETA\\([\\d]+\\)|ETA\\([\\d]+\\)|DADT\\([\\d]+\\)|EPS\\([\\d]+\\)))"
"name": "variable.parameter.population.nmtran",
"match": "(?i:\\b((THETA|ETA|EPS|ERR)\\([\\d]+\\)))"
},
{
"name": "variable.parameter.mu.nmtran",
"match": "(?i:\\b(MU_[\\d]))"
}]
},
"reserved" : {
"patterns": [{
"name": "storage.type.reserved.nmtran",
"match":"(?i:\\b((A(_0|_U)?\\([\\d]+\\))|(DADT\\([\\d]+\\))|((T|X)+SCALE)))"
},
{
"name": "variable.global.reserved.nmtran",
"match": "(?i:\\b((CORRL2|MTIME|MNEXT|MPAST)\\([\\d]+\\)))"
},
{
"name": "variable.global.reserved.nmtran",
"match": "(?i:\\b(CIWRES(I)?|DES_DER|MIXNUM|MIXEST|MTDIFF|MNOW|NPD(E?)|NPDE_MODE|DV_LOQ|DV_LAQ|CDF_L(A)?|T)\\b)"
},
{
"name": "storage.type.reserved.nmprd4.nmtran",
"match": "(?i:\\b(COM\\([\\d]+\\)|COM(ACT|RES|SAV)?))"
},
{
"name": "storage.type.reserved.other.nmtran",
"match": "(?i:\\b(ETASXI\\([\\d]+\\)|HINIT|HMIN|HMAX|STOP_TIME|ITASK|PASTZERO))"
},
{
"name": "storage.type.reserved.nmtran",
"match": "(?i:\\b((ALAG|F|S|D)[\\d]+)\\b)"
},
{
"comment": "reserved data item labels that may be needed by NONMEM or PREDPP",
"name": "storage.type.reserved.labels.nmtran",
"match": "(?i:\\b(ID|L(1|2)|MDV(I1|I2|I3)?|DV|TIME|DATE|DAT(1|2|3)|DROP|SKIP|EVID|AMT|RATE|SS|II|ADDL(_ACTUAL|_TIME|_TIMEDIFF)?|RAW_|MRG_|RPT_)\\b)"
},
{
"comment": "semi-reserved labels, have reserved meanings if used in $INPUT, but can be user-defined in abbreviated code, in which case they have no reserved meaning",
"name": "storage.type.reserved.semi.nmtran",
"match": "(?i:\\b(XVID(1|2|3|4|5)|REPL_)\\b)"
},
{
"comment": "NONMEM_RESERVED_GENERAL",
"name": "storage.type.reserved.nonmem.nmtran",
"match": "(?i:\\b(ITER_REPORT|BAYES_EXTRA_REQUEST|BAYES_EXTRA|RANDMT(U)?)\\b)"
},
{
"comment": "Record counters (read-only)",
"name": "storage.type.reserved.counter.nmtran",
"match": "(?i:\\b(NDREC|NIREC|FIRSTREC|LASTREC|FIRSTOBS|LASTOBS|FIRSTDOS|LASTDOS|EFIRSTREC|ELASTREC|EFIRSTOBS|ELASTOBS|EFIRSTDOS|ELASTDOS|IRECIDX)\\b)"
},
{
"comment": "Record counters (read-only)",
"name": "storage.type.nmtran",
"match": "(?i:\\b(INTEGER|REAL)\\b)"
},
{
"comment": "reserved variables used internally by NMTRAN",
"name": "storage.type.reserved.internal.nmtran",
"match": "(?i:\\b(CALL|CMT|PCMT|CONT|NTHETA|NTHP|NPROB|IPROB|MODE|R|PRED_IGNORE_DATA_TEST|PRED_IGNORE_DATA|VECTR[A-Z]{1,3}|FUNC[A-Z]{1,3}|GETETA|SIMETA|SIMEPS|NWIND|ETEXT|IERPRD|IERPRDU|MSEC|MFIRST|NETEXT|(A|B|C|D|E|F|P|Q)\\d{5}|M(C|E|G|T)\\d{4}|MXSTEP)\\b)"
}]
},
"operators" : {
"patterns": [{
"comment": "operators",
"name": "keyword.operator.nmtran",
"match": "(?i:\\b((\\s)?(\\+|-{1}|(\\*){1}|/|\\.((N)?EQ|EQN|GE|GT|LE|LT|NE(N)?|OR|AND)\\.)(\\s)?)\\b)"
"comment": "logical operators",
"name": "keyword.operator.logical.nmtran",
"match": "(?i:(\\.((N)?EQ|EQN|GE|GT|LE|LT|NE(N)?|OR|AND)\\.))"
},
{
"comment": "assignment operator",
"name": "markup.bold.nmtran",
"match": "="
"comment": "FORTRAN 95 logical operators",
"name": "keyword.operator.logical.fortran95.nmtran",
"match": "((\\=\\=|\\/\\=|\\>(\\=)?|\\<(\\=)?))"
},
{
"comment": "FORTRAN 95 operators",
"name": "keyword.operator.nmtran",
"match": "\\b((\\s)?(\\=\\=|\\/\\=|\\>(\\=)?|\\<(\\=)?)(\\s)?)\\b"
"comment": "exponentiation operator",
"name": "keyword.operator.exponentiation.nmtran",
"match": "(?i:(?<=(\\d|\\)))(E|(\\*\\*)))"
},
{
"comment": "assignment operator =",
"name": "keyword.operator.assignment.nmtran",
"match": "(?<!\\=|\\/|\\<|\\>)\\=(?!\\=)"
},
{
"comment": "invalid operator",
"name": "invalid.nmtran",
"match": "(?i:\\b((\\s)?((\\.NEQN\\.)|(\\=\\/))(\\s)?)\\b)"
"name": "invalid.illegal.nmtran",
"match": "(?i:(\\.NEQN\\.|\\=\\/))"
},
{
"comment": "Abbreviated code, FORTRAN 77 Code and NON-generic FORTAN 77 CODE",
"name": "keyword.operator.nmtran",
"match": "(?i:\\b(CALL(FL)?|DO|(ELSE)?IF|ELSE|ENDIF|TRUE|FALSE|EXIT|MODE|PASS|RANDOM|RETURN|SIMEPS|SIMETA|SQRT|SUPP|THEN|WHILE|ABS|ACOS|AIMAG|AINT|ALOG|ALOG10|AMAX0|AMAX1|AMIN0|AMIN1|AMOD|AND|ANINT|ASIN|ATAN|ATAN2|BACKSPACE|BLOCK|CABS|CCOS|CHAR|CHARACTER|CLOG|CLOSE|CMPLX|COMMON|COMPLEX|CONJG|CONTINUE|COS|COSH|CSIN|CSQRT|DABS|DACOS|DASIN|DATA(N(2)?)?|DBLE|DCOS|DCOSH|DDIM|DIM|DIMENSION|DINT|DLOG|DMAX1|DMIN1|DMOD|DNINT|DO|DOUBLE|DPROD|DSIGN|DSIN|DSINH|DSQRT|DTAN|DTANH|ELSE|ELSEIF|END|ENDFILE|ENTRY|EQ|EQUIVALENCE|ERR|(C|D)?EXP|EXTERNAL|FALSE|FILE|FLOAT|FORMAT|FUNCTION|GE|GOTO|GT|IABS|ICHAR|IDIM|IDINT|IDNINT|IF|IFIX|IMPLICIT|INDEX|INQUIRE|INTEGER|INTRINSIC|IOSTAT|ISIGN|LE|LEN|LGE|LGT|LLE|LLT|LOG|LOG10|LOGICAL|LT|MAX(0|1)?|MIN(0|1)?|MOD|NE|NINT|NOT|OPEN|OR|PARAMETER|PAUSE|PRECISION|PROGRAM|READ|REAL|REAL|RETURN|REWIND|SAVE|SIGN|SIN|SINH|SNGL|SQRT|STATUS|STOP|SUBROUTINE|TAN(H)?|THEN|TRUE|UNIT|WRITE|BTEST|CDABS|CDCOS|CDEXP|CDLOG|CDSIN|CDSQRT|COTAN|DCMPLX|DCONJG|DCOTAN|DIMAG|DREAL|EOF|ETDAT|GETDAT|GETTIM|HFIX|IAND|IBCHNG|IBCLR|IBSET|IEOR|IMAG|INT|INT1|INT2|INT4|INTC|INTERFACE|IOR|ISHA|ISHC|ISHFT|ISHL|JFIX|LACFAR|LOC|LOCKING|LOCNEAR|NOT|SETTIM)\\b)"
"name": "keyword.other.abbreviatedcode.nmtran",
"match": "(?i:\\b(AIMAG|AINT|ALOG|ALOG10|AMAX0|AMAX1|AMIN0|AMIN1|AMOD|ANINT|BACKSPACE|BLOCK|CHAR|CHARACTER|CMPLX|COMMON|COMPLEX|CONJG|COSH|DATA(N(2)?)?|DBLE|DCOS|DCOSH|DDIM|DIM|DIMENSION|DINT|DMAX1|DMIN1|DMOD|DNINT|DOUBLE|DPROD|DSIGN|ENTRY|EQUIVALENCE|EXTERNAL|FILE|FLOAT|FORMAT|FUNCTION|GOTO|IABS|ICHAR|IDIM|IDINT|IDNINT|IFIX|IMPLICIT|INDEX|INQUIRE|INTRINSIC|IOSTAT|ISIGN|LLE|LLT|LOGICAL|MAX(0|1)?|MIN(0|1)?)\\b)"
},
{
"comment": "exponentiation operator",
"name": "keyword.operator.nmtran",
"match": "(?i:(?<=[\\d])(E|(\\*\\*))|(\\&)$)"
"comment": "mainly related to flow control like if, else, do, while, etc.",
"name": "keyword.control.nmtran",
"match": "(?i:\\b(CALL(FL)?|DO(\\s)?WHILE|(ELSE)?IF|THEN|ELSE|END(DO|IF)?|EXIT|MODE|RETURN|PROGRAM|READ|WRITE|REWIND|SAVE|SNGL|STATUS|STOP|CONTINUE|SUBROUTINE|OPEN|CLOSE|FIX(ED)?)\\b)"
},
{
"comment": "protected functions",
"name": "entity.name.function.protected.nmtran",
"match": "(?i:\\bP(LOG(10?)|SQRT|EXP|DZ|ZR|NP|HE|NG|TAN|A(COS|SIN|TAN))\\b)"
},
{
"comment": "functions",
"name": "entity.name.function.nmtran",
"match": "(?i:\\b(SQRT|EXP|ABS|A?(COS|SIN|TAN)|ATAN2|SIGN|SIN|SINH|TAN|TANH|COTAN|INT|MOD|MIN|MAXLOG|LOG10|RANDOM|GAMLN|REAL|PASS|SUPP)\\b)"
},
{
"comment": "arithmetic operators",
"name": "keyword.operator.arithmetic.nmtran",
"match": "[\\*\/\\+\\-]"
}]
}
}
Expand Down

0 comments on commit fa3a67f

Please sign in to comment.