// This is a TextMate grammar distributed by `starry-night`. // This grammar is developed at // // and licensed `bsd-3-clause`. // See for more info. /** * @import {Grammar} from '@wooorm/starry-night' */ /** @type {Grammar} */ const grammar = { extensions: [], names: ['bluespec-bh', 'bh', 'bluespec-classic'], patterns: [ {include: '#comment_like'}, {include: '#numeric_literals'}, {include: '#string_literal'}, {include: '#char_literal'}, {match: '(?\n \\( # Opening parenthesis\n (?:\n [^\\(\\)]* # Match non-parentheses\n | \\g # or recurse into further depth\n )*\n \\) # Closing parenthesis\n )\n )\n # Type inside balanced brackets\n | ('? # Optional promotion tick\n (?\n \\[ # Opening bracket\n (?:\n [^\\[\\]]* # Match non-brackets\n | \\g # or recurse into further depth\n )*\n \\] # Closing bracket\n )\n )\n )\n # Then either\n \\s*\n # - a symbolic infix constructor, or\n (?:(?|⇒)\n (?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_"\']])\n' }, deriving: { patterns: [ { begin: '^(\\s*)(deriving)\\s+(?:(via|stock|newtype|anyclass)\\s+)?', beginCaptures: { 2: {name: 'keyword.other.deriving.bh'}, 3: {name: 'keyword.other.deriving.strategy.$3.bh'} }, end: '(?x) # Detect end of deriving statement\n # Decreasing indentation\n (?=\\}|;) # Explicit indentation\n |^(?! # Implicit indentation: end match on newline *unless* the new line is either:\n \\1\\s+\\S # - more indented, or\n | \\s* # - starts with whitespace, followed by:\n (?: $ # - the end of the line (i.e. empty line), or\n |\\{-[^@] # - the start of a block comment, or\n |--+ # - the start of a single-line comment.\n (?![\\p{S}\\p{P}&&[^(),;\\[\\]{}`_"\']]).*$) # non-symbol\n # The double dash may not be followed by other operator characters\n # (then it would be an operator, not a comment)\n )', name: 'meta.deriving.bh', patterns: [ {include: '#comment_like'}, { match: "(?|→)', endCaptures: { 1: {name: 'keyword.operator.period.bh'}, 2: {name: 'keyword.operator.arrow.bh'} }, patterns: [ {include: '#comment_like'}, {include: '#type_variable'}, {include: '#type_signature'} ] }, fun_decl: { begin: "(?x)^(\\s*)\n (primitive\\s+)?\n (type\\s+)?\n (?\n (?:\n [\\p{Ll}_\\p{Lu}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}']*\\#*\n | \\(\\s*\n (?!--+\\))\n [\\p{S}\\p{P}&&[^(),:;\\[\\]`{}_\"']]\n [\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']]*\n \\s*\\)\n )\n (?:\\s*,\\s*\\g)?\n )\n \\s*(?)\n ((<-|←)|(=)|(-<|↢)|(-<<|⤛))\n # non-symbolic character\n ([(),;\\[\\]`{}_"\']|[^\\p{S}\\p{P}])\n )\n # Decreasing indentation:\n |(?=\\}|;) # Explicit indentation\n |^(?! # Implicit indentation: end match on newline *unless* the new line is either:\n \\1\\s+\\S # - more indented, or\n | \\s* # - starts with whitespace, followed by:\n (?: $ # - the end of the line (i.e. empty line), or\n |\\{-[^@] # - the start of a block comment, or\n |--+ # - the start of a single-line comment.\n (?![\\p{S}\\p{P}&&[^(),;\\[\\]{}`_"\']]).*$) # non-symbol\n # The double dash may not be followed by other operator characters\n # (then it would be an operator, not a comment)\n )\n', name: 'meta.function.type-declaration.bh', patterns: [{include: '#type_signature'}] }, gadt_constructor: { patterns: [ { begin: "(?x)\n ^(\\s*)\n (?:\n (\\b(?[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}']*(\\.\\g)?)", name: 'entity.name.namespace.bh' }, pragma: { begin: '\\{-#', end: '#-\\}', name: 'meta.preprocessor.bh', patterns: [ {include: '#comments'}, { match: "(?xi) \\b(?|→)\n |(-<|↢)\n |(-<<|⤛)\n |(>-|⤚)\n |(>>-|⤜)\n )\n (?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"'']])" }, { captures: {1: {name: 'keyword.operator.postfix.hash.bh'}}, match: '(?x)\n (?<=[\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\\p{S}\\p{P}&&[^\\#,;\\[`{]]) # Require closing characters\n (\\#+)\n (?![\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\\p{S}\\p{P}&&[^),;\\]`}]]) # Disallow opening character' }, { captures: {1: {name: 'keyword.operator.infix.tight.at.bh'}}, match: "(?x)\n (?<=[\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}'\\)\\}\\]]) # Require closing characters\n (@)\n (?=[\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}'\\(\\[\\{]) # Require opening character" }, { captures: { 1: {name: 'keyword.operator.prefix.tilde.bh'}, 2: {name: 'keyword.operator.prefix.bang.bh'}, 3: {name: 'keyword.operator.prefix.minus.bh'}, 4: {name: 'keyword.operator.prefix.double-dollar.bh'}, 5: {name: 'keyword.operator.prefix.dollar.bh'}, 6: {name: 'keyword.operator.prefix.modifier.bh'} }, match: "(?x)\n (?)\n (?)\n (?|⇒', name: 'keyword.operator.big-arrow.bh'}, {include: '#string_literal'}, {match: "'[^']'", name: 'invalid'}, {include: '#type_application'}, {include: '#reserved_symbol'}, {include: '#type_operator'}, {include: '#type_constructor'}, { begin: '(\\()', beginCaptures: {1: {name: 'punctuation.paren.bh'}}, end: '(\\))', endCaptures: {2: {name: 'punctuation.paren.bh'}}, patterns: [{include: '#comma'}, {include: '#type_signature'}] }, { begin: "(')?(\\()", beginCaptures: { 1: {name: 'keyword.operator.promotion.bh'}, 2: {name: 'punctuation.paren.bh'} }, end: '(\\))', endCaptures: {1: {name: 'punctuation.paren.bh'}}, patterns: [{include: '#comma'}, {include: '#type_signature'}] }, { begin: "(')?(\\[)", beginCaptures: { 1: {name: 'keyword.operator.promotion.bh'}, 2: {name: 'punctuation.bracket.bh'} }, end: '(\\])', endCaptures: {1: {name: 'punctuation.bracket.bh'}}, patterns: [{include: '#comma'}, {include: '#type_signature'}] }, {include: '#type_variable'} ] }, type_variable: { match: "\\b(?