{"version":3,"file":"r.mjs","sources":["../../../../../../node_modules/highlight.js/lib/languages/r.js"],"sourcesContent":["/*\nLanguage: R\nDescription: R is a free software environment for statistical computing and graphics.\nAuthor: Joe Cheng <joe@rstudio.org>\nContributors: Konrad Rudolph <konrad.rudolph@gmail.com>\nWebsite: https://www.r-project.org\nCategory: common,scientific\n*/\n\n/** @type LanguageFn */\nfunction r(hljs) {\n  const regex = hljs.regex;\n  // Identifiers in R cannot start with `_`, but they can start with `.` if it\n  // is not immediately followed by a digit.\n  // R also supports quoted identifiers, which are near-arbitrary sequences\n  // delimited by backticks (`…`), which may contain escape sequences. These are\n  // handled in a separate mode. See `test/markup/r/names.txt` for examples.\n  // FIXME: Support Unicode identifiers.\n  const IDENT_RE = /(?:(?:[a-zA-Z]|\\.[._a-zA-Z])[._a-zA-Z0-9]*)|\\.(?!\\d)/;\n  const NUMBER_TYPES_RE = regex.either(\n    // Special case: only hexadecimal binary powers can contain fractions\n    /0[xX][0-9a-fA-F]+\\.[0-9a-fA-F]*[pP][+-]?\\d+i?/,\n    // Hexadecimal numbers without fraction and optional binary power\n    /0[xX][0-9a-fA-F]+(?:[pP][+-]?\\d+)?[Li]?/,\n    // Decimal numbers\n    /(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?[Li]?/\n  );\n  const OPERATORS_RE = /[=!<>:]=|\\|\\||&&|:::?|<-|<<-|->>|->|\\|>|[-+*\\/?!$&|:<=>@^~]|\\*\\*/;\n  const PUNCTUATION_RE = regex.either(\n    /[()]/,\n    /[{}]/,\n    /\\[\\[/,\n    /[[\\]]/,\n    /\\\\/,\n    /,/\n  );\n\n  return {\n    name: 'R',\n\n    keywords: {\n      $pattern: IDENT_RE,\n      keyword:\n        'function if in break next repeat else for while',\n      literal:\n        'NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 '\n        + 'NA_character_|10 NA_complex_|10',\n      built_in:\n        // Builtin constants\n        'LETTERS letters month.abb month.name pi T F '\n        // Primitive functions\n        // These are all the functions in `base` that are implemented as a\n        // `.Primitive`, minus those functions that are also keywords.\n        + 'abs acos acosh all any anyNA Arg as.call as.character '\n        + 'as.complex as.double as.environment as.integer as.logical '\n        + 'as.null.default as.numeric as.raw asin asinh atan atanh attr '\n        + 'attributes baseenv browser c call ceiling class Conj cos cosh '\n        + 'cospi cummax cummin cumprod cumsum digamma dim dimnames '\n        + 'emptyenv exp expression floor forceAndCall gamma gc.time '\n        + 'globalenv Im interactive invisible is.array is.atomic is.call '\n        + 'is.character is.complex is.double is.environment is.expression '\n        + 'is.finite is.function is.infinite is.integer is.language '\n        + 'is.list is.logical is.matrix is.na is.name is.nan is.null '\n        + 'is.numeric is.object is.pairlist is.raw is.recursive is.single '\n        + 'is.symbol lazyLoadDBfetch length lgamma list log max min '\n        + 'missing Mod names nargs nzchar oldClass on.exit pos.to.env '\n        + 'proc.time prod quote range Re rep retracemem return round '\n        + 'seq_along seq_len seq.int sign signif sin sinh sinpi sqrt '\n        + 'standardGeneric substitute sum switch tan tanh tanpi tracemem '\n        + 'trigamma trunc unclass untracemem UseMethod xtfrm',\n    },\n\n    contains: [\n      // Roxygen comments\n      hljs.COMMENT(\n        /#'/,\n        /$/,\n        { contains: [\n          {\n            // Handle `@examples` separately to cause all subsequent code\n            // until the next `@`-tag on its own line to be kept as-is,\n            // preventing highlighting. This code is example R code, so nested\n            // doctags shouldn’t be treated as such. See\n            // `test/markup/r/roxygen.txt` for an example.\n            scope: 'doctag',\n            match: /@examples/,\n            starts: {\n              end: regex.lookahead(regex.either(\n                // end if another doc comment\n                /\\n^#'\\s*(?=@[a-zA-Z]+)/,\n                // or a line with no comment\n                /\\n^(?!#')/\n              )),\n              endsParent: true\n            }\n          },\n          {\n            // Handle `@param` to highlight the parameter name following\n            // after.\n            scope: 'doctag',\n            begin: '@param',\n            end: /$/,\n            contains: [\n              {\n                scope: 'variable',\n                variants: [\n                  { match: IDENT_RE },\n                  { match: /`(?:\\\\.|[^`\\\\])+`/ }\n                ],\n                endsParent: true\n              }\n            ]\n          },\n          {\n            scope: 'doctag',\n            match: /@[a-zA-Z]+/\n          },\n          {\n            scope: 'keyword',\n            match: /\\\\[a-zA-Z]+/\n          }\n        ] }\n      ),\n\n      hljs.HASH_COMMENT_MODE,\n\n      {\n        scope: 'string',\n        contains: [ hljs.BACKSLASH_ESCAPE ],\n        variants: [\n          hljs.END_SAME_AS_BEGIN({\n            begin: /[rR]\"(-*)\\(/,\n            end: /\\)(-*)\"/\n          }),\n          hljs.END_SAME_AS_BEGIN({\n            begin: /[rR]\"(-*)\\{/,\n            end: /\\}(-*)\"/\n          }),\n          hljs.END_SAME_AS_BEGIN({\n            begin: /[rR]\"(-*)\\[/,\n            end: /\\](-*)\"/\n          }),\n          hljs.END_SAME_AS_BEGIN({\n            begin: /[rR]'(-*)\\(/,\n            end: /\\)(-*)'/\n          }),\n          hljs.END_SAME_AS_BEGIN({\n            begin: /[rR]'(-*)\\{/,\n            end: /\\}(-*)'/\n          }),\n          hljs.END_SAME_AS_BEGIN({\n            begin: /[rR]'(-*)\\[/,\n            end: /\\](-*)'/\n          }),\n          {\n            begin: '\"',\n            end: '\"',\n            relevance: 0\n          },\n          {\n            begin: \"'\",\n            end: \"'\",\n            relevance: 0\n          }\n        ],\n      },\n\n      // Matching numbers immediately following punctuation and operators is\n      // tricky since we need to look at the character ahead of a number to\n      // ensure the number is not part of an identifier, and we cannot use\n      // negative look-behind assertions. So instead we explicitly handle all\n      // possible combinations of (operator|punctuation), number.\n      // TODO: replace with negative look-behind when available\n      // { begin: /(?<![a-zA-Z0-9._])0[xX][0-9a-fA-F]+\\.[0-9a-fA-F]*[pP][+-]?\\d+i?/ },\n      // { begin: /(?<![a-zA-Z0-9._])0[xX][0-9a-fA-F]+([pP][+-]?\\d+)?[Li]?/ },\n      // { begin: /(?<![a-zA-Z0-9._])(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?[Li]?/ }\n      {\n        relevance: 0,\n        variants: [\n          {\n            scope: {\n              1: 'operator',\n              2: 'number'\n            },\n            match: [\n              OPERATORS_RE,\n              NUMBER_TYPES_RE\n            ]\n          },\n          {\n            scope: {\n              1: 'operator',\n              2: 'number'\n            },\n            match: [\n              /%[^%]*%/,\n              NUMBER_TYPES_RE\n            ]\n          },\n          {\n            scope: {\n              1: 'punctuation',\n              2: 'number'\n            },\n            match: [\n              PUNCTUATION_RE,\n              NUMBER_TYPES_RE\n            ]\n          },\n          {\n            scope: { 2: 'number' },\n            match: [\n              /[^a-zA-Z0-9._]|^/, // not part of an identifier, or start of document\n              NUMBER_TYPES_RE\n            ]\n          }\n        ]\n      },\n\n      // Operators/punctuation when they're not directly followed by numbers\n      {\n        // Relevance boost for the most common assignment form.\n        scope: { 3: 'operator' },\n        match: [\n          IDENT_RE,\n          /\\s+/,\n          /<-/,\n          /\\s+/\n        ]\n      },\n\n      {\n        scope: 'operator',\n        relevance: 0,\n        variants: [\n          { match: OPERATORS_RE },\n          { match: /%[^%]*%/ }\n        ]\n      },\n\n      {\n        scope: 'punctuation',\n        relevance: 0,\n        match: PUNCTUATION_RE\n      },\n\n      {\n        // Escaped identifier\n        begin: '`',\n        end: '`',\n        contains: [ { begin: /\\\\./ } ]\n      }\n    ]\n  };\n}\n\nmodule.exports = r;\n"],"names":["r","hljs","regex","IDENT_RE","NUMBER_TYPES_RE","OPERATORS_RE","PUNCTUATION_RE","r_1"],"mappings":";;;;AAUA,WAASA,EAAEC,GAAM;AACf,UAAMC,IAAQD,EAAK,OAObE,IAAW,wDACXC,IAAkBF,EAAM;AAAA;AAAA,MAE5B;AAAA;AAAA,MAEA;AAAA;AAAA,MAEA;AAAA,IACJ,GACQG,IAAe,oEACfC,IAAiBJ,EAAM;AAAA,MAC3B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ;AAEE,WAAO;AAAA,MACL,MAAM;AAAA,MAEN,UAAU;AAAA,QACR,UAAUC;AAAA,QACV,SACE;AAAA,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