basant307/AI_Governance_Project
048
1/*2Language: Scheme3Description: Scheme is a programming language in the Lisp family.4 (keywords based on http://community.schemewiki.org/?scheme-keywords)5Author: JP Verkamp <me@jverkamp.com>6Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>7Origin: clojure.js8Website: http://community.schemewiki.org/?what-is-scheme9Category: lisp10*/11 12function scheme(hljs) {13 const SCHEME_IDENT_RE = '[^\\(\\)\\[\\]\\{\\}",\'`;#|\\\\\\s]+';14 const SCHEME_SIMPLE_NUMBER_RE = '(-|\\+)?\\d+([./]\\d+)?';15 const SCHEME_COMPLEX_NUMBER_RE = SCHEME_SIMPLE_NUMBER_RE + '[+\\-]' + SCHEME_SIMPLE_NUMBER_RE + 'i';16 const KEYWORDS = {17 $pattern: SCHEME_IDENT_RE,18 built_in:19 'case-lambda call/cc class define-class exit-handler field import '20 + 'inherit init-field interface let*-values let-values let/ec mixin '21 + 'opt-lambda override protect provide public rename require '22 + 'require-for-syntax syntax syntax-case syntax-error unit/sig unless '23 + 'when with-syntax and begin call-with-current-continuation '24 + 'call-with-input-file call-with-output-file case cond define '25 + 'define-syntax delay do dynamic-wind else for-each if lambda let let* '26 + 'let-syntax letrec letrec-syntax map or syntax-rules \' * + , ,@ - ... / '27 + '; < <= = => > >= ` abs acos angle append apply asin assoc assq assv atan '28 + 'boolean? caar cadr call-with-input-file call-with-output-file '29 + 'call-with-values car cdddar cddddr cdr ceiling char->integer '30 + 'char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? '31 + 'char-downcase char-lower-case? char-numeric? char-ready? char-upcase '32 + 'char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? '33 + 'char? close-input-port close-output-port complex? cons cos '34 + 'current-input-port current-output-port denominator display eof-object? '35 + 'eq? equal? eqv? eval even? exact->inexact exact? exp expt floor '36 + 'force gcd imag-part inexact->exact inexact? input-port? integer->char '37 + 'integer? interaction-environment lcm length list list->string '38 + 'list->vector list-ref list-tail list? load log magnitude make-polar '39 + 'make-rectangular make-string make-vector max member memq memv min '40 + 'modulo negative? newline not null-environment null? number->string '41 + 'number? numerator odd? open-input-file open-output-file output-port? '42 + 'pair? peek-char port? positive? procedure? quasiquote quote quotient '43 + 'rational? rationalize read read-char real-part real? remainder reverse '44 + 'round scheme-report-environment set! set-car! set-cdr! sin sqrt string '45 + 'string->list string->number string->symbol string-append string-ci<=? '46 + 'string-ci<? string-ci=? string-ci>=? string-ci>? string-copy '47 + 'string-fill! string-length string-ref string-set! string<=? string<? '48 + 'string=? string>=? string>? string? substring symbol->string symbol? '49 + 'tan transcript-off transcript-on truncate values vector '50 + 'vector->list vector-fill! vector-length vector-ref vector-set! '51 + 'with-input-from-file with-output-to-file write write-char zero?'52 };53 54 const LITERAL = {55 className: 'literal',56 begin: '(#t|#f|#\\\\' + SCHEME_IDENT_RE + '|#\\\\.)'57 };58 59 const NUMBER = {60 className: 'number',61 variants: [62 {63 begin: SCHEME_SIMPLE_NUMBER_RE,64 relevance: 065 },66 {67 begin: SCHEME_COMPLEX_NUMBER_RE,68 relevance: 069 },70 { begin: '#b[0-1]+(/[0-1]+)?' },71 { begin: '#o[0-7]+(/[0-7]+)?' },72 { begin: '#x[0-9a-f]+(/[0-9a-f]+)?' }73 ]74 };75 76 const STRING = hljs.QUOTE_STRING_MODE;77 78 const COMMENT_MODES = [79 hljs.COMMENT(80 ';',81 '$',82 { relevance: 0 }83 ),84 hljs.COMMENT('#\\|', '\\|#')85 ];86 87 const IDENT = {88 begin: SCHEME_IDENT_RE,89 relevance: 090 };91 92 const QUOTED_IDENT = {93 className: 'symbol',94 begin: '\'' + SCHEME_IDENT_RE95 };96 97 const BODY = {98 endsWithParent: true,99 relevance: 0100 };101 102 const QUOTED_LIST = {103 variants: [104 { begin: /'/ },105 { begin: '`' }106 ],107 contains: [108 {109 begin: '\\(',110 end: '\\)',111 contains: [112 'self',113 LITERAL,114 STRING,115 NUMBER,116 IDENT,117 QUOTED_IDENT118 ]119 }120 ]121 };122 123 const NAME = {124 className: 'name',125 relevance: 0,126 begin: SCHEME_IDENT_RE,127 keywords: KEYWORDS128 };129 130 const LAMBDA = {131 begin: /lambda/,132 endsWithParent: true,133 returnBegin: true,134 contains: [135 NAME,136 {137 endsParent: true,138 variants: [139 {140 begin: /\(/,141 end: /\)/142 },143 {144 begin: /\[/,145 end: /\]/146 }147 ],148 contains: [ IDENT ]149 }150 ]151 };152 153 const LIST = {154 variants: [155 {156 begin: '\\(',157 end: '\\)'158 },159 {160 begin: '\\[',161 end: '\\]'162 }163 ],164 contains: [165 LAMBDA,166 NAME,167 BODY168 ]169 };170 171 BODY.contains = [172 LITERAL,173 NUMBER,174 STRING,175 IDENT,176 QUOTED_IDENT,177 QUOTED_LIST,178 LIST179 ].concat(COMMENT_MODES);180 181 return {182 name: 'Scheme',183 aliases: ['scm'],184 illegal: /\S/,185 contains: [186 hljs.SHEBANG(),187 NUMBER,188 STRING,189 QUOTED_IDENT,190 QUOTED_LIST,191 LIST192 ].concat(COMMENT_MODES)193 };194}195 196export { scheme as default };197 