CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
gams.js182 linesDownload Raw Back to languages
1/*2 Language: GAMS3 Author: Stefan Bechert <stefan.bechert@gmx.net>4 Contributors: Oleg Efimov <efimovov@gmail.com>, Mikko Kouhia <mikko.kouhia@iki.fi>5 Description: The General Algebraic Modeling System language6 Website: https://www.gams.com7 Category: scientific8 */9 10/** @type LanguageFn */11function gams(hljs) {12  const regex = hljs.regex;13  const KEYWORDS = {14    keyword:15      'abort acronym acronyms alias all and assign binary card diag display '16      + 'else eq file files for free ge gt if integer le loop lt maximizing '17      + 'minimizing model models ne negative no not option options or ord '18      + 'positive prod put putpage puttl repeat sameas semicont semiint smax '19      + 'smin solve sos1 sos2 sum system table then until using while xor yes',20    literal:21      'eps inf na',22    built_in:23      'abs arccos arcsin arctan arctan2 Beta betaReg binomial ceil centropy '24      + 'cos cosh cvPower div div0 eDist entropy errorf execSeed exp fact '25      + 'floor frac gamma gammaReg log logBeta logGamma log10 log2 mapVal max '26      + 'min mod ncpCM ncpF ncpVUpow ncpVUsin normal pi poly power '27      + 'randBinomial randLinear randTriangle round rPower sigmoid sign '28      + 'signPower sin sinh slexp sllog10 slrec sqexp sqlog10 sqr sqrec sqrt '29      + 'tan tanh trunc uniform uniformInt vcPower bool_and bool_eqv bool_imp '30      + 'bool_not bool_or bool_xor ifThen rel_eq rel_ge rel_gt rel_le rel_lt '31      + 'rel_ne gday gdow ghour gleap gmillisec gminute gmonth gsecond gyear '32      + 'jdate jnow jstart jtime errorLevel execError gamsRelease gamsVersion '33      + 'handleCollect handleDelete handleStatus handleSubmit heapFree '34      + 'heapLimit heapSize jobHandle jobKill jobStatus jobTerminate '35      + 'licenseLevel licenseStatus maxExecError sleep timeClose timeComp '36      + 'timeElapsed timeExec timeStart'37  };38  const PARAMS = {39    className: 'params',40    begin: /\(/,41    end: /\)/,42    excludeBegin: true,43    excludeEnd: true44  };45  const SYMBOLS = {46    className: 'symbol',47    variants: [48      { begin: /=[lgenxc]=/ },49      { begin: /\$/ }50    ]51  };52  const QSTR = { // One-line quoted comment string53    className: 'comment',54    variants: [55      {56        begin: '\'',57        end: '\''58      },59      {60        begin: '"',61        end: '"'62      }63    ],64    illegal: '\\n',65    contains: [ hljs.BACKSLASH_ESCAPE ]66  };67  const ASSIGNMENT = {68    begin: '/',69    end: '/',70    keywords: KEYWORDS,71    contains: [72      QSTR,73      hljs.C_LINE_COMMENT_MODE,74      hljs.C_BLOCK_COMMENT_MODE,75      hljs.QUOTE_STRING_MODE,76      hljs.APOS_STRING_MODE,77      hljs.C_NUMBER_MODE78    ]79  };80  const COMMENT_WORD = /[a-z0-9&#*=?@\\><:,()$[\]_.{}!+%^-]+/;81  const DESCTEXT = { // Parameter/set/variable description text82    begin: /[a-z][a-z0-9_]*(\([a-z0-9_, ]*\))?[ \t]+/,83    excludeBegin: true,84    end: '$',85    endsWithParent: true,86    contains: [87      QSTR,88      ASSIGNMENT,89      {90        className: 'comment',91        // one comment word, then possibly more92        begin: regex.concat(93          COMMENT_WORD,94          // [ ] because \s would be too broad (matching newlines)95          regex.anyNumberOfTimes(regex.concat(/[ ]+/, COMMENT_WORD))96        ),97        relevance: 098      }99    ]100  };101 102  return {103    name: 'GAMS',104    aliases: [ 'gms' ],105    case_insensitive: true,106    keywords: KEYWORDS,107    contains: [108      hljs.COMMENT(/^\$ontext/, /^\$offtext/),109      {110        className: 'meta',111        begin: '^\\$[a-z0-9]+',112        end: '$',113        returnBegin: true,114        contains: [115          {116            className: 'keyword',117            begin: '^\\$[a-z0-9]+'118          }119        ]120      },121      hljs.COMMENT('^\\*', '$'),122      hljs.C_LINE_COMMENT_MODE,123      hljs.C_BLOCK_COMMENT_MODE,124      hljs.QUOTE_STRING_MODE,125      hljs.APOS_STRING_MODE,126      // Declarations127      {128        beginKeywords:129          'set sets parameter parameters variable variables '130          + 'scalar scalars equation equations',131        end: ';',132        contains: [133          hljs.COMMENT('^\\*', '$'),134          hljs.C_LINE_COMMENT_MODE,135          hljs.C_BLOCK_COMMENT_MODE,136          hljs.QUOTE_STRING_MODE,137          hljs.APOS_STRING_MODE,138          ASSIGNMENT,139          DESCTEXT140        ]141      },142      { // table environment143        beginKeywords: 'table',144        end: ';',145        returnBegin: true,146        contains: [147          { // table header row148            beginKeywords: 'table',149            end: '$',150            contains: [ DESCTEXT ]151          },152          hljs.COMMENT('^\\*', '$'),153          hljs.C_LINE_COMMENT_MODE,154          hljs.C_BLOCK_COMMENT_MODE,155          hljs.QUOTE_STRING_MODE,156          hljs.APOS_STRING_MODE,157          hljs.C_NUMBER_MODE158          // Table does not contain DESCTEXT or ASSIGNMENT159        ]160      },161      // Function definitions162      {163        className: 'function',164        begin: /^[a-z][a-z0-9_,\-+' ()$]+\.{2}/,165        returnBegin: true,166        contains: [167          { // Function title168            className: 'title',169            begin: /^[a-z0-9_]+/170          },171          PARAMS,172          SYMBOLS173        ]174      },175      hljs.C_NUMBER_MODE,176      SYMBOLS177    ]178  };179}180 181export { gams as default };182 
basant307/AI_Governance_Project · CoolFace