Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4b00bed1
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4b00bed1
编写于
5月 23, 2020
作者:
D
Daniel Kelling
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for Unicode-aware regular expressions in Monaco Monarch language definitions
上级
a1ed3861
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
17 addition
and
3 deletion
+17
-3
src/vs/editor/standalone/common/monarch/monarchCommon.ts
src/vs/editor/standalone/common/monarch/monarchCommon.ts
+2
-0
src/vs/editor/standalone/common/monarch/monarchCompile.ts
src/vs/editor/standalone/common/monarch/monarchCompile.ts
+5
-2
src/vs/editor/standalone/common/monarch/monarchLexer.ts
src/vs/editor/standalone/common/monarch/monarchLexer.ts
+2
-1
src/vs/editor/standalone/common/monarch/monarchTypes.ts
src/vs/editor/standalone/common/monarch/monarchTypes.ts
+4
-0
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+4
-0
未找到文件。
src/vs/editor/standalone/common/monarch/monarchCommon.ts
浏览文件 @
4b00bed1
...
...
@@ -24,6 +24,7 @@ export interface ILexerMin {
languageId
:
string
;
noThrow
:
boolean
;
ignoreCase
:
boolean
;
unicode
:
boolean
;
usesEmbedded
:
boolean
;
defaultToken
:
string
;
stateNames
:
{
[
stateName
:
string
]:
any
;
};
...
...
@@ -34,6 +35,7 @@ export interface ILexer extends ILexerMin {
maxStack
:
number
;
start
:
string
|
null
;
ignoreCase
:
boolean
;
unicode
:
boolean
;
tokenPostfix
:
string
;
tokenizer
:
{
[
stateName
:
string
]:
IRule
[];
};
...
...
src/vs/editor/standalone/common/monarch/monarchCompile.ts
浏览文件 @
4b00bed1
...
...
@@ -79,7 +79,7 @@ function createKeywordMatcher(arr: string[], caseInsensitive: boolean = false):
// Lexer helpers
/**
* Compiles a regular expression string, adding the 'i' flag if 'ignoreCase' is set.
* Compiles a regular expression string, adding the 'i' flag if 'ignoreCase' is set
, and the 'u' flag if 'unicode' is set
.
* Also replaces @\w+ or sequences with the content of the specified attribute
*/
function
compileRegExp
(
lexer
:
monarchCommon
.
ILexerMin
,
str
:
string
):
RegExp
{
...
...
@@ -103,7 +103,8 @@ function compileRegExp(lexer: monarchCommon.ILexerMin, str: string): RegExp {
});
}
return
new
RegExp
(
str
,
(
lexer
.
ignoreCase
?
'
i
'
:
''
));
let
flags
=
(
lexer
.
ignoreCase
?
'
i
'
:
''
)
+
(
lexer
.
unicode
?
'
u
'
:
''
);
return
new
RegExp
(
str
,
flags
);
}
/**
...
...
@@ -400,6 +401,7 @@ export function compile(languageId: string, json: IMonarchLanguage): monarchComm
// Set standard fields: be defensive about types
lexer
.
start
=
(
typeof
json
.
start
===
'
string
'
?
json
.
start
:
null
);
lexer
.
ignoreCase
=
bool
(
json
.
ignoreCase
,
false
);
lexer
.
unicode
=
bool
(
json
.
unicode
,
false
);
lexer
.
tokenPostfix
=
string
(
json
.
tokenPostfix
,
'
.
'
+
lexer
.
languageId
);
lexer
.
defaultToken
=
string
(
json
.
defaultToken
,
'
source
'
);
...
...
@@ -410,6 +412,7 @@ export function compile(languageId: string, json: IMonarchLanguage): monarchComm
let
lexerMin
:
monarchCommon
.
ILexerMin
=
<
any
>
json
;
lexerMin
.
languageId
=
languageId
;
lexerMin
.
ignoreCase
=
lexer
.
ignoreCase
;
lexerMin
.
unicode
=
lexer
.
unicode
;
lexerMin
.
noThrow
=
lexer
.
noThrow
;
lexerMin
.
usesEmbedded
=
lexer
.
usesEmbedded
;
lexerMin
.
stateNames
=
json
.
tokenizer
;
...
...
src/vs/editor/standalone/common/monarch/monarchLexer.ts
浏览文件 @
4b00bed1
...
...
@@ -497,7 +497,8 @@ export class MonarchTokenizer implements modes.ITokenizationSupport {
let
regex
=
rule
.
regex
;
let
regexSource
=
rule
.
regex
.
source
;
if
(
regexSource
.
substr
(
0
,
4
)
===
'
^(?:
'
&&
regexSource
.
substr
(
regexSource
.
length
-
1
,
1
)
===
'
)
'
)
{
regex
=
new
RegExp
(
regexSource
.
substr
(
4
,
regexSource
.
length
-
5
),
regex
.
ignoreCase
?
'
i
'
:
''
);
let
flags
=
(
regex
.
ignoreCase
?
'
i
'
:
''
)
+
(
regex
.
unicode
?
'
u
'
:
''
);
regex
=
new
RegExp
(
regexSource
.
substr
(
4
,
regexSource
.
length
-
5
),
flags
);
}
let
result
=
line
.
search
(
regex
);
...
...
src/vs/editor/standalone/common/monarch/monarchTypes.ts
浏览文件 @
4b00bed1
...
...
@@ -21,6 +21,10 @@ export interface IMonarchLanguage {
* is the language case insensitive?
*/
ignoreCase
?:
boolean
;
/**
* is the language unicode-aware? (i.e., /\u{1D306}/)
*/
unicode
?:
boolean
;
/**
* if no match in the tokenizer assign this token class (default 'source')
*/
...
...
src/vs/monaco.d.ts
浏览文件 @
4b00bed1
...
...
@@ -6286,6 +6286,10 @@ declare namespace monaco.languages {
* is the language case insensitive?
*/
ignoreCase
?:
boolean
;
/**
* is the language unicode-aware? (i.e., /\u{1D306}/)
*/
unicode
?:
boolean
;
/**
* if no match in the tokenizer assign this token class (default 'source')
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录