LaravelTest
188 строк · 8.4 Кб
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4(function(mod) {5if (typeof exports == "object" && typeof module == "object") // CommonJS6mod(require("../../lib/codemirror"));7else if (typeof define == "function" && define.amd) // AMD8define(["../../lib/codemirror"], mod);9else // Plain browser env10mod(CodeMirror);11})(function(CodeMirror) {12"use strict";13
14CodeMirror.defineMode("fortran", function() {15function words(array) {16var keys = {};17for (var i = 0; i < array.length; ++i) {18keys[array[i]] = true;19}20return keys;21}22
23var keywords = words([24"abstract", "accept", "allocatable", "allocate",25"array", "assign", "asynchronous", "backspace",26"bind", "block", "byte", "call", "case",27"class", "close", "common", "contains",28"continue", "cycle", "data", "deallocate",29"decode", "deferred", "dimension", "do",30"elemental", "else", "encode", "end",31"endif", "entry", "enumerator", "equivalence",32"exit", "external", "extrinsic", "final",33"forall", "format", "function", "generic",34"go", "goto", "if", "implicit", "import", "include",35"inquire", "intent", "interface", "intrinsic",36"module", "namelist", "non_intrinsic",37"non_overridable", "none", "nopass",38"nullify", "open", "optional", "options",39"parameter", "pass", "pause", "pointer",40"print", "private", "program", "protected",41"public", "pure", "read", "recursive", "result",42"return", "rewind", "save", "select", "sequence",43"stop", "subroutine", "target", "then", "to", "type",44"use", "value", "volatile", "where", "while",45"write"]);46var builtins = words(["abort", "abs", "access", "achar", "acos",47"adjustl", "adjustr", "aimag", "aint", "alarm",48"all", "allocated", "alog", "amax", "amin",49"amod", "and", "anint", "any", "asin",50"associated", "atan", "besj", "besjn", "besy",51"besyn", "bit_size", "btest", "cabs", "ccos",52"ceiling", "cexp", "char", "chdir", "chmod",53"clog", "cmplx", "command_argument_count",54"complex", "conjg", "cos", "cosh", "count",55"cpu_time", "cshift", "csin", "csqrt", "ctime",56"c_funloc", "c_loc", "c_associated", "c_null_ptr",57"c_null_funptr", "c_f_pointer", "c_null_char",58"c_alert", "c_backspace", "c_form_feed",59"c_new_line", "c_carriage_return",60"c_horizontal_tab", "c_vertical_tab", "dabs",61"dacos", "dasin", "datan", "date_and_time",62"dbesj", "dbesj", "dbesjn", "dbesy", "dbesy",63"dbesyn", "dble", "dcos", "dcosh", "ddim", "derf",64"derfc", "dexp", "digits", "dim", "dint", "dlog",65"dlog", "dmax", "dmin", "dmod", "dnint",66"dot_product", "dprod", "dsign", "dsinh",67"dsin", "dsqrt", "dtanh", "dtan", "dtime",68"eoshift", "epsilon", "erf", "erfc", "etime",69"exit", "exp", "exponent", "extends_type_of",70"fdate", "fget", "fgetc", "float", "floor",71"flush", "fnum", "fputc", "fput", "fraction",72"fseek", "fstat", "ftell", "gerror", "getarg",73"get_command", "get_command_argument",74"get_environment_variable", "getcwd",75"getenv", "getgid", "getlog", "getpid",76"getuid", "gmtime", "hostnm", "huge", "iabs",77"iachar", "iand", "iargc", "ibclr", "ibits",78"ibset", "ichar", "idate", "idim", "idint",79"idnint", "ieor", "ierrno", "ifix", "imag",80"imagpart", "index", "int", "ior", "irand",81"isatty", "ishft", "ishftc", "isign",82"iso_c_binding", "is_iostat_end", "is_iostat_eor",83"itime", "kill", "kind", "lbound", "len", "len_trim",84"lge", "lgt", "link", "lle", "llt", "lnblnk", "loc",85"log", "logical", "long", "lshift", "lstat", "ltime",86"matmul", "max", "maxexponent", "maxloc", "maxval",87"mclock", "merge", "move_alloc", "min", "minexponent",88"minloc", "minval", "mod", "modulo", "mvbits",89"nearest", "new_line", "nint", "not", "or", "pack",90"perror", "precision", "present", "product", "radix",91"rand", "random_number", "random_seed", "range",92"real", "realpart", "rename", "repeat", "reshape",93"rrspacing", "rshift", "same_type_as", "scale",94"scan", "second", "selected_int_kind",95"selected_real_kind", "set_exponent", "shape",96"short", "sign", "signal", "sinh", "sin", "sleep",97"sngl", "spacing", "spread", "sqrt", "srand", "stat",98"sum", "symlnk", "system", "system_clock", "tan",99"tanh", "time", "tiny", "transfer", "transpose",100"trim", "ttynam", "ubound", "umask", "unlink",101"unpack", "verify", "xor", "zabs", "zcos", "zexp",102"zlog", "zsin", "zsqrt"]);103
104var dataTypes = words(["c_bool", "c_char", "c_double", "c_double_complex",105"c_float", "c_float_complex", "c_funptr", "c_int",106"c_int16_t", "c_int32_t", "c_int64_t", "c_int8_t",107"c_int_fast16_t", "c_int_fast32_t", "c_int_fast64_t",108"c_int_fast8_t", "c_int_least16_t", "c_int_least32_t",109"c_int_least64_t", "c_int_least8_t", "c_intmax_t",110"c_intptr_t", "c_long", "c_long_double",111"c_long_double_complex", "c_long_long", "c_ptr",112"c_short", "c_signed_char", "c_size_t", "character",113"complex", "double", "integer", "logical", "real"]);114var isOperatorChar = /[+\-*&=<>\/\:]/;115var litOperator = /^\.(and|or|eq|lt|le|gt|ge|ne|not|eqv|neqv)\./i;116
117function tokenBase(stream, state) {118
119if (stream.match(litOperator)){120return 'operator';121}122
123var ch = stream.next();124if (ch == "!") {125stream.skipToEnd();126return "comment";127}128if (ch == '"' || ch == "'") {129state.tokenize = tokenString(ch);130return state.tokenize(stream, state);131}132if (/[\[\]\(\),]/.test(ch)) {133return null;134}135if (/\d/.test(ch)) {136stream.eatWhile(/[\w\.]/);137return "number";138}139if (isOperatorChar.test(ch)) {140stream.eatWhile(isOperatorChar);141return "operator";142}143stream.eatWhile(/[\w\$_]/);144var word = stream.current().toLowerCase();145
146if (keywords.hasOwnProperty(word)){147return 'keyword';148}149if (builtins.hasOwnProperty(word) || dataTypes.hasOwnProperty(word)) {150return 'builtin';151}152return "variable";153}154
155function tokenString(quote) {156return function(stream, state) {157var escaped = false, next, end = false;158while ((next = stream.next()) != null) {159if (next == quote && !escaped) {160end = true;161break;162}163escaped = !escaped && next == "\\";164}165if (end || !escaped) state.tokenize = null;166return "string";167};168}169
170// Interface171
172return {173startState: function() {174return {tokenize: null};175},176
177token: function(stream, state) {178if (stream.eatSpace()) return null;179var style = (state.tokenize || tokenBase)(stream, state);180if (style == "comment" || style == "meta") return style;181return style;182}183};184});185
186CodeMirror.defineMIME("text/x-fortran", "fortran");187
188});189