Skip to main content Svelte Highlight v7.21.1

GBNF language preview

1. A JSON-ish grammar

rule definitions, quoted terminals, and character classes
horizon-dark
# a simple JSON-ish grammar
root ::= object
object ::= "{" pair ("," pair)* "}"
pair ::= string ":" value
value ::= string | number | object
string ::= "\"" [^"]* "\""
number ::= [0-9]+ ("." [0-9]+)?
atom-one-dark
# a simple JSON-ish grammar
root ::= object
object ::= "{" pair ("," pair)* "}"
pair ::= string ":" value
value ::= string | number | object
string ::= "\"" [^"]* "\""
number ::= [0-9]+ ("." [0-9]+)?
github-dark
# a simple JSON-ish grammar
root ::= object
object ::= "{" pair ("," pair)* "}"
pair ::= string ":" value
value ::= string | number | object
string ::= "\"" [^"]* "\""
number ::= [0-9]+ ("." [0-9]+)?
dracula
# a simple JSON-ish grammar
root ::= object
object ::= "{" pair ("," pair)* "}"
pair ::= string ":" value
value ::= string | number | object
string ::= "\"" [^"]* "\""
number ::= [0-9]+ ("." [0-9]+)?
nord
# a simple JSON-ish grammar
root ::= object
object ::= "{" pair ("," pair)* "}"
pair ::= string ":" value
value ::= string | number | object
string ::= "\"" [^"]* "\""
number ::= [0-9]+ ("." [0-9]+)?
github
# a simple JSON-ish grammar
root ::= object
object ::= "{" pair ("," pair)* "}"
pair ::= string ":" value
value ::= string | number | object
string ::= "\"" [^"]* "\""
number ::= [0-9]+ ("." [0-9]+)?

2. Quantifiers

optional, one-or-more, and repetition ranges
horizon-dark
root ::= greeting name? "!"+
greeting ::= "hi" | "hello"
name ::= [a-zA-Z]{1,20}
atom-one-dark
root ::= greeting name? "!"+
greeting ::= "hi" | "hello"
name ::= [a-zA-Z]{1,20}
github-dark
root ::= greeting name? "!"+
greeting ::= "hi" | "hello"
name ::= [a-zA-Z]{1,20}
dracula
root ::= greeting name? "!"+
greeting ::= "hi" | "hello"
name ::= [a-zA-Z]{1,20}
nord
root ::= greeting name? "!"+
greeting ::= "hi" | "hello"
name ::= [a-zA-Z]{1,20}
github
root ::= greeting name? "!"+
greeting ::= "hi" | "hello"
name ::= [a-zA-Z]{1,20}

3. Grouping and alternation

grouped alternatives inside a rule
horizon-dark
expr ::= term (("+" | "-") term)*
term ::= factor (("*" | "/") factor)*
factor ::= [0-9]+ | "(" expr ")"
atom-one-dark
expr ::= term (("+" | "-") term)*
term ::= factor (("*" | "/") factor)*
factor ::= [0-9]+ | "(" expr ")"
github-dark
expr ::= term (("+" | "-") term)*
term ::= factor (("*" | "/") factor)*
factor ::= [0-9]+ | "(" expr ")"
dracula
expr ::= term (("+" | "-") term)*
term ::= factor (("*" | "/") factor)*
factor ::= [0-9]+ | "(" expr ")"
nord
expr ::= term (("+" | "-") term)*
term ::= factor (("*" | "/") factor)*
factor ::= [0-9]+ | "(" expr ")"
github
expr ::= term (("+" | "-") term)*
term ::= factor (("*" | "/") factor)*
factor ::= [0-9]+ | "(" expr ")"