1package g
2
3import (
4	. "github.com/alecthomas/chroma" // nolint
5	"github.com/alecthomas/chroma/lexers/internal"
6)
7
8// Gherkin lexer.
9var Gherkin = internal.Register(MustNewLazyLexer(
10	&Config{
11		Name:      "Gherkin",
12		Aliases:   []string{"cucumber", "Cucumber", "gherkin", "Gherkin"},
13		Filenames: []string{"*.feature", "*.FEATURE"},
14		MimeTypes: []string{"text/x-gherkin"},
15	},
16	gherkinRules,
17))
18
19func gherkinRules() Rules {
20	stepKeywords := `^(\s*)(하지만|조건|먼저|만일|만약|단|그리고|그러면|那麼|那么|而且|當|当|前提|假設|假设|假如|假定|但是|但し|並且|并且|同時|同时|もし|ならば|ただし|しかし|かつ|و |متى |لكن |عندما |ثم |بفرض |اذاً |כאשר |וגם |בהינתן |אזי |אז |אבל |Якщо |Унда |То |Припустимо, що |Припустимо |Онда |Но |Нехай |Лекин |Когато |Када |Кад |К тому же |И |Задато |Задати |Задате |Если |Допустим |Дадено |Ва |Бирок |Аммо |Али |Але |Агар |А |І |Șis |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Youse know when youse got |Youse know like when |Yna |Ya know how |Ya gotta |Y |Wun |Wtedy |When y'all |When |Wenn |WEN |Và |Ve |Und |Un |Thì |Then y'all |Then |Tapi |Tak |Tada |Tad |Så |Stel |Soit |Siis |Si |Sed |Se |Quando |Quand |Quan |Pryd |Pokud |Pokiaľ |Però |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Når |När |Niin |Nhưng |N |Mutta |Men |Mas |Maka |Majd |Mais |Maar |Ma |Lorsque |Lorsqu'|Kun |Kuid |Kui |Khi |Keď |Ketika |Když |Kaj |Kai |Kada |Kad |Jeżeli |Ja |Ir |I CAN HAZ |I |Ha |Givun |Givet |Given y'all |Given |Gitt |Gegeven |Gegeben sei |Fakat |Eğer ki |Etant donné |Et |Então |Entonces |Entao |En |Eeldades |E |Duota |Dun |Donitaĵo |Donat |Donada |Do |Diyelim ki |Dengan |Den youse gotta |De |Dato |Dar |Dann |Dan |Dado |Dacă |Daca |DEN |Când |Cuando |Cho |Cept |Cand |Cal |But y'all |But |Buh |Biết |Bet |BUT |Atès |Atunci |Atesa |Anrhegedig a |Angenommen |And y'all |And |An |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Aber |AN |A také |A |\* )`
21
22	featureKeywords := `^(기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Фича|Особина|Могућност|Özellik|Właściwość|Tính năng|Trajto|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd)(:)(.*)$`
23
24	featureElementKeywords := `^(\s*)(시나리오 개요|시나리오|배경|背景|場景大綱|場景|场景大纲|场景|劇本大綱|劇本|剧本大纲|剧本|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|シナリオ|سيناريو مخطط|سيناريو|الخلفية|תרחיש|תבנית תרחיש|רקע|Тарих|Сценарій|Сценарио|Сценарий структураси|Сценарий|Структура сценарію|Структура сценарија|Структура сценария|Скица|Рамка на сценарий|Пример|Предыстория|Предистория|Позадина|Передумова|Основа|Концепт|Контекст|Założenia|Wharrimean is|Tình hung|The thing of it is|Tausta|Taust|Tapausaihio|Tapaus|Szenariogrundriss|Szenario|Szablon scenariusza|Stsenaarium|Struktura scenarija|Skica|Skenario konsep|Skenario|Situācija|Senaryo taslağı|Senaryo|Scénář|Scénario|Schema dello scenario|Scenārijs pēc parauga|Scenārijs|Scenár|Scenaro|Scenariusz|Scenariul de şablon|Scenariul de sablon|Scenariu|Scenario Outline|Scenario Amlinellol|Scenario|Scenarijus|Scenarijaus šablonas|Scenarij|Scenarie|Rerefons|Raamstsenaarium|Primer|Pozadí|Pozadina|Pozadie|Plan du scénario|Plan du Scénario|Osnova scénáře|Osnova|Náčrt Scénáře|Náčrt Scenáru|Mate|MISHUN SRSLY|MISHUN|Kch bn|Konturo de la scenaro|Kontext|Konteksts|Kontekstas|Kontekst|Koncept|Khung tình hung|Khung kch bn|Háttér|Grundlage|Geçmiş|Forgatókönyv vázlat|Forgatókönyv|Fono|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l'escenari|Escenario|Escenari|Dis is what went down|Dasar|Contexto|Contexte|Contesto|Condiţii|Conditii|Cenário|Cenario|Cefndir|Bi cnh|Blokes|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|All y'all|Achtergrond|Abstrakt Scenario|Abstract Scenario)(:)(.*)$`
25
26	examplesKeywords := `^(\s*)(예|例子|例|サンプル|امثلة|דוגמאות|Сценарији|Примери|Приклади|Мисоллар|Значения|Örnekler|Voorbeelden|Variantai|Tapaukset|Scenarios|Scenariji|Scenarijai|Příklady|Példák|Príklady|Przykłady|Primjeri|Primeri|Piemēri|Pavyzdžiai|Paraugs|Juhtumid|Exemplos|Exemples|Exemplele|Exempel|Examples|Esempi|Enghreifftiau|Ekzemploj|Eksempler|Ejemplos|EXAMPLZ|Dliu|Contoh|Cobber|Beispiele)(:)(.*)$`
27
28	return Rules{
29		"comments": {
30			{`\s*#.*$`, Comment, nil},
31		},
32		"featureElements": {
33			{stepKeywords, Keyword, Push("stepContentStack")},
34			Include("comments"),
35			{`(\s|.)`, NameFunction, nil},
36		},
37		"featureElementsOnStack": {
38			{stepKeywords, Keyword, Pop(2)},
39			Include("comments"),
40			{`(\s|.)`, NameFunction, nil},
41		},
42		"examplesTable": {
43			{`\s+\|`, Keyword, Push("examplesTableHeader")},
44			Include("comments"),
45			{`(\s|.)`, NameFunction, nil},
46		},
47		"examplesTableHeader": {
48			{`\s+\|\s*$`, Keyword, Pop(2)},
49			Include("comments"),
50			{`\\\|`, NameVariable, nil},
51			{`\s*\|`, Keyword, nil},
52			{`[^|]`, NameVariable, nil},
53		},
54		"scenarioSectionsOnStack": {
55			{featureElementKeywords, ByGroups(NameFunction, Keyword, Keyword, NameFunction), Push("featureElementsOnStack")},
56		},
57		"narrative": {
58			Include("scenarioSectionsOnStack"),
59			{`(\s|.)`, NameFunction, nil},
60		},
61		"tableVars": {
62			{`(<[^>]+>)`, NameVariable, nil},
63		},
64		"numbers": {
65			{`(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?`, LiteralString, nil},
66		},
67		"string": {
68			Include("tableVars"),
69			{`(\s|.)`, LiteralString, nil},
70		},
71		"pyString": {
72			{`"""`, Keyword, Pop(1)},
73			Include("string"),
74		},
75		"stepContentRoot": {
76			{`$`, Keyword, Pop(1)},
77			Include("stepContent"),
78		},
79		"stepContentStack": {
80			{`$`, Keyword, Pop(2)},
81			Include("stepContent"),
82		},
83		"stepContent": {
84			{`"`, NameFunction, Push("doubleString")},
85			Include("tableVars"),
86			Include("numbers"),
87			Include("comments"),
88			{`(\s|.)`, NameFunction, nil},
89		},
90		"tableContent": {
91			{`\s+\|\s*$`, Keyword, Pop(1)},
92			Include("comments"),
93			{`\\\|`, LiteralString, nil},
94			{`\s*\|`, Keyword, nil},
95			{`"`, LiteralString, Push("doubleStringTable")},
96			Include("string"),
97		},
98		"doubleString": {
99			{`"`, NameFunction, Pop(1)},
100			Include("string"),
101		},
102		"doubleStringTable": {
103			{`"`, LiteralString, Pop(1)},
104			Include("string"),
105		},
106		"root": {
107			{`\n`, NameFunction, nil},
108			Include("comments"),
109			{`"""`, Keyword, Push("pyString")},
110			{`\s+\|`, Keyword, Push("tableContent")},
111			{`"`, NameFunction, Push("doubleString")},
112			Include("tableVars"),
113			Include("numbers"),
114			{`(\s*)(@[^@\r\n\t ]+)`, ByGroups(NameFunction, NameTag), nil},
115			{stepKeywords, ByGroups(NameFunction, Keyword), Push("stepContentRoot")},
116			{featureKeywords, ByGroups(Keyword, Keyword, NameFunction), Push("narrative")},
117			{featureElementKeywords, ByGroups(NameFunction, Keyword, Keyword, NameFunction), Push("featureElements")},
118			{examplesKeywords, ByGroups(NameFunction, Keyword, Keyword, NameFunction), Push("examplesTable")},
119			{`(\s|.)`, NameFunction, nil},
120		},
121	}
122}
123