Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
testing.py210 linesDownload Raw Back to lexers
1"""2    pygments.lexers.testing3    ~~~~~~~~~~~~~~~~~~~~~~~4 5    Lexers for testing languages.6 7    :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.8    :license: BSD, see LICENSE for details.9"""10 11from pygments.lexer import RegexLexer, include, bygroups12from pygments.token import Comment, Keyword, Name, String, Number, Generic, Text13 14__all__ = ['GherkinLexer', 'TAPLexer']15 16 17class GherkinLexer(RegexLexer):18    """19    For Gherkin syntax.20    """21    name = 'Gherkin'22    aliases = ['gherkin', 'cucumber']23    filenames = ['*.feature']24    mimetypes = ['text/x-gherkin']25    url = 'https://cucumber.io/docs/gherkin'26    version_added = '1.2'27 28    feature_keywords = '^(기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Фича|Особина|Могућност|Ö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)(:)(.*)$'29    feature_element_keywords = '^(\\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)(:)(.*)$'30    examples_keywords = '^(\\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)(:)(.*)$'31    step_keywords = '^(\\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 |\\* )'32 33    tokens = {34        'comments': [35            (r'^\s*#.*$', Comment),36        ],37        'feature_elements': [38            (step_keywords, Keyword, "step_content_stack"),39            include('comments'),40            (r"(\s|.)", Name.Function),41        ],42        'feature_elements_on_stack': [43            (step_keywords, Keyword, "#pop:2"),44            include('comments'),45            (r"(\s|.)", Name.Function),46        ],47        'examples_table': [48            (r"\s+\|", Keyword, 'examples_table_header'),49            include('comments'),50            (r"(\s|.)", Name.Function),51        ],52        'examples_table_header': [53            (r"\s+\|\s*$", Keyword, "#pop:2"),54            include('comments'),55            (r"\\\|", Name.Variable),56            (r"\s*\|", Keyword),57            (r"[^|]", Name.Variable),58        ],59        'scenario_sections_on_stack': [60            (feature_element_keywords,61             bygroups(Name.Function, Keyword, Keyword, Name.Function),62             "feature_elements_on_stack"),63        ],64        'narrative': [65            include('scenario_sections_on_stack'),66            include('comments'),67            (r"(\s|.)", Name.Function),68        ],69        'table_vars': [70            (r'(<[^>]+>)', Name.Variable),71        ],72        'numbers': [73            (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', String),74        ],75        'string': [76            include('table_vars'),77            (r'(\s|.)', String),78        ],79        'py_string': [80            (r'"""', Keyword, "#pop"),81            include('string'),82        ],83        'step_content_root': [84            (r"$", Keyword, "#pop"),85            include('step_content'),86        ],87        'step_content_stack': [88            (r"$", Keyword, "#pop:2"),89            include('step_content'),90        ],91        'step_content': [92            (r'"', Name.Function, "double_string"),93            include('table_vars'),94            include('numbers'),95            include('comments'),96            (r'(\s|.)', Name.Function),97        ],98        'table_content': [99            (r"\s+\|\s*$", Keyword, "#pop"),100            include('comments'),101            (r"\\\|", String),102            (r"\s*\|", Keyword),103            include('string'),104        ],105        'double_string': [106            (r'"', Name.Function, "#pop"),107            include('string'),108        ],109        'root': [110            (r'\n', Name.Function),111            include('comments'),112            (r'"""', Keyword, "py_string"),113            (r'\s+\|', Keyword, 'table_content'),114            (r'"', Name.Function, "double_string"),115            include('table_vars'),116            include('numbers'),117            (r'(\s*)(@[^@\r\n\t ]+)', bygroups(Name.Function, Name.Tag)),118            (step_keywords, bygroups(Name.Function, Keyword),119             'step_content_root'),120            (feature_keywords, bygroups(Keyword, Keyword, Name.Function),121             'narrative'),122            (feature_element_keywords,123             bygroups(Name.Function, Keyword, Keyword, Name.Function),124             'feature_elements'),125            (examples_keywords,126             bygroups(Name.Function, Keyword, Keyword, Name.Function),127             'examples_table'),128            (r'(\s|.)', Name.Function),129        ]130    }131 132    def analyse_text(self, text):133        return134 135 136class TAPLexer(RegexLexer):137    """138    For Test Anything Protocol (TAP) output.139    """140    name = 'TAP'141    url = 'https://testanything.org/'142    aliases = ['tap']143    filenames = ['*.tap']144    version_added = '2.1'145 146    tokens = {147        'root': [148            # A TAP version may be specified.149            (r'^TAP version \d+\n', Name.Namespace),150 151            # Specify a plan with a plan line.152            (r'^1\.\.\d+', Keyword.Declaration, 'plan'),153 154            # A test failure155            (r'^(not ok)([^\S\n]*)(\d*)',156             bygroups(Generic.Error, Text, Number.Integer), 'test'),157 158            # A test success159            (r'^(ok)([^\S\n]*)(\d*)',160             bygroups(Keyword.Reserved, Text, Number.Integer), 'test'),161 162            # Diagnostics start with a hash.163            (r'^#.*\n', Comment),164 165            # TAP's version of an abort statement.166            (r'^Bail out!.*\n', Generic.Error),167 168            # TAP ignores any unrecognized lines.169            (r'^.*\n', Text),170        ],171        'plan': [172            # Consume whitespace (but not newline).173            (r'[^\S\n]+', Text),174 175            # A plan may have a directive with it.176            (r'#', Comment, 'directive'),177 178            # Or it could just end.179            (r'\n', Comment, '#pop'),180 181            # Anything else is wrong.182            (r'.*\n', Generic.Error, '#pop'),183        ],184        'test': [185            # Consume whitespace (but not newline).186            (r'[^\S\n]+', Text),187 188            # A test may have a directive with it.189            (r'#', Comment, 'directive'),190 191            (r'\S+', Text),192 193            (r'\n', Text, '#pop'),194        ],195        'directive': [196            # Consume whitespace (but not newline).197            (r'[^\S\n]+', Comment),198 199            # Extract todo items.200            (r'(?i)\bTODO\b', Comment.Preproc),201 202            # Extract skip items.203            (r'(?i)\bSKIP\S*', Comment.Preproc),204 205            (r'\S+', Comment),206 207            (r'\n', Comment, '#pop:2'),208        ],209    }210 
codekingpro/portable-devtools · Team Ai