]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/ada.js
1 /*! `ada` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar
= (function () {
7 Author: Lars Schulna <kartoffelbrei.mit.muskatnuss@gmail.org>
8 Description: Ada is a general-purpose programming language that has great support for saftey critical and real-time applications.
9 It has been developed by the DoD and thus has been used in military and safety-critical applications (like civil aviation).
10 The first version appeared in the 80s, but it's still actively developed today with
11 the newest standard being Ada2012.
14 // We try to support full Ada2012
16 // We highlight all appearances of types, keywords, literals (string, char, number, bool)
17 // and titles (user defined function/procedure/package)
18 // CSS classes are set accordingly
20 // Languages causing problems for language detection:
21 // xml (broken by Foo : Bar type), elm (broken by Foo : Bar type), vbscript-html (broken by body keyword)
22 // sql (ada default.txt has a lot of sql keywords)
24 /** @type LanguageFn */
26 // Regular expression for Ada numeric literals.
27 // stolen form the VHDL highlighter
30 const INTEGER_RE
= '\\d(_|\\d)*';
31 const EXPONENT_RE
= '[eE][-+]?' + INTEGER_RE
;
32 const DECIMAL_LITERAL_RE
= INTEGER_RE
+ '(\\.' + INTEGER_RE
+ ')?' + '(' + EXPONENT_RE
+ ')?';
35 const BASED_INTEGER_RE
= '\\w+';
36 const BASED_LITERAL_RE
= INTEGER_RE
+ '#' + BASED_INTEGER_RE
+ '(\\.' + BASED_INTEGER_RE
+ ')?' + '#' + '(' + EXPONENT_RE
+ ')?';
38 const NUMBER_RE
= '\\b(' + BASED_LITERAL_RE
+ '|' + DECIMAL_LITERAL_RE
+ ')';
41 const ID_REGEX
= '[A-Za-z](_?[A-Za-z0-9.])*';
43 // bad chars, only allowed in literals
44 const BAD_CHARS
= `[]\\{\\}%#'"`;
46 // Ada doesn't have block comments, only line comments
47 const COMMENTS
= hljs
.COMMENT('--', '$');
49 // variable declarations of the form
51 // where only Bar will be highlighted
53 // TODO: These spaces are not required by the Ada syntax
54 // however, I have yet to see handwritten Ada code where
55 // someone does not put spaces around :
57 end: '\\s*(:=|;|\\)|=>|$)',
58 // endsWithParent: true,
63 // workaround to avoid highlighting
64 // named loops and declare blocks
65 beginKeywords: 'loop for declare others',
69 // properly highlight all modifiers
71 beginKeywords: 'not null constant access function procedure in out aliased exception'
158 case_insensitive: true,
182 // character literals always contain one char
195 begin: "'" + ID_REGEX
198 // package definition, maybe inside generic
200 begin: '(\\bwith\\s+)?(\\bprivate\\s+)?\\bpackage\\s+(\\bbody\\s+)?',
202 keywords: 'package body',
208 // function/procedure declaration/definition
209 // maybe inside generic
210 begin: '(\\b(with|overriding)\\s+)?\\b(function|procedure)\\s+',
211 end: '(\\bis|\\bwith|\\brenames|\\)\\s*;)',
212 keywords: 'overriding function procedure with is renames return',
213 // we need to re-match the 'function' keyword, so that
214 // the title mode below matches only exactly once
220 // name of the function/procedure
222 begin: '(\\bwith\\s+)?\\b(function|procedure)\\s+',
229 // // parameter types
234 begin: '\\breturn\\s+',
239 // we are done with functions
247 // new type declarations
248 // maybe inside generic
250 begin: '\\b(sub)?type\\s+',
257 // see comment above the definition
261 // relevance boosters for small snippets
262 // {begin: '\\s*=>\\s*'},
263 // {begin: '\\s*:=\\s*'},
264 // {begin: '\\s+:=\\s+'},
273 export default hljsGrammar
;