/* Language: Augmented Backus-Naur Form Author: Alex McKibben Website: https://tools.ietf.org/html/rfc5234 */ /** @type LanguageFn */ function abnf(hljs) { const regexes = { ruleDeclaration: "^[a-zA-Z][a-zA-Z0-9-]*", unexpectedChars: "[!@#$^&',?+~`|:]" }; const keywords = [ "ALPHA", "BIT", "CHAR", "CR", "CRLF", "CTL", "DIGIT", "DQUOTE", "HEXDIG", "HTAB", "LF", "LWSP", "OCTET", "SP", "VCHAR", "WSP" ]; const commentMode = hljs.COMMENT(";", "$"); const terminalBinaryMode = { className: "symbol", begin: /%b[0-1]+(-[0-1]+|(\.[0-1]+)+){0,1}/ }; const terminalDecimalMode = { className: "symbol", begin: /%d[0-9]+(-[0-9]+|(\.[0-9]+)+){0,1}/ }; const terminalHexadecimalMode = { className: "symbol", begin: /%x[0-9A-F]+(-[0-9A-F]+|(\.[0-9A-F]+)+){0,1}/ }; const caseSensitivityIndicatorMode = { className: "symbol", begin: /%[si]/ }; const ruleDeclarationMode = { className: "attribute", begin: regexes.ruleDeclaration + '(?=\\s*=)' }; return { name: 'Augmented Backus-Naur Form', illegal: regexes.unexpectedChars, keywords: keywords.join(" "), contains: [ ruleDeclarationMode, commentMode, terminalBinaryMode, terminalDecimalMode, terminalHexadecimalMode, caseSensitivityIndicatorMode, hljs.QUOTE_STRING_MODE, hljs.NUMBER_MODE ] }; } module.exports = abnf;