Skip to content

Commit

Permalink
(ebnf) add backtick (grave symbol) as string character (#2290)
Browse files Browse the repository at this point in the history
This adds backticks as an allowed character for terminal strings.

This has precedent in some EBNF-described specifications such as the Go
specification.
  • Loading branch information
vancluever authored and joshgoebel committed Nov 29, 2019
1 parent 4ba3b91 commit eebe0cb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ New styles:
none.

Improvements:
- enh(ebnf) add backticks as additional string variant (#2290) [Chris Marchesi][]
- fix(themes): fix inconsistencies between some themes padding/spacing (#2300) [Josh Goebel][]
- chore(javascript): add esm related extensions to aliases (#2298) [Rongjian Zhang][]
- fix(kotlin): fix termination of """ string literals (#2295) [Josh Goebel][]
Expand Down
11 changes: 9 additions & 2 deletions src/languages/ebnf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ function(hljs) {
contains: [
commentMode,
specialSequenceMode,
// terminals
hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE
{
// terminals
className: 'string',
variants: [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
{begin: '`', end: '`'},
]
},
]
};

Expand Down
8 changes: 8 additions & 0 deletions test/markup/ebnf/quote-symbols.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<span class="hljs-attribute">first_quote_symbol</span> = <span class="hljs-string">"'"</span> .
<span class="hljs-attribute">second_quote_symbol</span> = <span class="hljs-string">'"'</span> .

<span class="hljs-comment">(* escaped_quote_symbol tests backticks, which does not interfere
* with backslashes. It has precedent in some language
* specifications.
*)</span>
<span class="hljs-attribute">escaped_quote_symbol</span> = <span class="hljs-string">`\`</span> ( first_quote_symbol | second_quote_symbol ) .
8 changes: 8 additions & 0 deletions test/markup/ebnf/quote-symbols.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
first_quote_symbol = "'" .
second_quote_symbol = '"' .

(* escaped_quote_symbol tests backticks, which does not interfere
* with backslashes. It has precedent in some language
* specifications.
*)
escaped_quote_symbol = `\` ( first_quote_symbol | second_quote_symbol ) .

0 comments on commit eebe0cb

Please sign in to comment.