You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gherkin.go 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package g
  2. import (
  3. . "github.com/alecthomas/chroma" // nolint
  4. "github.com/alecthomas/chroma/lexers/internal"
  5. )
  6. var stepKeywords = `^(\s*)(하지만|조건|먼저|만일|만약|단|그리고|그러면|那麼|那么|而且|當|当|前提|假設|假设|假如|假定|但是|但し|並且|并且|同時|同时|もし|ならば|ただし|しかし|かつ|و |متى |لكن |عندما |ثم |بفرض |اذاً |כאשר |וגם |בהינתן |אזי |אז |אבל |Якщо |Унда |То |Припустимо, що |Припустимо |Онда |Но |Нехай |Лекин |Когато |Када |Кад |К тому же |И |Задато |Задати |Задате |Если |Допустим |Дадено |Ва |Бирок |Аммо |Али |Але |Агар |А |І |Și |És |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 |\* )`
  7. var 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)(:)(.*)$`
  8. var featureElementKeywords = `^(\s*)(시나리오 개요|시나리오|배경|背景|場景大綱|場景|场景大纲|场景|劇本大綱|劇本|剧本大纲|剧本|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|シナリオ|سيناريو مخطط|سيناريو|الخلفية|תרחיש|תבנית תרחיש|רקע|Тарих|Сценарій|Сценарио|Сценарий структураси|Сценарий|Структура сценарію|Структура сценарија|Структура сценария|Скица|Рамка на сценарий|Пример|Предыстория|Предистория|Позадина|Передумова|Основа|Концепт|Контекст|Założenia|Wharrimean is|Tình huống|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|Kịch bản|Konturo de la scenaro|Kontext|Konteksts|Kontekstas|Kontekst|Koncept|Khung tình huống|Khung kịch bản|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|Bối cảnh|Blokes|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|All y'all|Achtergrond|Abstrakt Scenario|Abstract Scenario)(:)(.*)$`
  9. var 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|Dữ liệu|Contoh|Cobber|Beispiele)(:)(.*)$`
  10. // Gherkin lexer.
  11. var Gherkin = internal.Register(MustNewLexer(
  12. &Config{
  13. Name: "Gherkin",
  14. Aliases: []string{"cucumber", "Cucumber", "gherkin", "Gherkin"},
  15. Filenames: []string{"*.feature", "*.FEATURE"},
  16. MimeTypes: []string{"text/x-gherkin"},
  17. },
  18. Rules{
  19. "comments": {
  20. {`\s*#.*$`, Comment, nil},
  21. },
  22. "featureElements": {
  23. {stepKeywords, Keyword, Push("stepContentStack")},
  24. Include("comments"),
  25. {`(\s|.)`, NameFunction, nil},
  26. },
  27. "featureElementsOnStack": {
  28. {stepKeywords, Keyword, Pop(2)},
  29. Include("comments"),
  30. {`(\s|.)`, NameFunction, nil},
  31. },
  32. "examplesTable": {
  33. {`\s+\|`, Keyword, Push("examplesTableHeader")},
  34. Include("comments"),
  35. {`(\s|.)`, NameFunction, nil},
  36. },
  37. "examplesTableHeader": {
  38. {`\s+\|\s*$`, Keyword, Pop(2)},
  39. Include("comments"),
  40. {`\\\|`, NameVariable, nil},
  41. {`\s*\|`, Keyword, nil},
  42. {`[^|]`, NameVariable, nil},
  43. },
  44. "scenarioSectionsOnStack": {
  45. {featureElementKeywords, ByGroups(NameFunction, Keyword, Keyword, NameFunction), Push("featureElementsOnStack")},
  46. },
  47. "narrative": {
  48. Include("scenarioSectionsOnStack"),
  49. {`(\s|.)`, NameFunction, nil},
  50. },
  51. "tableVars": {
  52. {`(<[^>]+>)`, NameVariable, nil},
  53. },
  54. "numbers": {
  55. {`(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?`, LiteralString, nil},
  56. },
  57. "string": {
  58. Include("tableVars"),
  59. {`(\s|.)`, LiteralString, nil},
  60. },
  61. "pyString": {
  62. {`"""`, Keyword, Pop(1)},
  63. Include("string"),
  64. },
  65. "stepContentRoot": {
  66. {`$`, Keyword, Pop(1)},
  67. Include("stepContent"),
  68. },
  69. "stepContentStack": {
  70. {`$`, Keyword, Pop(2)},
  71. Include("stepContent"),
  72. },
  73. "stepContent": {
  74. {`"`, NameFunction, Push("doubleString")},
  75. Include("tableVars"),
  76. Include("numbers"),
  77. Include("comments"),
  78. {`(\s|.)`, NameFunction, nil},
  79. },
  80. "tableContent": {
  81. {`\s+\|\s*$`, Keyword, Pop(1)},
  82. Include("comments"),
  83. {`\\\|`, LiteralString, nil},
  84. {`\s*\|`, Keyword, nil},
  85. {`"`, LiteralString, Push("doubleStringTable")},
  86. Include("string"),
  87. },
  88. "doubleString": {
  89. {`"`, NameFunction, Pop(1)},
  90. Include("string"),
  91. },
  92. "doubleStringTable": {
  93. {`"`, LiteralString, Pop(1)},
  94. Include("string"),
  95. },
  96. "root": {
  97. {`\n`, NameFunction, nil},
  98. Include("comments"),
  99. {`"""`, Keyword, Push("pyString")},
  100. {`\s+\|`, Keyword, Push("tableContent")},
  101. {`"`, NameFunction, Push("doubleString")},
  102. Include("tableVars"),
  103. Include("numbers"),
  104. {`(\s*)(@[^@\r\n\t ]+)`, ByGroups(NameFunction, NameTag), nil},
  105. {stepKeywords, ByGroups(NameFunction, Keyword), Push("stepContentRoot")},
  106. {featureKeywords, ByGroups(Keyword, Keyword, NameFunction), Push("narrative")},
  107. {featureElementKeywords, ByGroups(NameFunction, Keyword, Keyword, NameFunction), Push("featureElements")},
  108. {examplesKeywords, ByGroups(NameFunction, Keyword, Keyword, NameFunction), Push("examplesTable")},
  109. {`(\s|.)`, NameFunction, nil},
  110. },
  111. },
  112. ))