@exercism/codemirror-lang-gleam
Advanced tools
Comparing version 1.0.1 to 2.0.0
import { LRParser } from '@lezer/lr'; | ||
import { LRLanguage, LanguageSupport } from '@codemirror/language'; | ||
import { styleTags, tags } from '@codemirror/highlight'; | ||
import { NodeProp } from '@lezer/common'; | ||
// This file was generated by lezer-generator. You probably shouldn't edit it. | ||
const spec_LowercaseIdentifier = {__proto__:null,pub:38, fn:40, type:42, import:44, if:46, case:48, external:50, let:52, assert:54, use:56, todo:58, panic:60}; | ||
const spec_LowercaseIdentifier = {__proto__:null,assert:38, case:40, const:42, external:44, fn:46, if:48, import:50, type:52, let:54, panic:56, pub:58, todo:60, use:62, opaque:64}; | ||
const parser = LRParser.deserialize({ | ||
version: 13, | ||
states: "!jO!hOPOOOOOO'#C_'#C_O!oOQO'#CeOOOO'#Cl'#ClOOOO'#Ci'#CiO!wOPO'#CkQOOOOOOOOO'#Cg'#CgOOOO,59P,59PO#OOPO,59POOOO-E6g-E6gOOOO1G.k1G.k", | ||
stateData: "#`~OQSOSPOTPOUPOVPOWPOYSO[SOaQOcVOdVOeVOfVOgVOhVOiVOjVOkVOlVOmVOnVOoSO~O^_P~PQOaWObXO~O^_X~PQOaZO~OWTUVSYQ[oS~", | ||
version: 14, | ||
states: "!jO!nOPOOOOOO'#C_'#C_O!uOQO'#CeOOOO'#Cl'#ClOOOO'#Ci'#CiO!}OPO'#CkQOOOOOOOOO'#Cg'#CgOOOO,59P,59PO#UOPO,59POOOO-E6g-E6gOOOO1G.k1G.k", | ||
stateData: "#g~OQSOSPOTPOUPOVPOWPOYSO[SOaQOcVOdVOeVOfVOgVOhVOiVOjVOkVOlVOmVOnVOoVOpVOqSO~O^_P~PQOaWObXO~O^_X~PQOaZO~OaWTUVSYQ[qS~", | ||
goto: "saPPPbPPPPPbPfPjPpfTROTTSOTQTORYTRUO", | ||
nodeNames: "⚠ Program Comment Number Decimal Hex Octal Binary Float String UppercaseIdentifier Keyword LowercaseIdentifier", | ||
maxTerm: 31, | ||
ma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bQ[PqPOr!zs!O!z!O!P&l!P!Q!z!Q![:Z![!c!z!c!};d!}#O!z#O#P#c#P#R!z#R#S:Z#S#T!z#T#o;d#o;'S!z;'S;=`#r<%lO!zR:b`bQ[POr!zs!O!z!O!P&l!P!Q!z!Q![:Z![!c!z!c!};d!}#O!z#O#P#c#P#R!z#R#S:Z#S#T!z#T#o;d#o;'S!z;'S;=`#r<%lO!zR;k^bQ[POr!zs!Q!z!Q![;d![!c!z!c!};d!}#O!z#O#P#c#P#R!z#R#S;d#S#T!z#T#o;d#o;'S!z;'S;=`#r<%lO!zR<p^bQ[PqPOr!zs!Q!z!Q![;d![!c!z!c!};d!}#O!z#O#P#c#P#R!z#R#S;d#S#T!z#T#o;d#o;'S!z;'S;=`#r<%lO!zR=qPqP;=`<%l!aP=yOqP", | ||
tokenizers: [0, 1], | ||
topRules: {"Program":[0,1]}, | ||
specialized: [{term: 12, get: value => spec_LowercaseIdentifier[value] || -1}], | ||
tokenPrec: 97 | ||
specialized: [{term: 12, get: (value) => spec_LowercaseIdentifier[value] || -1}], | ||
tokenPrec: 103 | ||
}); | ||
let nextTagID = 0; | ||
/** | ||
Highlighting tags are markers that denote a highlighting category. | ||
They are [associated](#highlight.styleTags) with parts of a syntax | ||
tree by a language mode, and then mapped to an actual CSS style by | ||
a [highlighter](#highlight.Highlighter). | ||
Because syntax tree node types and highlight styles have to be | ||
able to talk the same language, CodeMirror uses a mostly _closed_ | ||
[vocabulary](#highlight.tags) of syntax tags (as opposed to | ||
traditional open string-based systems, which make it hard for | ||
highlighting themes to cover all the tokens produced by the | ||
various languages). | ||
It _is_ possible to [define](#highlight.Tag^define) your own | ||
highlighting tags for system-internal use (where you control both | ||
the language package and the highlighter), but such tags will not | ||
be picked up by regular highlighters (though you can derive them | ||
from standard tags to allow highlighters to fall back to those). | ||
*/ | ||
class Tag { | ||
/** | ||
@internal | ||
*/ | ||
constructor( | ||
/** | ||
The set of this tag and all its parent tags, starting with | ||
this one itself and sorted in order of decreasing specificity. | ||
*/ | ||
set, | ||
/** | ||
The base unmodified tag that this one is based on, if it's | ||
modified @internal | ||
*/ | ||
base, | ||
/** | ||
The modifiers applied to this.base @internal | ||
*/ | ||
modified) { | ||
this.set = set; | ||
this.base = base; | ||
this.modified = modified; | ||
/** | ||
@internal | ||
*/ | ||
this.id = nextTagID++; | ||
} | ||
/** | ||
Define a new tag. If `parent` is given, the tag is treated as a | ||
sub-tag of that parent, and | ||
[highlighters](#highlight.tagHighlighter) that don't mention | ||
this tag will try to fall back to the parent tag (or grandparent | ||
tag, etc). | ||
*/ | ||
static define(parent) { | ||
if (parent === null || parent === void 0 ? void 0 : parent.base) | ||
throw new Error("Can not derive from a modified tag"); | ||
let tag = new Tag([], null, []); | ||
tag.set.push(tag); | ||
if (parent) | ||
for (let t of parent.set) | ||
tag.set.push(t); | ||
return tag; | ||
} | ||
/** | ||
Define a tag _modifier_, which is a function that, given a tag, | ||
will return a tag that is a subtag of the original. Applying the | ||
same modifier to a twice tag will return the same value (`m1(t1) | ||
== m1(t1)`) and applying multiple modifiers will, regardless or | ||
order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`). | ||
When multiple modifiers are applied to a given base tag, each | ||
smaller set of modifiers is registered as a parent, so that for | ||
example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`, | ||
`m1(m3(t1)`, and so on. | ||
*/ | ||
static defineModifier() { | ||
let mod = new Modifier; | ||
return (tag) => { | ||
if (tag.modified.indexOf(mod) > -1) | ||
return tag; | ||
return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id)); | ||
}; | ||
} | ||
} | ||
let nextModifierID = 0; | ||
class Modifier { | ||
constructor() { | ||
this.instances = []; | ||
this.id = nextModifierID++; | ||
} | ||
static get(base, mods) { | ||
if (!mods.length) | ||
return base; | ||
let exists = mods[0].instances.find(t => t.base == base && sameArray(mods, t.modified)); | ||
if (exists) | ||
return exists; | ||
let set = [], tag = new Tag(set, base, mods); | ||
for (let m of mods) | ||
m.instances.push(tag); | ||
let configs = powerSet(mods); | ||
for (let parent of base.set) | ||
if (!parent.modified.length) | ||
for (let config of configs) | ||
set.push(Modifier.get(parent, config)); | ||
return tag; | ||
} | ||
} | ||
function sameArray(a, b) { | ||
return a.length == b.length && a.every((x, i) => x == b[i]); | ||
} | ||
function powerSet(array) { | ||
let sets = [[]]; | ||
for (let i = 0; i < array.length; i++) { | ||
for (let j = 0, e = sets.length; j < e; j++) { | ||
sets.push(sets[j].concat(array[i])); | ||
} | ||
} | ||
return sets.sort((a, b) => b.length - a.length); | ||
} | ||
/** | ||
This function is used to add a set of tags to a language syntax | ||
via [`NodeSet.extend`](#common.NodeSet.extend) or | ||
[`LRParser.configure`](#lr.LRParser.configure). | ||
The argument object maps node selectors to [highlighting | ||
tags](#highlight.Tag) or arrays of tags. | ||
Node selectors may hold one or more (space-separated) node paths. | ||
Such a path can be a [node name](#common.NodeType.name), or | ||
multiple node names (or `*` wildcards) separated by slash | ||
characters, as in `"Block/Declaration/VariableName"`. Such a path | ||
matches the final node but only if its direct parent nodes are the | ||
other nodes mentioned. A `*` in such a path matches any parent, | ||
but only a single level—wildcards that match multiple parents | ||
aren't supported, both for efficiency reasons and because Lezer | ||
trees make it rather hard to reason about what they would match.) | ||
A path can be ended with `/...` to indicate that the tag assigned | ||
to the node should also apply to all child nodes, even if they | ||
match their own style (by default, only the innermost style is | ||
used). | ||
When a path ends in `!`, as in `Attribute!`, no further matching | ||
happens for the node's child nodes, and the entire node gets the | ||
given style. | ||
In this notation, node names that contain `/`, `!`, `*`, or `...` | ||
must be quoted as JSON strings. | ||
For example: | ||
```javascript | ||
parser.withProps( | ||
styleTags({ | ||
// Style Number and BigNumber nodes | ||
"Number BigNumber": tags.number, | ||
// Style Escape nodes whose parent is String | ||
"String/Escape": tags.escape, | ||
// Style anything inside Attributes nodes | ||
"Attributes!": tags.meta, | ||
// Add a style to all content inside Italic nodes | ||
"Italic/...": tags.emphasis, | ||
// Style InvalidString nodes as both `string` and `invalid` | ||
"InvalidString": [tags.string, tags.invalid], | ||
// Style the node named "/" as punctuation | ||
'"/"': tags.punctuation | ||
}) | ||
) | ||
``` | ||
*/ | ||
function styleTags(spec) { | ||
let byName = Object.create(null); | ||
for (let prop in spec) { | ||
let tags = spec[prop]; | ||
if (!Array.isArray(tags)) | ||
tags = [tags]; | ||
for (let part of prop.split(" ")) | ||
if (part) { | ||
let pieces = [], mode = 2 /* Mode.Normal */, rest = part; | ||
for (let pos = 0;;) { | ||
if (rest == "..." && pos > 0 && pos + 3 == part.length) { | ||
mode = 1 /* Mode.Inherit */; | ||
break; | ||
} | ||
let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest); | ||
if (!m) | ||
throw new RangeError("Invalid path: " + part); | ||
pieces.push(m[0] == "*" ? "" : m[0][0] == '"' ? JSON.parse(m[0]) : m[0]); | ||
pos += m[0].length; | ||
if (pos == part.length) | ||
break; | ||
let next = part[pos++]; | ||
if (pos == part.length && next == "!") { | ||
mode = 0 /* Mode.Opaque */; | ||
break; | ||
} | ||
if (next != "/") | ||
throw new RangeError("Invalid path: " + part); | ||
rest = part.slice(pos); | ||
} | ||
let last = pieces.length - 1, inner = pieces[last]; | ||
if (!inner) | ||
throw new RangeError("Invalid path: " + part); | ||
let rule = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null); | ||
byName[inner] = rule.sort(byName[inner]); | ||
} | ||
} | ||
return ruleNodeProp.add(byName); | ||
} | ||
const ruleNodeProp = new NodeProp(); | ||
class Rule { | ||
constructor(tags, mode, context, next) { | ||
this.tags = tags; | ||
this.mode = mode; | ||
this.context = context; | ||
this.next = next; | ||
} | ||
get opaque() { return this.mode == 0 /* Mode.Opaque */; } | ||
get inherit() { return this.mode == 1 /* Mode.Inherit */; } | ||
sort(other) { | ||
if (!other || other.depth < this.depth) { | ||
this.next = other; | ||
return this; | ||
} | ||
other.next = this.sort(other.next); | ||
return other; | ||
} | ||
get depth() { return this.context ? this.context.length : 0; } | ||
} | ||
Rule.empty = new Rule([], 2 /* Mode.Normal */, null); | ||
/** | ||
Define a [highlighter](#highlight.Highlighter) from an array of | ||
tag/class pairs. Classes associated with more specific tags will | ||
take precedence. | ||
*/ | ||
function tagHighlighter(tags, options) { | ||
let map = Object.create(null); | ||
for (let style of tags) { | ||
if (!Array.isArray(style.tag)) | ||
map[style.tag.id] = style.class; | ||
else | ||
for (let tag of style.tag) | ||
map[tag.id] = style.class; | ||
} | ||
let { scope, all = null } = options || {}; | ||
return { | ||
style: (tags) => { | ||
let cls = all; | ||
for (let tag of tags) { | ||
for (let sub of tag.set) { | ||
let tagClass = map[sub.id]; | ||
if (tagClass) { | ||
cls = cls ? cls + " " + tagClass : tagClass; | ||
break; | ||
} | ||
} | ||
} | ||
return cls; | ||
}, | ||
scope | ||
}; | ||
} | ||
const t = Tag.define; | ||
const comment = t(), name = t(), typeName = t(name), propertyName = t(name), literal = t(), string = t(literal), number = t(literal), content = t(), heading = t(content), keyword = t(), operator = t(), punctuation = t(), bracket = t(punctuation), meta = t(); | ||
/** | ||
The default set of highlighting [tags](#highlight.Tag). | ||
This collection is heavily biased towards programming languages, | ||
and necessarily incomplete. A full ontology of syntactic | ||
constructs would fill a stack of books, and be impractical to | ||
write themes for. So try to make do with this set. If all else | ||
fails, [open an | ||
issue](https://github.com/codemirror/codemirror.next) to propose a | ||
new tag, or [define](#highlight.Tag^define) a local custom tag for | ||
your use case. | ||
Note that it is not obligatory to always attach the most specific | ||
tag possible to an element—if your grammar can't easily | ||
distinguish a certain type of element (such as a local variable), | ||
it is okay to style it as its more general variant (a variable). | ||
For tags that extend some parent tag, the documentation links to | ||
the parent. | ||
*/ | ||
const tags = { | ||
/** | ||
A comment. | ||
*/ | ||
comment, | ||
/** | ||
A line [comment](#highlight.tags.comment). | ||
*/ | ||
lineComment: t(comment), | ||
/** | ||
A block [comment](#highlight.tags.comment). | ||
*/ | ||
blockComment: t(comment), | ||
/** | ||
A documentation [comment](#highlight.tags.comment). | ||
*/ | ||
docComment: t(comment), | ||
/** | ||
Any kind of identifier. | ||
*/ | ||
name, | ||
/** | ||
The [name](#highlight.tags.name) of a variable. | ||
*/ | ||
variableName: t(name), | ||
/** | ||
A type [name](#highlight.tags.name). | ||
*/ | ||
typeName: typeName, | ||
/** | ||
A tag name (subtag of [`typeName`](#highlight.tags.typeName)). | ||
*/ | ||
tagName: t(typeName), | ||
/** | ||
A property or field [name](#highlight.tags.name). | ||
*/ | ||
propertyName: propertyName, | ||
/** | ||
An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)). | ||
*/ | ||
attributeName: t(propertyName), | ||
/** | ||
The [name](#highlight.tags.name) of a class. | ||
*/ | ||
className: t(name), | ||
/** | ||
A label [name](#highlight.tags.name). | ||
*/ | ||
labelName: t(name), | ||
/** | ||
A namespace [name](#highlight.tags.name). | ||
*/ | ||
namespace: t(name), | ||
/** | ||
The [name](#highlight.tags.name) of a macro. | ||
*/ | ||
macroName: t(name), | ||
/** | ||
A literal value. | ||
*/ | ||
literal, | ||
/** | ||
A string [literal](#highlight.tags.literal). | ||
*/ | ||
string, | ||
/** | ||
A documentation [string](#highlight.tags.string). | ||
*/ | ||
docString: t(string), | ||
/** | ||
A character literal (subtag of [string](#highlight.tags.string)). | ||
*/ | ||
character: t(string), | ||
/** | ||
An attribute value (subtag of [string](#highlight.tags.string)). | ||
*/ | ||
attributeValue: t(string), | ||
/** | ||
A number [literal](#highlight.tags.literal). | ||
*/ | ||
number, | ||
/** | ||
An integer [number](#highlight.tags.number) literal. | ||
*/ | ||
integer: t(number), | ||
/** | ||
A floating-point [number](#highlight.tags.number) literal. | ||
*/ | ||
float: t(number), | ||
/** | ||
A boolean [literal](#highlight.tags.literal). | ||
*/ | ||
bool: t(literal), | ||
/** | ||
Regular expression [literal](#highlight.tags.literal). | ||
*/ | ||
regexp: t(literal), | ||
/** | ||
An escape [literal](#highlight.tags.literal), for example a | ||
backslash escape in a string. | ||
*/ | ||
escape: t(literal), | ||
/** | ||
A color [literal](#highlight.tags.literal). | ||
*/ | ||
color: t(literal), | ||
/** | ||
A URL [literal](#highlight.tags.literal). | ||
*/ | ||
url: t(literal), | ||
/** | ||
A language keyword. | ||
*/ | ||
keyword, | ||
/** | ||
The [keyword](#highlight.tags.keyword) for the self or this | ||
object. | ||
*/ | ||
self: t(keyword), | ||
/** | ||
The [keyword](#highlight.tags.keyword) for null. | ||
*/ | ||
null: t(keyword), | ||
/** | ||
A [keyword](#highlight.tags.keyword) denoting some atomic value. | ||
*/ | ||
atom: t(keyword), | ||
/** | ||
A [keyword](#highlight.tags.keyword) that represents a unit. | ||
*/ | ||
unit: t(keyword), | ||
/** | ||
A modifier [keyword](#highlight.tags.keyword). | ||
*/ | ||
modifier: t(keyword), | ||
/** | ||
A [keyword](#highlight.tags.keyword) that acts as an operator. | ||
*/ | ||
operatorKeyword: t(keyword), | ||
/** | ||
A control-flow related [keyword](#highlight.tags.keyword). | ||
*/ | ||
controlKeyword: t(keyword), | ||
/** | ||
A [keyword](#highlight.tags.keyword) that defines something. | ||
*/ | ||
definitionKeyword: t(keyword), | ||
/** | ||
A [keyword](#highlight.tags.keyword) related to defining or | ||
interfacing with modules. | ||
*/ | ||
moduleKeyword: t(keyword), | ||
/** | ||
An operator. | ||
*/ | ||
operator, | ||
/** | ||
An [operator](#highlight.tags.operator) that dereferences something. | ||
*/ | ||
derefOperator: t(operator), | ||
/** | ||
Arithmetic-related [operator](#highlight.tags.operator). | ||
*/ | ||
arithmeticOperator: t(operator), | ||
/** | ||
Logical [operator](#highlight.tags.operator). | ||
*/ | ||
logicOperator: t(operator), | ||
/** | ||
Bit [operator](#highlight.tags.operator). | ||
*/ | ||
bitwiseOperator: t(operator), | ||
/** | ||
Comparison [operator](#highlight.tags.operator). | ||
*/ | ||
compareOperator: t(operator), | ||
/** | ||
[Operator](#highlight.tags.operator) that updates its operand. | ||
*/ | ||
updateOperator: t(operator), | ||
/** | ||
[Operator](#highlight.tags.operator) that defines something. | ||
*/ | ||
definitionOperator: t(operator), | ||
/** | ||
Type-related [operator](#highlight.tags.operator). | ||
*/ | ||
typeOperator: t(operator), | ||
/** | ||
Control-flow [operator](#highlight.tags.operator). | ||
*/ | ||
controlOperator: t(operator), | ||
/** | ||
Program or markup punctuation. | ||
*/ | ||
punctuation, | ||
/** | ||
[Punctuation](#highlight.tags.punctuation) that separates | ||
things. | ||
*/ | ||
separator: t(punctuation), | ||
/** | ||
Bracket-style [punctuation](#highlight.tags.punctuation). | ||
*/ | ||
bracket, | ||
/** | ||
Angle [brackets](#highlight.tags.bracket) (usually `<` and `>` | ||
tokens). | ||
*/ | ||
angleBracket: t(bracket), | ||
/** | ||
Square [brackets](#highlight.tags.bracket) (usually `[` and `]` | ||
tokens). | ||
*/ | ||
squareBracket: t(bracket), | ||
/** | ||
Parentheses (usually `(` and `)` tokens). Subtag of | ||
[bracket](#highlight.tags.bracket). | ||
*/ | ||
paren: t(bracket), | ||
/** | ||
Braces (usually `{` and `}` tokens). Subtag of | ||
[bracket](#highlight.tags.bracket). | ||
*/ | ||
brace: t(bracket), | ||
/** | ||
Content, for example plain text in XML or markup documents. | ||
*/ | ||
content, | ||
/** | ||
[Content](#highlight.tags.content) that represents a heading. | ||
*/ | ||
heading, | ||
/** | ||
A level 1 [heading](#highlight.tags.heading). | ||
*/ | ||
heading1: t(heading), | ||
/** | ||
A level 2 [heading](#highlight.tags.heading). | ||
*/ | ||
heading2: t(heading), | ||
/** | ||
A level 3 [heading](#highlight.tags.heading). | ||
*/ | ||
heading3: t(heading), | ||
/** | ||
A level 4 [heading](#highlight.tags.heading). | ||
*/ | ||
heading4: t(heading), | ||
/** | ||
A level 5 [heading](#highlight.tags.heading). | ||
*/ | ||
heading5: t(heading), | ||
/** | ||
A level 6 [heading](#highlight.tags.heading). | ||
*/ | ||
heading6: t(heading), | ||
/** | ||
A prose separator (such as a horizontal rule). | ||
*/ | ||
contentSeparator: t(content), | ||
/** | ||
[Content](#highlight.tags.content) that represents a list. | ||
*/ | ||
list: t(content), | ||
/** | ||
[Content](#highlight.tags.content) that represents a quote. | ||
*/ | ||
quote: t(content), | ||
/** | ||
[Content](#highlight.tags.content) that is emphasized. | ||
*/ | ||
emphasis: t(content), | ||
/** | ||
[Content](#highlight.tags.content) that is styled strong. | ||
*/ | ||
strong: t(content), | ||
/** | ||
[Content](#highlight.tags.content) that is part of a link. | ||
*/ | ||
link: t(content), | ||
/** | ||
[Content](#highlight.tags.content) that is styled as code or | ||
monospace. | ||
*/ | ||
monospace: t(content), | ||
/** | ||
[Content](#highlight.tags.content) that has a strike-through | ||
style. | ||
*/ | ||
strikethrough: t(content), | ||
/** | ||
Inserted text in a change-tracking format. | ||
*/ | ||
inserted: t(), | ||
/** | ||
Deleted text. | ||
*/ | ||
deleted: t(), | ||
/** | ||
Changed text. | ||
*/ | ||
changed: t(), | ||
/** | ||
An invalid or unsyntactic element. | ||
*/ | ||
invalid: t(), | ||
/** | ||
Metadata or meta-instruction. | ||
*/ | ||
meta, | ||
/** | ||
[Metadata](#highlight.tags.meta) that applies to the entire | ||
document. | ||
*/ | ||
documentMeta: t(meta), | ||
/** | ||
[Metadata](#highlight.tags.meta) that annotates or adds | ||
attributes to a given syntactic element. | ||
*/ | ||
annotation: t(meta), | ||
/** | ||
Processing instruction or preprocessor directive. Subtag of | ||
[meta](#highlight.tags.meta). | ||
*/ | ||
processingInstruction: t(meta), | ||
/** | ||
[Modifier](#highlight.Tag^defineModifier) that indicates that a | ||
given element is being defined. Expected to be used with the | ||
various [name](#highlight.tags.name) tags. | ||
*/ | ||
definition: Tag.defineModifier(), | ||
/** | ||
[Modifier](#highlight.Tag^defineModifier) that indicates that | ||
something is constant. Mostly expected to be used with | ||
[variable names](#highlight.tags.variableName). | ||
*/ | ||
constant: Tag.defineModifier(), | ||
/** | ||
[Modifier](#highlight.Tag^defineModifier) used to indicate that | ||
a [variable](#highlight.tags.variableName) or [property | ||
name](#highlight.tags.propertyName) is being called or defined | ||
as a function. | ||
*/ | ||
function: Tag.defineModifier(), | ||
/** | ||
[Modifier](#highlight.Tag^defineModifier) that can be applied to | ||
[names](#highlight.tags.name) to indicate that they belong to | ||
the language's standard environment. | ||
*/ | ||
standard: Tag.defineModifier(), | ||
/** | ||
[Modifier](#highlight.Tag^defineModifier) that indicates a given | ||
[names](#highlight.tags.name) is local to some scope. | ||
*/ | ||
local: Tag.defineModifier(), | ||
/** | ||
A generic variant [modifier](#highlight.Tag^defineModifier) that | ||
can be used to tag language-specific alternative variants of | ||
some common tag. It is recommended for themes to define special | ||
forms of at least the [string](#highlight.tags.string) and | ||
[variable name](#highlight.tags.variableName) tags, since those | ||
come up a lot. | ||
*/ | ||
special: Tag.defineModifier() | ||
}; | ||
/** | ||
This is a highlighter that adds stable, predictable classes to | ||
tokens, for styling with external CSS. | ||
The following tags are mapped to their name prefixed with `"tok-"` | ||
(for example `"tok-comment"`): | ||
* [`link`](#highlight.tags.link) | ||
* [`heading`](#highlight.tags.heading) | ||
* [`emphasis`](#highlight.tags.emphasis) | ||
* [`strong`](#highlight.tags.strong) | ||
* [`keyword`](#highlight.tags.keyword) | ||
* [`atom`](#highlight.tags.atom) | ||
* [`bool`](#highlight.tags.bool) | ||
* [`url`](#highlight.tags.url) | ||
* [`labelName`](#highlight.tags.labelName) | ||
* [`inserted`](#highlight.tags.inserted) | ||
* [`deleted`](#highlight.tags.deleted) | ||
* [`literal`](#highlight.tags.literal) | ||
* [`string`](#highlight.tags.string) | ||
* [`number`](#highlight.tags.number) | ||
* [`variableName`](#highlight.tags.variableName) | ||
* [`typeName`](#highlight.tags.typeName) | ||
* [`namespace`](#highlight.tags.namespace) | ||
* [`className`](#highlight.tags.className) | ||
* [`macroName`](#highlight.tags.macroName) | ||
* [`propertyName`](#highlight.tags.propertyName) | ||
* [`operator`](#highlight.tags.operator) | ||
* [`comment`](#highlight.tags.comment) | ||
* [`meta`](#highlight.tags.meta) | ||
* [`punctuation`](#highlight.tags.punctuation) | ||
* [`invalid`](#highlight.tags.invalid) | ||
In addition, these mappings are provided: | ||
* [`regexp`](#highlight.tags.regexp), | ||
[`escape`](#highlight.tags.escape), and | ||
[`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string) | ||
are mapped to `"tok-string2"` | ||
* [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName) | ||
to `"tok-variableName2"` | ||
* [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName) | ||
to `"tok-variableName tok-local"` | ||
* [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName) | ||
to `"tok-variableName tok-definition"` | ||
* [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName) | ||
to `"tok-propertyName tok-definition"` | ||
*/ | ||
tagHighlighter([ | ||
{ tag: tags.link, class: "tok-link" }, | ||
{ tag: tags.heading, class: "tok-heading" }, | ||
{ tag: tags.emphasis, class: "tok-emphasis" }, | ||
{ tag: tags.strong, class: "tok-strong" }, | ||
{ tag: tags.keyword, class: "tok-keyword" }, | ||
{ tag: tags.atom, class: "tok-atom" }, | ||
{ tag: tags.bool, class: "tok-bool" }, | ||
{ tag: tags.url, class: "tok-url" }, | ||
{ tag: tags.labelName, class: "tok-labelName" }, | ||
{ tag: tags.inserted, class: "tok-inserted" }, | ||
{ tag: tags.deleted, class: "tok-deleted" }, | ||
{ tag: tags.literal, class: "tok-literal" }, | ||
{ tag: tags.string, class: "tok-string" }, | ||
{ tag: tags.number, class: "tok-number" }, | ||
{ tag: [tags.regexp, tags.escape, tags.special(tags.string)], class: "tok-string2" }, | ||
{ tag: tags.variableName, class: "tok-variableName" }, | ||
{ tag: tags.local(tags.variableName), class: "tok-variableName tok-local" }, | ||
{ tag: tags.definition(tags.variableName), class: "tok-variableName tok-definition" }, | ||
{ tag: tags.special(tags.variableName), class: "tok-variableName2" }, | ||
{ tag: tags.definition(tags.propertyName), class: "tok-propertyName tok-definition" }, | ||
{ tag: tags.typeName, class: "tok-typeName" }, | ||
{ tag: tags.namespace, class: "tok-namespace" }, | ||
{ tag: tags.className, class: "tok-className" }, | ||
{ tag: tags.macroName, class: "tok-macroName" }, | ||
{ tag: tags.propertyName, class: "tok-propertyName" }, | ||
{ tag: tags.operator, class: "tok-operator" }, | ||
{ tag: tags.comment, class: "tok-comment" }, | ||
{ tag: tags.meta, class: "tok-meta" }, | ||
{ tag: tags.invalid, class: "tok-invalid" }, | ||
{ tag: tags.punctuation, class: "tok-punctuation" } | ||
]); | ||
const lezerParser = parser; | ||
@@ -29,9 +761,9 @@ | ||
styleTags({ | ||
"Comment": tags.comment, | ||
Comment: tags.comment, | ||
"Number Decimal Hex Octal Binary Float": tags.number, | ||
"String": tags.string, | ||
"UppercaseIdentifier": tags.typeName, | ||
"Keyword": tags.keyword, | ||
}) | ||
] | ||
String: tags.string, | ||
UppercaseIdentifier: tags.typeName, | ||
Keyword: tags.keyword, | ||
}), | ||
], | ||
}), | ||
@@ -41,3 +773,3 @@ languageData: { | ||
commentTokens: { line: "//" }, | ||
} | ||
}, | ||
}); | ||
@@ -47,5 +779,5 @@ | ||
let lang = gleamLanguage; | ||
return new LanguageSupport(lang, gleamLanguage.data.of({})) | ||
return new LanguageSupport(lang, gleamLanguage.data.of({})); | ||
} | ||
export { gleam, gleamLanguage, lezerParser }; |
{ | ||
"name": "@exercism/codemirror-lang-gleam", | ||
"description": "Gleam Lezer parser and language support for CodeMirror", | ||
"author": "Giacomo Cavalieri <giacomo.cavalieri@icloud.com>", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/exercism/codemirror-lang-gleam" | ||
}, | ||
"imports": { | ||
"#parser": "./src/lezer/parser.js" | ||
}, | ||
"type": "module", | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.es.js", | ||
"exports": { | ||
"import": "./dist/index.es.js", | ||
"require": "./dist/index.cjs" | ||
}, | ||
"types": "index.d.ts", | ||
"scripts": { | ||
"prepare": "npm run build", | ||
"build": "npm run build-grammar && rollup -c", | ||
"build-debug": "lezer-generator src/lezer/gleam.grammar --names -o src/lezer/parser && rollup -c", | ||
"build-grammar": "lezer-generator src/lezer/gleam.grammar -o src/lezer/parser", | ||
"build-devtool": "npm run build-grammar && rollup -c rollup.config.devtool.js" | ||
}, | ||
"dependencies": { | ||
"@codemirror/autocomplete": "^0.19.4", | ||
"@codemirror/highlight": "^0.19.6", | ||
"@codemirror/language": "^0.19.3" | ||
}, | ||
"devDependencies": { | ||
"@codemirror/basic-setup": "0.19", | ||
"@lezer/generator": "^0.15.2", | ||
"@rollup/plugin-node-resolve": "^13.0.6", | ||
"colors": "^1.4.0", | ||
"lezer": "^0.13.5", | ||
"mocha": "^9.0.0", | ||
"rollup": "^2.50.4" | ||
}, | ||
"files": [ | ||
"dist", | ||
"index.d.ts" | ||
] | ||
"name": "@exercism/codemirror-lang-gleam", | ||
"description": "Gleam Lezer parser and language support for CodeMirror", | ||
"author": "Giacomo Cavalieri <giacomo.cavalieri@icloud.com>", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/exercism/codemirror-lang-gleam" | ||
}, | ||
"imports": { | ||
"#parser": "./src/lezer/parser.js" | ||
}, | ||
"type": "module", | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.es.js", | ||
"exports": { | ||
"import": "./dist/index.es.js", | ||
"require": "./dist/index.cjs" | ||
}, | ||
"types": "index.d.ts", | ||
"scripts": { | ||
"prepare": "npm run build", | ||
"build": "npm run build-grammar && rollup -c", | ||
"build-debug": "lezer-generator src/lezer/gleam.grammar --names -o src/lezer/parser && rollup -c", | ||
"build-grammar": "lezer-generator src/lezer/gleam.grammar -o src/lezer/parser", | ||
"build-devtool": "npm run build-grammar && rollup -c rollup.config.devtool.js" | ||
}, | ||
"dependencies": { | ||
"@codemirror/autocomplete": "^6.15.0", | ||
"@codemirror/language": "^6.10.1", | ||
"@lezer/highlight": "^1.2.0", | ||
"@lezer/lr": "^1.4.0" | ||
}, | ||
"devDependencies": { | ||
"@lezer/generator": "^1.7.0", | ||
"@rollup/plugin-node-resolve": "^13.0.6", | ||
"codemirror": "6.0.1", | ||
"colors": "^1.4.0", | ||
"lezer": "^0.13.5", | ||
"mocha": "^9.0.0", | ||
"rollup": "^2.50.4" | ||
}, | ||
"files": [ | ||
"dist", | ||
"index.d.ts" | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
58646
1539
4
1
+ Added@lezer/highlight@^1.2.0
+ Added@lezer/lr@^1.4.0
+ Added@codemirror/autocomplete@6.18.4(transitive)
+ Added@codemirror/language@6.10.8(transitive)
+ Added@codemirror/state@6.5.2(transitive)
+ Added@codemirror/view@6.36.2(transitive)
+ Added@lezer/common@1.2.3(transitive)
+ Added@lezer/highlight@1.2.1(transitive)
+ Added@lezer/lr@1.4.2(transitive)
+ Added@marijn/find-cluster-break@1.0.2(transitive)
- Removed@codemirror/highlight@^0.19.6
- Removed@codemirror/autocomplete@0.19.15(transitive)
- Removed@codemirror/highlight@0.19.8(transitive)
- Removed@codemirror/language@0.19.10(transitive)
- Removed@codemirror/rangeset@0.19.9(transitive)
- Removed@codemirror/state@0.19.9(transitive)
- Removed@codemirror/text@0.19.6(transitive)
- Removed@codemirror/tooltip@0.19.16(transitive)
- Removed@codemirror/view@0.19.48(transitive)
- Removed@lezer/common@0.15.12(transitive)
- Removed@lezer/lr@0.15.8(transitive)
Updated@codemirror/language@^6.10.1