Skip to content

Commit

Permalink
Add support for Ada (generic). Closes #949
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Jul 3, 2016
1 parent c9bdcd3 commit 65619f7
Show file tree
Hide file tree
Showing 13 changed files with 337 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ var components = {
"require": "javascript",
"owner": "Golmote"
},
"ada": {
"title": "Ada",
"owner": "Lucretia"
},
"apacheconf": {
"title": "Apache Configuration",
"owner": "GuiTeK"
Expand Down
19 changes: 19 additions & 0 deletions components/prism-ada.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Prism.languages.ada = {
'comment': /--.*/,
'string': /"(?:""|[^"\r\f\n])*"/i,
'number': [
{
pattern: /\b[0-9](?:_?[0-9])*#[0-9A-F](?:_?[0-9A-F])*(?:\.[0-9A-F](?:_?[0-9A-F])*)?#(?:E[+-]?[0-9](?:_?[0-9])*)?/i
},
{
pattern: /\b[0-9](?:_?[0-9])*(?:\.[0-9](?:_?[0-9])*)?(?:E[+-]?[0-9](?:_?[0-9])*)?\b/i
}
],
'attr-name': /\b'\w+/i,
'keyword': /\b(?:abort|abs|abstract|accept|access|aliased|all|and|array|at|begin|body|case|constant|declare|delay|delta|digits|do|else|new|return|elsif|end|entry|exception|exit|for|function|generic|goto|if|in|interface|is|limited|loop|mod|not|null|of|others|out|overriding|package|pragma|private|procedure|protected|raise|range|record|rem|renames|requeue|reverse|select|separate|some|subtype|synchronized|tagged|task|terminate|then|type|until|use|when|while|with|xor)\b/i,
'boolean': /\b(?:true|false)\b/i,
'operator': /<[=>]?|>=?|=>?|:=|\/=?|\*\*?|[&+-]/,
'punctuation': /\.\.?|[,;():]/,
'char': /'.'/,
'variable': /\b[a-z](?:[_a-z\d])*\b/i
};
1 change: 1 addition & 0 deletions components/prism-ada.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions examples/prism-ada.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<h1>Ada</h1>
<p>To use this language, use the class "language-ada".</p>

<h2>Strings</h2>
<pre><code>"foo ""bar"" baz"
"Multi-line strings are appended with a " &
"ampersand symbole."</code></pre>

<h2>Ada83 example</h2>
<pre><code>WITH ADA.TEXT_IO;

-- Comments look like this.

PROCEDURE TEST IS
BEGIN
ADA.TEXT_IO.PUT_LINE ("Hello"); -- Comments look like this.
END TEST;</code></pre>

<h2>Ada 2012 full example</h2>
<pre><code>with Ada.Text_IO; Use Ada.Text_IO;

-- Comments look like this.
procedure Test is
procedure Bah with
Import => True, -- Shows the new aspect feature of the language.
Convention => C,
External_Name => "bah";

type Things is range 1 .. 10;
begin
Put_Line ("Hello"); -- Comments look like this.

Bah; -- Call C function.

for Index in Things'Range loop
null;
end loop;
end Test;</code></pre>
13 changes: 13 additions & 0 deletions tests/languages/ada/attr-name_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Integer'Size
Character'Val

----------------------------------------------------

[
["variable", "Integer"], ["attr-name", "'Size"],
["variable", "Character"], ["attr-name", "'Val"]
]

----------------------------------------------------

Checks for attributes.
13 changes: 13 additions & 0 deletions tests/languages/ada/boolean_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
true
false

----------------------------------------------------

[
["boolean", "true"],
["boolean", "false"]
]

----------------------------------------------------

Checks for booleans.
13 changes: 13 additions & 0 deletions tests/languages/ada/char_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'f'
'A'

----------------------------------------------------

[
["char", "'f'"],
["char", "'A'"]
]

----------------------------------------------------

Checks for chars.
13 changes: 13 additions & 0 deletions tests/languages/ada/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--
-- Foo bar

----------------------------------------------------

[
["comment", "--"],
["comment", "-- Foo bar"]
]

----------------------------------------------------

Checks for comments.
153 changes: 153 additions & 0 deletions tests/languages/ada/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
abort
abs
abstract
accept
access
aliased
all
and
array
at
begin
body
case
constant
declare
delay
delta
digits
do
else
new
return
elsif
end
entry
exception
exit
for
function
generic
goto
if
in
interface
is
limited
loop
mod
not
null
of
others
out
overriding
package
pragma
private
procedure
protected
raise
range
record
rem
renames
requeue
reverse
select
separate
some
subtype
synchronized
tagged
task
terminate
then
type
until
use
when
while
with
xor

----------------------------------------------------

[
["keyword", "abort"],
["keyword", "abs"],
["keyword", "abstract"],
["keyword", "accept"],
["keyword", "access"],
["keyword", "aliased"],
["keyword", "all"],
["keyword", "and"],
["keyword", "array"],
["keyword", "at"],
["keyword", "begin"],
["keyword", "body"],
["keyword", "case"],
["keyword", "constant"],
["keyword", "declare"],
["keyword", "delay"],
["keyword", "delta"],
["keyword", "digits"],
["keyword", "do"],
["keyword", "else"],
["keyword", "new"],
["keyword", "return"],
["keyword", "elsif"],
["keyword", "end"],
["keyword", "entry"],
["keyword", "exception"],
["keyword", "exit"],
["keyword", "for"],
["keyword", "function"],
["keyword", "generic"],
["keyword", "goto"],
["keyword", "if"],
["keyword", "in"],
["keyword", "interface"],
["keyword", "is"],
["keyword", "limited"],
["keyword", "loop"],
["keyword", "mod"],
["keyword", "not"],
["keyword", "null"],
["keyword", "of"],
["keyword", "others"],
["keyword", "out"],
["keyword", "overriding"],
["keyword", "package"],
["keyword", "pragma"],
["keyword", "private"],
["keyword", "procedure"],
["keyword", "protected"],
["keyword", "raise"],
["keyword", "range"],
["keyword", "record"],
["keyword", "rem"],
["keyword", "renames"],
["keyword", "requeue"],
["keyword", "reverse"],
["keyword", "select"],
["keyword", "separate"],
["keyword", "some"],
["keyword", "subtype"],
["keyword", "synchronized"],
["keyword", "tagged"],
["keyword", "task"],
["keyword", "terminate"],
["keyword", "then"],
["keyword", "type"],
["keyword", "until"],
["keyword", "use"],
["keyword", "when"],
["keyword", "while"],
["keyword", "with"],
["keyword", "xor"]
]

----------------------------------------------------

Checks for keywords.
21 changes: 21 additions & 0 deletions tests/languages/ada/number_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
42
42_000
3.14_15_9
0.4E+123_456
3.7e-7
1_6#Bad_Face#E-32_1

----------------------------------------------------

[
["number", "42"],
["number", "42_000"],
["number", "3.14_15_9"],
["number", "0.4E+123_456"],
["number", "3.7e-7"],
["number", "1_6#Bad_Face#E-32_1"]
]

----------------------------------------------------

Checks for numbers.
23 changes: 23 additions & 0 deletions tests/languages/ada/operator_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<>
=> :=
< <=
> >=
= /=
& + -
* ** /

----------------------------------------------------

[
["operator", "<>"],
["operator", "=>"], ["operator", ":="],
["operator", "<"], ["operator", "<="],
["operator", ">"], ["operator", ">="],
["operator", "="], ["operator", "/="],
["operator", "&"], ["operator", "+"], ["operator", "-"],
["operator", "*"], ["operator", "**"], ["operator", "/"]
]

----------------------------------------------------

Checks for operators.
13 changes: 13 additions & 0 deletions tests/languages/ada/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
""
"Foo""bar"""

----------------------------------------------------

[
["string", "\"\""],
["string", "\"Foo\"\"bar\"\"\""]
]

----------------------------------------------------

Checks for strings.
13 changes: 13 additions & 0 deletions tests/languages/ada/variable_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Byte
foo_bar42

----------------------------------------------------

[
["variable", "Byte"],
["variable", "foo_bar42"]
]

----------------------------------------------------

Checks for variables.

0 comments on commit 65619f7

Please sign in to comment.