LaravelTest
214 строк · 7.7 Кб
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("ttcn-cfg", function(config, parserConfig) {15var indentUnit = config.indentUnit,16keywords = parserConfig.keywords || {},17fileNCtrlMaskOptions = parserConfig.fileNCtrlMaskOptions || {},18externalCommands = parserConfig.externalCommands || {},19multiLineStrings = parserConfig.multiLineStrings,20indentStatements = parserConfig.indentStatements !== false;21var isOperatorChar = /[\|]/;22var curPunc;23
24function tokenBase(stream, state) {25var ch = stream.next();26if (ch == '"' || ch == "'") {27state.tokenize = tokenString(ch);28return state.tokenize(stream, state);29}30if (/[:=]/.test(ch)) {31curPunc = ch;32return "punctuation";33}34if (ch == "#"){35stream.skipToEnd();36return "comment";37}38if (/\d/.test(ch)) {39stream.eatWhile(/[\w\.]/);40return "number";41}42if (isOperatorChar.test(ch)) {43stream.eatWhile(isOperatorChar);44return "operator";45}46if (ch == "["){47stream.eatWhile(/[\w_\]]/);48return "number sectionTitle";49}50
51stream.eatWhile(/[\w\$_]/);52var cur = stream.current();53if (keywords.propertyIsEnumerable(cur)) return "keyword";54if (fileNCtrlMaskOptions.propertyIsEnumerable(cur))55return "negative fileNCtrlMaskOptions";56if (externalCommands.propertyIsEnumerable(cur)) return "negative externalCommands";57
58return "variable";59}60
61function tokenString(quote) {62return function(stream, state) {63var escaped = false, next, end = false;64while ((next = stream.next()) != null) {65if (next == quote && !escaped){66var afterNext = stream.peek();67//look if the character if the quote is like the B in '10100010'B68if (afterNext){69afterNext = afterNext.toLowerCase();70if(afterNext == "b" || afterNext == "h" || afterNext == "o")71stream.next();72}73end = true; break;74}75escaped = !escaped && next == "\\";76}77if (end || !(escaped || multiLineStrings))78state.tokenize = null;79return "string";80};81}82
83function Context(indented, column, type, align, prev) {84this.indented = indented;85this.column = column;86this.type = type;87this.align = align;88this.prev = prev;89}90function pushContext(state, col, type) {91var indent = state.indented;92if (state.context && state.context.type == "statement")93indent = state.context.indented;94return state.context = new Context(indent, col, type, null, state.context);95}96function popContext(state) {97var t = state.context.type;98if (t == ")" || t == "]" || t == "}")99state.indented = state.context.indented;100return state.context = state.context.prev;101}102
103//Interface104return {105startState: function(basecolumn) {106return {107tokenize: null,108context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),109indented: 0,110startOfLine: true111};112},113
114token: function(stream, state) {115var ctx = state.context;116if (stream.sol()) {117if (ctx.align == null) ctx.align = false;118state.indented = stream.indentation();119state.startOfLine = true;120}121if (stream.eatSpace()) return null;122curPunc = null;123var style = (state.tokenize || tokenBase)(stream, state);124if (style == "comment") return style;125if (ctx.align == null) ctx.align = true;126
127if ((curPunc == ";" || curPunc == ":" || curPunc == ",")128&& ctx.type == "statement"){129popContext(state);130}131else if (curPunc == "{") pushContext(state, stream.column(), "}");132else if (curPunc == "[") pushContext(state, stream.column(), "]");133else if (curPunc == "(") pushContext(state, stream.column(), ")");134else if (curPunc == "}") {135while (ctx.type == "statement") ctx = popContext(state);136if (ctx.type == "}") ctx = popContext(state);137while (ctx.type == "statement") ctx = popContext(state);138}139else if (curPunc == ctx.type) popContext(state);140else if (indentStatements && (((ctx.type == "}" || ctx.type == "top")141&& curPunc != ';') || (ctx.type == "statement"142&& curPunc == "newstatement")))143pushContext(state, stream.column(), "statement");144state.startOfLine = false;145return style;146},147
148electricChars: "{}",149lineComment: "#",150fold: "brace"151};152});153
154function words(str) {155var obj = {}, words = str.split(" ");156for (var i = 0; i < words.length; ++i)157obj[words[i]] = true;158return obj;159}160
161CodeMirror.defineMIME("text/x-ttcn-cfg", {162name: "ttcn-cfg",163keywords: words("Yes No LogFile FileMask ConsoleMask AppendFile" +164" TimeStampFormat LogEventTypes SourceInfoFormat" +165" LogEntityName LogSourceInfo DiskFullAction" +166" LogFileNumber LogFileSize MatchingHints Detailed" +167" Compact SubCategories Stack Single None Seconds" +168" DateTime Time Stop Error Retry Delete TCPPort KillTimer" +169" NumHCs UnixSocketsEnabled LocalAddress"),170fileNCtrlMaskOptions: words("TTCN_EXECUTOR TTCN_ERROR TTCN_WARNING" +171" TTCN_PORTEVENT TTCN_TIMEROP TTCN_VERDICTOP" +172" TTCN_DEFAULTOP TTCN_TESTCASE TTCN_ACTION" +173" TTCN_USER TTCN_FUNCTION TTCN_STATISTICS" +174" TTCN_PARALLEL TTCN_MATCHING TTCN_DEBUG" +175" EXECUTOR ERROR WARNING PORTEVENT TIMEROP" +176" VERDICTOP DEFAULTOP TESTCASE ACTION USER" +177" FUNCTION STATISTICS PARALLEL MATCHING DEBUG" +178" LOG_ALL LOG_NOTHING ACTION_UNQUALIFIED" +179" DEBUG_ENCDEC DEBUG_TESTPORT" +180" DEBUG_UNQUALIFIED DEFAULTOP_ACTIVATE" +181" DEFAULTOP_DEACTIVATE DEFAULTOP_EXIT" +182" DEFAULTOP_UNQUALIFIED ERROR_UNQUALIFIED" +183" EXECUTOR_COMPONENT EXECUTOR_CONFIGDATA" +184" EXECUTOR_EXTCOMMAND EXECUTOR_LOGOPTIONS" +185" EXECUTOR_RUNTIME EXECUTOR_UNQUALIFIED" +186" FUNCTION_RND FUNCTION_UNQUALIFIED" +187" MATCHING_DONE MATCHING_MCSUCCESS" +188" MATCHING_MCUNSUCC MATCHING_MMSUCCESS" +189" MATCHING_MMUNSUCC MATCHING_PCSUCCESS" +190" MATCHING_PCUNSUCC MATCHING_PMSUCCESS" +191" MATCHING_PMUNSUCC MATCHING_PROBLEM" +192" MATCHING_TIMEOUT MATCHING_UNQUALIFIED" +193" PARALLEL_PORTCONN PARALLEL_PORTMAP" +194" PARALLEL_PTC PARALLEL_UNQUALIFIED" +195" PORTEVENT_DUALRECV PORTEVENT_DUALSEND" +196" PORTEVENT_MCRECV PORTEVENT_MCSEND" +197" PORTEVENT_MMRECV PORTEVENT_MMSEND" +198" PORTEVENT_MQUEUE PORTEVENT_PCIN" +199" PORTEVENT_PCOUT PORTEVENT_PMIN" +200" PORTEVENT_PMOUT PORTEVENT_PQUEUE" +201" PORTEVENT_STATE PORTEVENT_UNQUALIFIED" +202" STATISTICS_UNQUALIFIED STATISTICS_VERDICT" +203" TESTCASE_FINISH TESTCASE_START" +204" TESTCASE_UNQUALIFIED TIMEROP_GUARD" +205" TIMEROP_READ TIMEROP_START TIMEROP_STOP" +206" TIMEROP_TIMEOUT TIMEROP_UNQUALIFIED" +207" USER_UNQUALIFIED VERDICTOP_FINAL" +208" VERDICTOP_GETVERDICT VERDICTOP_SETVERDICT" +209" VERDICTOP_UNQUALIFIED WARNING_UNQUALIFIED"),210externalCommands: words("BeginControlPart EndControlPart BeginTestCase" +211" EndTestCase"),212multiLineStrings: true213});214});