diff --git a/AUTHORS.en.txt b/AUTHORS.en.txt index 006cea0fbe..7c41fdc4dc 100644 --- a/AUTHORS.en.txt +++ b/AUTHORS.en.txt @@ -255,5 +255,6 @@ Contributors: - Morten Piibeleht - Martin Clausen - Ahmad Awais +- Melissa Geels - Dmitriy Tarasov - Egor Rogov diff --git a/CHANGES.md b/CHANGES.md index dccadc89ca..a1561632f6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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][]. diff --git a/docs/css-classes-reference.rst b/docs/css-classes-reference.rst index 80e0e252bc..4ed2b4a853 100644 --- a/docs/css-classes-reference.rst +++ b/docs/css-classes-reference.rst @@ -137,6 +137,8 @@ Language names and aliases +-------------------------+---------------------------------------------------+ | ActionScript | actionscript, as | +-------------------------+---------------------------------------------------+ +| AngelScript | angelscript, asc | ++-------------------------+---------------------------------------------------+ | Apache | apache, apacheconf | +-------------------------+---------------------------------------------------+ | AppleScript | applescript, osascript | diff --git a/src/languages/angelscript.js b/src/languages/angelscript.js new file mode 100644 index 0000000000..34862cadfc --- /dev/null +++ b/src/languages/angelscript.js @@ -0,0 +1,111 @@ +/* +Language: AngelScript +Author: Melissa Geels +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?)?)' + } + ] + }; +} diff --git a/test/detect/angelscript/default.txt b/test/detect/angelscript/default.txt new file mode 100644 index 0000000000..1ed2ee3295 --- /dev/null +++ b/test/detect/angelscript/default.txt @@ -0,0 +1,42 @@ +interface IInterface +{ + void DoSomething(); +} + +namespace MyApplication +{ + /* + * This ia a test class. + */ + class SomeClass : IInterface + { + array m_arr; + + array m_children; + array> 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(); +}