// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
/*
Gherkin mode - http://www.cukes.info/
Report bugs/issues here: https://github.com/codemirror/CodeMirror/issues
*/
// Following Objs from Brackets implementation: https://github.com/tregusti/brackets-gherkin/blob/master/main.js
//var Quotes = {
// SINGLE: 1,
// DOUBLE: 2
//};
//var regex = {
// keywords: /(Feature| {2}(Scenario|In order to|As|I)| {4}(Given|When|Then|And))/
//};
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
CodeMirror.defineMode("gherkin", function () {
return {
startState: function () {
return {
lineNumber: 0,
tableHeaderLine: false,
allowFeature: true,
allowBackground: false,
allowScenario: false,
allowSteps: false,
allowPlaceholders: false,
allowMultilineArgument: false,
inMultilineString: false,
inMultilineTable: false,
inKeywordLine: false
};
},
token: function (stream, state) {
if (stream.sol()) {
state.lineNumber++;
state.inKeywordLine = false;
if (state.inMultilineTable) {
state.tableHeaderLine = false;
if (!stream.match(/\s*\|/, false)) {
state.allowMultilineArgument = false;
state.inMultilineTable = false;
}
}
}
stream.eatSpace();
if (state.allowMultilineArgument) {
// STRING
if (state.inMultilineString) {
if (stream.match('"""')) {
state.inMultilineString = false;
state.allowMultilineArgument = false;
} else {
stream.match(/.*/);
}
return "string";
}
// TABLE
if (state.inMultilineTable) {
if (stream.match(/\|\s*/)) {
return "bracket";
} else {
stream.match(/[^\|]*/);
return state.tableHeaderLine ? "header" : "string";
}
}
// DETECT START
if (stream.match('"""')) {
// String
state.inMultilineString = true;
return "string";
} else if (stream.match("|")) {
// Table
state.inMultilineTable = true;
state.tableHeaderLine = true;
return "bracket";
}
}
// LINE COMMENT
if (stream.match(/#.*/)) {
return "comment";
// TAG
} else if (!state.inKeywordLine && stream.match(/@\S+/)) {
return "tag";
// FEATURE
} else if (!state.inKeywordLine && state.allowFeature && stream.match(/(??|??|?????|??|????????|??????????|????????????????????|??????|?????|????????|??? ?????|??????|??? ???|??????|?????|?????|??????????|???????|??????????????|??????????|??????????????|????????|???????|?????????|?????????|??????????|??????????|W?a?ciwo??|Vlastnos?|Trajto|Tính n?ng|Savyb?|Pretty much|Po?iadavka|Po?adavek|Potrzeba biznesowa|Özellik|Osobina|Ominaisuus|Omadus|OH HAI|Mogu?nost|Mogucnost|Jellemz?|Hwćt|Hwaet|Funzionalitŕ|Funktionalitéit|Funktionalität|Funkcja|Funkcionalnost|Funkcionalit?te|Funkcia|Fungsi|Functionaliteit|Func?ionalitate|Func?ionalitate|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|F??a|Feature|Eiginleiki|Egenskap|Egenskab|Característica|Caracteristica|Business Need|Aspekt|Arwedd|Ahoy matey!|Ability):/)) {
state.allowScenario = true;
state.allowBackground = true;
state.allowPlaceholders = false;
state.allowSteps = false;
state.allowMultilineArgument = false;
state.inKeywordLine = true;
return "keyword";
// BACKGROUND
} else if (!state.inKeywordLine && state.allowBackground && stream.match(/(??|??|??????|????????|???????|??????|?????????|?????|???????|???|?????|???????????|???????????|????????|??????????|??????|????????|?????|????????|Za?o?enia|Yo\-ho\-ho|Tausta|Taust|Situ?cija|Rerefons|Pozadina|Pozadie|Pozadí|Osnova|Latar Belakang|Kontext|Konteksts|Kontekstas|Kontekst|Háttér|Hannergrond|Grundlage|Geçmi?|Fundo|Fono|First off|Dis is what went down|Dasar|Contexto|Contexte|Context|Contesto|Cenário de Fundo|Cenario de Fundo|Cefndir|B?i c?nh|Bakgrunnur|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|Ćr|Aer|Achtergrond):/)) {
state.allowPlaceholders = false;
state.allowSteps = true;
state.allowBackground = false;
state.allowMultilineArgument = false;
state.inKeywordLine = true;
return "keyword";
// SCENARIO OUTLINE
} else if (!state.inKeywordLine && state.allowScenario && stream.match(/(????|????|????|????|????|??????????|????????|??????????|???? ??|?????????????|?????????????????????|??????|????|????? ??? ????|????? ?????|???????? ???????|??????? ????|????? ??????|????? ?????|??????????? ????????|???????? ???????????|????????? ????????|????????? ????????|????????? ?????????|?????|????? ?? ????????|???????|????????? ????????|Wharrimean is|Template Situai|Template Senario|Template Keadaan|Tapausaihio|Szenariogrundriss|Szablon scenariusza|Swa hwćr swa|Swa hwaer swa|Struktura scenarija|Structur? scenariu|Structura scenariu|Skica|Skenario konsep|Shiver me timbers|Senaryo tasla??|Schema dello scenario|Scenariomall|Scenariomal|Scenario Template|Scenario Outline|Scenario Amlinellol|Scen?rijs p?c parauga|Scenarijaus ?ablonas|Reckon it's like|Raamstsenaarium|Plang vum Szenario|Plan du Scénario|Plan du scénario|Osnova scéná?e|Osnova Scenára|Ná?rt Scenáru|Ná?rt Scéná?e|Ná?rt Scenára|MISHUN SRSLY|Menggariskan Senario|Lýsing Dćma|Lýsing Atburđarásar|Konturo de la scenaro|Koncept|Khung těnh hu?ng|Khung k?ch b?n|Forgatókönyv vázlat|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l'escenari|Esbozo do escenario|Delineaçăo do Cenário|Delineacao do Cenario|All y'all|Abstrakt Scenario|Abstract Scenario):/)) {
state.allowPlaceholders = true;
state.allowSteps = true;
state.allowMultilineArgument = false;
state.inKeywordLine = true;
return "keyword";
// EXAMPLES
} else if (state.allowScenario && stream.match(/(??|?|????|?|???????????????|??????????????|??????????|????????|????????|??????|????? ??|?????|???????|????????|?????????|???????|???????|????????|????????|????????|???????|????????????|You'll wanna|Voorbeelden|Variantai|Tapaukset|Se ţe|Se the|Se đe|Scenarios|Scenariji|Scenarijai|Przyk?ady|Primjeri|Primeri|P?íklady|Príklady|Piem?ri|Példák|Pavyzd?iai|Paraugs|Örnekler|Juhtumid|Exemplos|Exemples|Exemple|Exempel|EXAMPLZ|Examples|Esempi|Enghreifftiau|Ekzemploj|Eksempler|Ejemplos|D? li?u|Dead men tell no tales|Dćmi|Contoh|Cenários|Cenarios|Beispiller|Beispiele|Atburđarásir):/)) {
state.allowPlaceholders = false;
state.allowSteps = true;
state.allowBackground = false;
state.allowMultilineArgument = true;
return "keyword";
// SCENARIO
} else if (!state.inKeywordLine && state.allowScenario && stream.match(/(??|??|??|??|????|????|?????????|?????????|?????????|?????|????????|???????|??????|?????|????????|????????|????????|??????|???????|Těnh hu?ng|The thing of it is|Tapaus|Szenario|Swa|Stsenaarium|Skenario|Situai|Senaryo|Senario|Scenaro|Scenariusz|Scenariu|Scénario|Scenario|Scenarijus|Scen?rijs|Scenarij|Scenarie|Scéná?|Scenár|Primer|MISHUN|K?ch b?n|Keadaan|Heave to|Forgatókönyv|Escenario|Escenari|Cenário|Cenario|Awww, look mate|Atburđarás):/)) {
state.allowPlaceholders = false;
state.allowSteps = true;
state.allowBackground = false;
state.allowMultilineArgument = false;
state.inKeywordLine = true;
return "keyword";
// STEPS
} else if (!state.inKeywordLine && state.allowSteps && stream.match(/(??|??|??|?|?|??|??|??|??|??|??|??|??|??|??|??|??|???|???|???|??|???|??|??|??|??|?|???|???|??? |????? |??? |??????? |???????? |??????????? |????? |?????? |???? |???? |????? |??????????? |???? |? ??????????? |??????? |?? |?? |???? |????? ?? |???? |??? |??? |?????? |?? |?? |??? |??? |?? |????? |?????? |??? |?? |??? |? |?????? |??? |??? |????? |?? |???? |?? ??? |??? |???? |????? |???? |??? |?????? |??? |?? |??? |???? |??? |???? |???? |????? |?? |????? |?? |????? |??????????, ?? |?????????? |???? |?? |????? |???????? |????? |????? |???? |????? |?????? |???? |??? |? ???? ?? |? |? |?????? |?????? |?????? |???? |???????? |???? |?????? |?? |?? |????? |???? |????? |???? |???? |??? |??? |???? |? ????? |? |???? |???? |??? |????????? |???? |Ţurh |Ţegar |Ţa ţe |Ţá |Ţa |Zatati |Zak?adaj?c |Zadato |Zadate |Zadano |Zadani |Zadan |Za p?edpokladu |Za predpokladu |Youse know when youse got |Youse know like when |Yna |Yeah nah |Y'know |Y |Wun |Wtedy |When y'all |When |Wenn |WEN |wann |Ve |Vŕ |Und |Un |ugeholl |Too right |Thurh |Thě |Then y'all |Then |Tha the |Tha |Tetapi |Tapi |Tak |Tada |Tad |Stel |Soit |Siis |?i |?i |Si |Sed |Se |Sĺ |Quando |Quand |Quan |Pryd |Potom |Pokud |Pokia? |Perň |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Niin |Nh?ng |När |Nĺr |Mutta |Men |Mas |Maka |Majd |Maj?c |Mais |Maar |mä |Ma |Lorsque |Lorsqu'|Logo |Let go and haul |Kun |Kuid |Kui |Kiedy |Khi |Ketika |Kemudian |Ke? |Kdy? |Kaj |Kai |Kada |Kad |Je?eli |Je?li |Ja |It's just unbelievable |Ir |I CAN HAZ |I |Ha |Givun |Givet |Given y'all |Given |Gitt |Gegeven |Gegeben seien |Gegeben sei |Gdy |Gangway! |Fakat |Étant donnés |Etant donnés |Étant données |Etant données |Étant donnée |Etant donnée |Étant donné |Etant donné |Et |És |Entonces |Entón |Entăo |Entao |En |E?er ki |Ef |Eeldades |E |Đurh |Duota |Dun |Donita?o |Donat |Donada |Do |Diyelim ki |Diberi |Dengan |Den youse gotta |DEN |De |Dato |Da?i fiind |Da?i fiind |Dati fiind |Dati |Date fiind |Date |Data |Dat fiind |Dar |Dann |dann |Dan |Dados |Dado |Dadas |Dada |Đa đe |Đa |Cuando |Cho |Cando |Când |Cand |Cal |But y'all |But at the end of the day I reckon |BUT |But |Buh |Blimey! |Bi?t |Bet |Bagi |Aye |awer |Avast! |Atunci |Atesa |Atčs |Apabila |Anrhegedig a |Angenommen |And y'all |And |AN |An |an |Amikor |Amennyiben |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Ak |Adott |Ac |Aber |A zárove? |A tie? |A taktie? |A také |A |a |7 |\* )/)) {
state.inStep = true;
state.allowPlaceholders = true;
state.allowMultilineArgument = true;
state.inKeywordLine = true;
return "keyword";
// INLINE STRING
} else if (stream.match(/"[^"]*"?/)) {
return "string";
// PLACEHOLDER
} else if (state.allowPlaceholders && stream.match(/<[^>]*>?/)) {
return "variable";
// Fall through
} else {
stream.next();
stream.eatWhile(/[^@"<#]/);
return null;
}
}
};
});
CodeMirror.defineMIME("text/x-feature", "gherkin");
});
|