LaravelTest
255 строк · 10.1 Кб
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4/**
5* Author: Gautam Mehta
6* Branched from CodeMirror's Scheme mode
7*/
8(function(mod) {9if (typeof exports == "object" && typeof module == "object") // CommonJS10mod(require("../../lib/codemirror"));11else if (typeof define == "function" && define.amd) // AMD12define(["../../lib/codemirror"], mod);13else // Plain browser env14mod(CodeMirror);15})(function(CodeMirror) {16"use strict";17
18CodeMirror.defineMode("cobol", function () {19var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",20ATOM = "atom", NUMBER = "number", KEYWORD = "keyword", MODTAG = "header",21COBOLLINENUM = "def", PERIOD = "link";22function makeKeywords(str) {23var obj = {}, words = str.split(" ");24for (var i = 0; i < words.length; ++i) obj[words[i]] = true;25return obj;26}27var atoms = makeKeywords("TRUE FALSE ZEROES ZEROS ZERO SPACES SPACE LOW-VALUE LOW-VALUES ");28var keywords = makeKeywords(29"ACCEPT ACCESS ACQUIRE ADD ADDRESS " +30"ADVANCING AFTER ALIAS ALL ALPHABET " +31"ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER ALPHANUMERIC ALPHANUMERIC-EDITED " +32"ALSO ALTER ALTERNATE AND ANY " +33"ARE AREA AREAS ARITHMETIC ASCENDING " +34"ASSIGN AT ATTRIBUTE AUTHOR AUTO " +35"AUTO-SKIP AUTOMATIC B-AND B-EXOR B-LESS " +36"B-NOT B-OR BACKGROUND-COLOR BACKGROUND-COLOUR BEEP " +37"BEFORE BELL BINARY BIT BITS " +38"BLANK BLINK BLOCK BOOLEAN BOTTOM " +39"BY CALL CANCEL CD CF " +40"CH CHARACTER CHARACTERS CLASS CLOCK-UNITS " +41"CLOSE COBOL CODE CODE-SET COL " +42"COLLATING COLUMN COMMA COMMIT COMMITMENT " +43"COMMON COMMUNICATION COMP COMP-0 COMP-1 " +44"COMP-2 COMP-3 COMP-4 COMP-5 COMP-6 " +45"COMP-7 COMP-8 COMP-9 COMPUTATIONAL COMPUTATIONAL-0 " +46"COMPUTATIONAL-1 COMPUTATIONAL-2 COMPUTATIONAL-3 COMPUTATIONAL-4 COMPUTATIONAL-5 " +47"COMPUTATIONAL-6 COMPUTATIONAL-7 COMPUTATIONAL-8 COMPUTATIONAL-9 COMPUTE " +48"CONFIGURATION CONNECT CONSOLE CONTAINED CONTAINS " +49"CONTENT CONTINUE CONTROL CONTROL-AREA CONTROLS " +50"CONVERTING COPY CORR CORRESPONDING COUNT " +51"CRT CRT-UNDER CURRENCY CURRENT CURSOR " +52"DATA DATE DATE-COMPILED DATE-WRITTEN DAY " +53"DAY-OF-WEEK DB DB-ACCESS-CONTROL-KEY DB-DATA-NAME DB-EXCEPTION " +54"DB-FORMAT-NAME DB-RECORD-NAME DB-SET-NAME DB-STATUS DBCS " +55"DBCS-EDITED DE DEBUG-CONTENTS DEBUG-ITEM DEBUG-LINE " +56"DEBUG-NAME DEBUG-SUB-1 DEBUG-SUB-2 DEBUG-SUB-3 DEBUGGING " +57"DECIMAL-POINT DECLARATIVES DEFAULT DELETE DELIMITED " +58"DELIMITER DEPENDING DESCENDING DESCRIBED DESTINATION " +59"DETAIL DISABLE DISCONNECT DISPLAY DISPLAY-1 " +60"DISPLAY-2 DISPLAY-3 DISPLAY-4 DISPLAY-5 DISPLAY-6 " +61"DISPLAY-7 DISPLAY-8 DISPLAY-9 DIVIDE DIVISION " +62"DOWN DROP DUPLICATE DUPLICATES DYNAMIC " +63"EBCDIC EGI EJECT ELSE EMI " +64"EMPTY EMPTY-CHECK ENABLE END END. END-ACCEPT END-ACCEPT. " +65"END-ADD END-CALL END-COMPUTE END-DELETE END-DISPLAY " +66"END-DIVIDE END-EVALUATE END-IF END-INVOKE END-MULTIPLY " +67"END-OF-PAGE END-PERFORM END-READ END-RECEIVE END-RETURN " +68"END-REWRITE END-SEARCH END-START END-STRING END-SUBTRACT " +69"END-UNSTRING END-WRITE END-XML ENTER ENTRY " +70"ENVIRONMENT EOP EQUAL EQUALS ERASE " +71"ERROR ESI EVALUATE EVERY EXCEEDS " +72"EXCEPTION EXCLUSIVE EXIT EXTEND EXTERNAL " +73"EXTERNALLY-DESCRIBED-KEY FD FETCH FILE FILE-CONTROL " +74"FILE-STREAM FILES FILLER FINAL FIND " +75"FINISH FIRST FOOTING FOR FOREGROUND-COLOR " +76"FOREGROUND-COLOUR FORMAT FREE FROM FULL " +77"FUNCTION GENERATE GET GIVING GLOBAL " +78"GO GOBACK GREATER GROUP HEADING " +79"HIGH-VALUE HIGH-VALUES HIGHLIGHT I-O I-O-CONTROL " +80"ID IDENTIFICATION IF IN INDEX " +81"INDEX-1 INDEX-2 INDEX-3 INDEX-4 INDEX-5 " +82"INDEX-6 INDEX-7 INDEX-8 INDEX-9 INDEXED " +83"INDIC INDICATE INDICATOR INDICATORS INITIAL " +84"INITIALIZE INITIATE INPUT INPUT-OUTPUT INSPECT " +85"INSTALLATION INTO INVALID INVOKE IS " +86"JUST JUSTIFIED KANJI KEEP KEY " +87"LABEL LAST LD LEADING LEFT " +88"LEFT-JUSTIFY LENGTH LENGTH-CHECK LESS LIBRARY " +89"LIKE LIMIT LIMITS LINAGE LINAGE-COUNTER " +90"LINE LINE-COUNTER LINES LINKAGE LOCAL-STORAGE " +91"LOCALE LOCALLY LOCK " +92"MEMBER MEMORY MERGE MESSAGE METACLASS " +93"MODE MODIFIED MODIFY MODULES MOVE " +94"MULTIPLE MULTIPLY NATIONAL NATIVE NEGATIVE " +95"NEXT NO NO-ECHO NONE NOT " +96"NULL NULL-KEY-MAP NULL-MAP NULLS NUMBER " +97"NUMERIC NUMERIC-EDITED OBJECT OBJECT-COMPUTER OCCURS " +98"OF OFF OMITTED ON ONLY " +99"OPEN OPTIONAL OR ORDER ORGANIZATION " +100"OTHER OUTPUT OVERFLOW OWNER PACKED-DECIMAL " +101"PADDING PAGE PAGE-COUNTER PARSE PERFORM " +102"PF PH PIC PICTURE PLUS " +103"POINTER POSITION POSITIVE PREFIX PRESENT " +104"PRINTING PRIOR PROCEDURE PROCEDURE-POINTER PROCEDURES " +105"PROCEED PROCESS PROCESSING PROGRAM PROGRAM-ID " +106"PROMPT PROTECTED PURGE QUEUE QUOTE " +107"QUOTES RANDOM RD READ READY " +108"REALM RECEIVE RECONNECT RECORD RECORD-NAME " +109"RECORDS RECURSIVE REDEFINES REEL REFERENCE " +110"REFERENCE-MONITOR REFERENCES RELATION RELATIVE RELEASE " +111"REMAINDER REMOVAL RENAMES REPEATED REPLACE " +112"REPLACING REPORT REPORTING REPORTS REPOSITORY " +113"REQUIRED RERUN RESERVE RESET RETAINING " +114"RETRIEVAL RETURN RETURN-CODE RETURNING REVERSE-VIDEO " +115"REVERSED REWIND REWRITE RF RH " +116"RIGHT RIGHT-JUSTIFY ROLLBACK ROLLING ROUNDED " +117"RUN SAME SCREEN SD SEARCH " +118"SECTION SECURE SECURITY SEGMENT SEGMENT-LIMIT " +119"SELECT SEND SENTENCE SEPARATE SEQUENCE " +120"SEQUENTIAL SET SHARED SIGN SIZE " +121"SKIP1 SKIP2 SKIP3 SORT SORT-MERGE " +122"SORT-RETURN SOURCE SOURCE-COMPUTER SPACE-FILL " +123"SPECIAL-NAMES STANDARD STANDARD-1 STANDARD-2 " +124"START STARTING STATUS STOP STORE " +125"STRING SUB-QUEUE-1 SUB-QUEUE-2 SUB-QUEUE-3 SUB-SCHEMA " +126"SUBFILE SUBSTITUTE SUBTRACT SUM SUPPRESS " +127"SYMBOLIC SYNC SYNCHRONIZED SYSIN SYSOUT " +128"TABLE TALLYING TAPE TENANT TERMINAL " +129"TERMINATE TEST TEXT THAN THEN " +130"THROUGH THRU TIME TIMES TITLE " +131"TO TOP TRAILING TRAILING-SIGN TRANSACTION " +132"TYPE TYPEDEF UNDERLINE UNEQUAL UNIT " +133"UNSTRING UNTIL UP UPDATE UPON " +134"USAGE USAGE-MODE USE USING VALID " +135"VALIDATE VALUE VALUES VARYING VLR " +136"WAIT WHEN WHEN-COMPILED WITH WITHIN " +137"WORDS WORKING-STORAGE WRITE XML XML-CODE " +138"XML-EVENT XML-NTEXT XML-TEXT ZERO ZERO-FILL " );139
140var builtins = makeKeywords("- * ** / + < <= = > >= ");141var tests = {142digit: /\d/,143digit_or_colon: /[\d:]/,144hex: /[0-9a-f]/i,145sign: /[+-]/,146exponent: /e/i,147keyword_char: /[^\s\(\[\;\)\]]/,148symbol: /[\w*+\-]/149};150function isNumber(ch, stream){151// hex152if ( ch === '0' && stream.eat(/x/i) ) {153stream.eatWhile(tests.hex);154return true;155}156// leading sign157if ( ( ch == '+' || ch == '-' ) && ( tests.digit.test(stream.peek()) ) ) {158stream.eat(tests.sign);159ch = stream.next();160}161if ( tests.digit.test(ch) ) {162stream.eat(ch);163stream.eatWhile(tests.digit);164if ( '.' == stream.peek()) {165stream.eat('.');166stream.eatWhile(tests.digit);167}168if ( stream.eat(tests.exponent) ) {169stream.eat(tests.sign);170stream.eatWhile(tests.digit);171}172return true;173}174return false;175}176return {177startState: function () {178return {179indentStack: null,180indentation: 0,181mode: false182};183},184token: function (stream, state) {185if (state.indentStack == null && stream.sol()) {186// update indentation, but only if indentStack is empty187state.indentation = 6 ; //stream.indentation();188}189// skip spaces190if (stream.eatSpace()) {191return null;192}193var returnType = null;194switch(state.mode){195case "string": // multi-line string parsing mode196var next = false;197while ((next = stream.next()) != null) {198if ((next == "\"" || next == "\'") && !stream.match(/['"]/, false)) {199state.mode = false;200break;201}202}203returnType = STRING; // continue on in string mode204break;205default: // default parsing mode206var ch = stream.next();207var col = stream.column();208if (col >= 0 && col <= 5) {209returnType = COBOLLINENUM;210} else if (col >= 72 && col <= 79) {211stream.skipToEnd();212returnType = MODTAG;213} else if (ch == "*" && col == 6) { // comment214stream.skipToEnd(); // rest of the line is a comment215returnType = COMMENT;216} else if (ch == "\"" || ch == "\'") {217state.mode = "string";218returnType = STRING;219} else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) {220returnType = ATOM;221} else if (ch == ".") {222returnType = PERIOD;223} else if (isNumber(ch,stream)){224returnType = NUMBER;225} else {226if (stream.current().match(tests.symbol)) {227while (col < 71) {228if (stream.eat(tests.symbol) === undefined) {229break;230} else {231col++;232}233}234}235if (keywords && keywords.propertyIsEnumerable(stream.current().toUpperCase())) {236returnType = KEYWORD;237} else if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase())) {238returnType = BUILTIN;239} else if (atoms && atoms.propertyIsEnumerable(stream.current().toUpperCase())) {240returnType = ATOM;241} else returnType = null;242}243}244return returnType;245},246indent: function (state) {247if (state.indentStack == null) return state.indentation;248return state.indentStack.indent;249}250};251});252
253CodeMirror.defineMIME("text/x-cobol", "cobol");254
255});256