Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,6 @@ Contributors:
- Morten Piibeleht <morten.piibeleht@gmail.com>
- Martin Clausen <martin.clausene@gmail.com>
- Ahmad Awais <me@AhmadAwais.com>
- Melissa Geels <melissa@nimble.tools>
- Dmitriy Tarasov <dimatar@gmail.com>
- Egor Rogov <e.rogov@postgrespro.ru>
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ New style:

New language:

- *AngelScript* by [Melissa Geels][]
- *GML* by [meseta][]
- *PostgreSQL* SQL dialect and PL/pgSQL language by [Egor Rogov][].

Expand Down
2 changes: 2 additions & 0 deletions docs/css-classes-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ Language names and aliases
+-------------------------+---------------------------------------------------+
| ActionScript | actionscript, as |
+-------------------------+---------------------------------------------------+
| AngelScript | angelscript, asc |
+-------------------------+---------------------------------------------------+
| Apache | apache, apacheconf |
+-------------------------+---------------------------------------------------+
| AppleScript | applescript, osascript |
Expand Down
111 changes: 111 additions & 0 deletions src/languages/angelscript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
Language: AngelScript
Author: Melissa Geels <melissa@nimble.tools>
Category: scripting
*/

function(hljs) {
var builtInTypeMode = {
className: 'built_in',
begin: '\\b(void|bool|int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|string|ref|array|double|float|auto|dictionary)'
};

var objectHandleMode = {
className: 'symbol',
begin: '[a-zA-Z0-9_]+@'
};

var genericMode = {
className: 'keyword',
begin: '<', end: '>',
contains: [ builtInTypeMode, objectHandleMode ]
};

builtInTypeMode.contains = [ genericMode ];
objectHandleMode.contains = [ genericMode ];

return {
aliases: [ 'asc' ],

keywords:
'for in|0 break continue while do|0 return if else case switch namespace is cast ' +
'or and xor not get|0 in inout|10 out override set|0 private public const default|0 ' +
'final shared external mixin|10 enum typedef funcdef this super import from interface',

// avoid close detection with C# and JS
illegal: '(^using\\s+[A-Za-z0-9_\\.]+;$|\\bfunction\s*[^\\(])',

contains: [
{ // 'strings'
className: 'string',
begin: '\'', end: '\'',
illegal: '\\n',
contains: [ hljs.BACKSLASH_ESCAPE ],
relevance: 0
},

{ // "strings"
className: 'string',
begin: '"', end: '"',
illegal: '\\n',
contains: [ hljs.BACKSLASH_ESCAPE ],
relevance: 0
},

// """heredoc strings"""
{
className: 'string',
begin: '"""', end: '"""'
},

hljs.C_LINE_COMMENT_MODE, // single-line comments
hljs.C_BLOCK_COMMENT_MODE, // comment blocks

{ // interface or namespace declaration
beginKeywords: 'interface namespace', end: '{',
illegal: '[;.\\-]',
contains: [
{ // interface or namespace name
className: 'symbol',
begin: '[a-zA-Z0-9_]+'
}
]
},

{ // class declaration
beginKeywords: 'class', end: '{',
illegal: '[;.\\-]',
contains: [
{ // class name
className: 'symbol',
begin: '[a-zA-Z0-9_]+',
contains: [
{
begin: '[:,]\\s*',
contains: [
{
className: 'symbol',
begin: '[a-zA-Z0-9_]+'
}
]
}
]
}
]
},

builtInTypeMode, // built-in types
objectHandleMode, // object handles

{ // literals
className: 'literal',
begin: '\\b(null|true|false)'
},

{ // numbers
className: 'number',
begin: '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?f?|\\.\\d+f?)([eE][-+]?\\d+f?)?)'
}
]
};
}
42 changes: 42 additions & 0 deletions test/detect/angelscript/default.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
interface IInterface
{
void DoSomething();
}

namespace MyApplication
{
/*
* This ia a test class.
*/
class SomeClass : IInterface
{
array<float> m_arr;

array<SomeClass@> m_children;
array<array<SomeClass@>> m_subChildren; // Nested templates

SomeClass()
{
// Add some integers
m_arr.insertLast(1.0f);
m_arr.insertLast(1.75f);
m_arr.insertLast(3.14159f);
uint x = 0x7fff0000;
int y = 9001;
}

void DoSomething()
{
print("Something! " + 'stuff.');
for (uint i = 0; i < m_arr.length(); i++) {
print(" " + i + ": " + m_arr[i]);
}
}
}
}

void Main()
{
SomeClass@ c = SomeClass();
c.DoSomething();
}