Skip to content

Commit 00a6749

Browse files
authored
enh(angelscript) Improve heredocs, numbers, metadata blocks (#2724)
* Fixed problematic heredoc strings * Fixed unhandled valid number formatting * Added missing metadata block * Added more Angelscript code to detect test case
1 parent e980213 commit 00a6749

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ Language Improvements:
1313
- fix(javascript) Comments inside params should be highlighted (#2702) [Josh Goebel][]
1414
- fix(scala) Comments inside class header should be highlighted (#1559) [Josh Goebel][]
1515
- fix(c-like) Correctly highlight modifiers (`final`) in class declaration (#2696) [Josh Goebel][]
16+
- enh(angelscript) Improve heredocs, numbers, metadata blocks (#2724) [Melissa Geels][]
1617

1718
[David Pine]: https://github.com/IEvangelist
1819
[Josh Goebel]: https://github.com/joshgoebel
1920
[Ryan Jonasson]: https://github.com/ryanjonasson
2021
[Philipp Engel]: https://github.com/interkosmos
2122
[Konrad Rudolph]: https://github.com/klmr
23+
[Melissa Geels]: https://github.com/codecat
2224

2325

2426
## Version 10.2.1

src/languages/angelscript.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ export default function(hljs) {
4848
relevance: 0
4949
},
5050

51+
// """heredoc strings"""
52+
{
53+
className: 'string',
54+
begin: '"""', end: '"""'
55+
},
56+
5157
{ // "strings"
5258
className: 'string',
5359
begin: '"', end: '"',
@@ -56,15 +62,14 @@ export default function(hljs) {
5662
relevance: 0
5763
},
5864

59-
// """heredoc strings"""
60-
{
61-
className: 'string',
62-
begin: '"""', end: '"""'
63-
},
64-
6565
hljs.C_LINE_COMMENT_MODE, // single-line comments
6666
hljs.C_BLOCK_COMMENT_MODE, // comment blocks
6767

68+
{ // metadata
69+
className: 'string',
70+
begin: '^\\s*\\[', end: '\\]',
71+
},
72+
6873
{ // interface or namespace declaration
6974
beginKeywords: 'interface namespace', end: '{',
7075
illegal: '[;.\\-]',
@@ -108,7 +113,7 @@ export default function(hljs) {
108113

109114
{ // numbers
110115
className: 'number',
111-
begin: '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?f?|\\.\\d+f?)([eE][-+]?\\d+f?)?)'
116+
begin: '(-?)(\\b0[xXbBoOdD][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?f?|\\.\\d+f?)([eE][-+]?\\d+f?)?)'
112117
}
113118
]
114119
};

test/detect/angelscript/default.txt

+6
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ namespace MyApplication
2525
m_arr.insertLast(3.14159f);
2626
uint x = 0x7fff0000;
2727
int y = 9001;
28+
uint z = 0b10101010;
2829
}
2930

3031
int get_Thing() property { return m_thing; }
3132
void set_Thing(int x) property { m_thing = x; }
3233

34+
[Hook x=1 y=2]
3335
void DoSomething()
3436
{
3537
print("Something! " + 'stuff.');
@@ -54,3 +56,7 @@ void Main()
5456
SomeClass@ c = SomeClass();
5557
c.DoSomething();
5658
}
59+
60+
string multilineString = """
61+
Hello world, "this is a test"!
62+
""";

0 commit comments

Comments
 (0)