Skip to content

Commit

Permalink
✨ Grammar: Highlight ABNF core rules
Browse files Browse the repository at this point in the history
The grammar now adds the scope `support.constant` to the core rules,
specified in Appendix B of the [ABNF RFC][].

[ABNF RFC]: https://tools.ietf.org/pdf/rfc5234.pdf
  • Loading branch information
sanssecours committed Nov 2, 2016
1 parent 86a961c commit d87cd81
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions Syntaxes/ABNF.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,35 @@
</dict>
</array>
</dict>
<key>rule-name-core</key>
<dict>
<key>captures</key>
<dict>
<key>rule</key>
<dict>
<key>name</key>
<string>support.constant.core-rule.$1.abnf</string>
</dict>
</dict>
<key>match</key>
<string>(?x)\b(?&lt;rule&gt;
ALPHA |
BIT |
CHAR |
CR(?:LF)? |
CTL |
DIGIT |
DQUOTE |
HEXDIG |
HTAB |
LF |
LWSP |
OCTECT |
SP |
VCHAR |
WSP
)\b</string>
</dict>
<key>rule-name-plain</key>
<dict>
<key>captures</key>
Expand Down Expand Up @@ -623,6 +652,10 @@
<key>include</key>
<string>#string-double-quoted</string>
</dict>
<dict>
<key>include</key>
<string>#rule-name-core</string>
</dict>
<dict>
<key>include</key>
<string>#rule-name</string>
Expand Down
2 changes: 1 addition & 1 deletion Tests/Example.abnf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; In ABNF comments start with a single semicolon.

; An ABNF rule can contain multiple sub-rules.
rule = subrule1 subrule2 subrule3
rule = WSP subrule2 DIGIT

; We can also use optional angle brackets around a rule name.
<oh-look-ma-angle-brackets> = "[]"; To specify a sequence of characters we use
Expand Down

0 comments on commit d87cd81

Please sign in to comment.