]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/ada.js
1 /*! `ada` grammar compiled for Highlight.js 11.11.1 */
3 var hljsGrammar
= (function () {
8 Author: Lars Schulna <kartoffelbrei.mit.muskatnuss@gmail.org>
9 Description: Ada is a general-purpose programming language that has great support for saftey critical and real-time applications.
10 It has been developed by the DoD and thus has been used in military and safety-critical applications (like civil aviation).
11 The first version appeared in the 80s, but it's still actively developed today with
12 the newest standard being Ada2012.
15 // We try to support full Ada2012
17 // We highlight all appearances of types, keywords, literals (string, char, number, bool)
18 // and titles (user defined function/procedure/package)
19 // CSS classes are set accordingly
21 // Languages causing problems for language detection:
22 // xml (broken by Foo : Bar type), elm (broken by Foo : Bar type), vbscript-html (broken by body keyword)
23 // sql (ada default.txt has a lot of sql keywords)
25 /** @type LanguageFn */
27 // Regular expression for Ada numeric literals.
28 // stolen form the VHDL highlighter
31 const INTEGER_RE
= '\\d(_|\\d)*';
32 const EXPONENT_RE
= '[eE][-+]?' + INTEGER_RE
;
33 const DECIMAL_LITERAL_RE
= INTEGER_RE
+ '(\\.' + INTEGER_RE
+ ')?' + '(' + EXPONENT_RE
+ ')?';
36 const BASED_INTEGER_RE
= '\\w+';
37 const BASED_LITERAL_RE
= INTEGER_RE
+ '#' + BASED_INTEGER_RE
+ '(\\.' + BASED_INTEGER_RE
+ ')?' + '#' + '(' + EXPONENT_RE
+ ')?';
39 const NUMBER_RE
= '\\b(' + BASED_LITERAL_RE
+ '|' + DECIMAL_LITERAL_RE
+ ')';
42 const ID_REGEX
= '[A-Za-z](_?[A-Za-z0-9.])*';
44 // bad chars, only allowed in literals
45 const BAD_CHARS
= `[]\\{\\}%#'"`;
47 // Ada doesn't have block comments, only line comments
48 const COMMENTS
= hljs
.COMMENT('--', '$');
50 // variable declarations of the form
52 // where only Bar will be highlighted
54 // TODO: These spaces are not required by the Ada syntax
55 // however, I have yet to see handwritten Ada code where
56 // someone does not put spaces around :
58 end: '\\s*(:=|;|\\)|=>|$)',
59 // endsWithParent: true,
64 // workaround to avoid highlighting
65 // named loops and declare blocks
66 beginKeywords: 'loop for declare others',
70 // properly highlight all modifiers
72 beginKeywords: 'not null constant access function procedure in out aliased exception'
159 case_insensitive: true,
183 // character literals always contain one char
196 begin: "'" + ID_REGEX
199 // package definition, maybe inside generic
201 begin: '(\\bwith\\s+)?(\\bprivate\\s+)?\\bpackage\\s+(\\bbody\\s+)?',
203 keywords: 'package body',
209 // function/procedure declaration/definition
210 // maybe inside generic
211 begin: '(\\b(with|overriding)\\s+)?\\b(function|procedure)\\s+',
212 end: '(\\bis|\\bwith|\\brenames|\\)\\s*;)',
213 keywords: 'overriding function procedure with is renames return',
214 // we need to re-match the 'function' keyword, so that
215 // the title mode below matches only exactly once
221 // name of the function/procedure
223 begin: '(\\bwith\\s+)?\\b(function|procedure)\\s+',
230 // // parameter types
235 begin: '\\breturn\\s+',
240 // we are done with functions
248 // new type declarations
249 // maybe inside generic
251 begin: '\\b(sub)?type\\s+',
258 // see comment above the definition
262 // relevance boosters for small snippets
263 // {begin: '\\s*=>\\s*'},
264 // {begin: '\\s*:=\\s*'},
265 // {begin: '\\s+:=\\s+'},
274 hljs
.registerLanguage('ada', hljsGrammar
);