Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
1ddc7d4e
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,发现更多精彩内容 >>
提交
1ddc7d4e
编写于
6月 15, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix TS 2.4 monarch issues
上级
42d3d542
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
14 deletion
+32
-14
src/vs/editor/common/modes/monarch/monarchCommon.ts
src/vs/editor/common/modes/monarch/monarchCommon.ts
+22
-4
src/vs/editor/common/modes/monarch/monarchCompile.ts
src/vs/editor/common/modes/monarch/monarchCompile.ts
+4
-4
src/vs/editor/common/modes/monarch/monarchLexer.ts
src/vs/editor/common/modes/monarch/monarchLexer.ts
+6
-6
未找到文件。
src/vs/editor/common/modes/monarch/monarchCommon.ts
浏览文件 @
1ddc7d4e
...
...
@@ -46,19 +46,37 @@ export interface IBracket {
close
:
string
;
}
export
type
FuzzyAction
=
IAction
|
string
;
export
function
isFuzzyActionArr
(
what
:
FuzzyAction
|
FuzzyAction
[]):
what
is
FuzzyAction
[]
{
return
(
Array
.
isArray
(
what
));
}
export
function
isFuzzyAction
(
what
:
FuzzyAction
|
FuzzyAction
[]):
what
is
FuzzyAction
{
return
!
isFuzzyActionArr
(
what
);
}
export
function
isString
(
what
:
FuzzyAction
):
what
is
string
{
return
(
typeof
what
===
'
string
'
);
}
export
function
isIAction
(
what
:
FuzzyAction
):
what
is
IAction
{
return
!
isString
(
what
);
}
export
interface
IRule
{
regex
:
RegExp
;
action
:
I
Action
;
action
:
Fuzzy
Action
;
matchOnlyAtLineStart
:
boolean
;
name
:
string
;
}
export
interface
IAction
{
// an action is either a group of actions
group
?:
I
Action
[];
group
?:
Fuzzy
Action
[];
// or a function that returns a fresh action
test
?:
(
id
:
string
,
matches
:
string
[],
state
:
string
,
eos
:
boolean
)
=>
I
Action
;
test
?:
(
id
:
string
,
matches
:
string
[],
state
:
string
,
eos
:
boolean
)
=>
Fuzzy
Action
;
// or it is a declarative action with a token value and various other attributes
token
?:
string
;
...
...
@@ -74,7 +92,7 @@ export interface IAction {
export
interface
IBranch
{
name
:
string
;
value
:
I
Action
;
value
:
Fuzzy
Action
;
test
:
(
id
:
string
,
matches
:
string
[],
state
:
string
,
eos
:
boolean
)
=>
boolean
;
}
...
...
src/vs/editor/common/modes/monarch/monarchCompile.ts
浏览文件 @
1ddc7d4e
...
...
@@ -118,7 +118,7 @@ function selectScrutinee(id: string, matches: string[], state: string, num: numb
return
null
;
}
function
createGuard
(
lexer
:
monarchCommon
.
ILexerMin
,
ruleName
:
string
,
tkey
:
string
,
val
:
monarchCommon
.
I
Action
):
monarchCommon
.
IBranch
{
function
createGuard
(
lexer
:
monarchCommon
.
ILexerMin
,
ruleName
:
string
,
tkey
:
string
,
val
:
monarchCommon
.
Fuzzy
Action
):
monarchCommon
.
IBranch
{
// get the scrutinee and pattern
var
scrut
=
-
1
;
// -1: $!, 0-99: $n, 100+n: $Sn
var
oppat
=
tkey
;
...
...
@@ -222,7 +222,7 @@ function createGuard(lexer: monarchCommon.ILexerMin, ruleName: string, tkey: str
* contains user functions as actions (which is usually not allowed), then this
* may be called during lexing. It is important therefore to compile common cases efficiently
*/
function
compileAction
(
lexer
:
monarchCommon
.
ILexerMin
,
ruleName
:
string
,
action
:
any
):
monarchCommon
.
I
Action
{
function
compileAction
(
lexer
:
monarchCommon
.
ILexerMin
,
ruleName
:
string
,
action
:
any
):
monarchCommon
.
Fuzzy
Action
{
if
(
!
action
)
{
return
{
token
:
''
};
}
...
...
@@ -285,7 +285,7 @@ function compileAction(lexer: monarchCommon.ILexerMin, ruleName: string, action:
}
}
else
if
(
Array
.
isArray
(
action
))
{
var
results
=
[];
var
results
:
monarchCommon
.
FuzzyAction
[]
=
[];
var
idx
:
string
;
for
(
idx
in
action
)
{
if
(
action
.
hasOwnProperty
(
idx
))
{
...
...
@@ -345,7 +345,7 @@ function compileAction(lexer: monarchCommon.ILexerMin, ruleName: string, action:
*/
class
Rule
implements
monarchCommon
.
IRule
{
public
regex
:
RegExp
=
new
RegExp
(
''
);
public
action
:
monarchCommon
.
I
Action
=
{
token
:
''
};
public
action
:
monarchCommon
.
Fuzzy
Action
=
{
token
:
''
};
public
matchOnlyAtLineStart
:
boolean
=
false
;
public
name
:
string
=
''
;
...
...
src/vs/editor/common/modes/monarch/monarchLexer.ts
浏览文件 @
1ddc7d4e
...
...
@@ -459,7 +459,7 @@ export class MonarchTokenizer implements modes.ITokenizationSupport {
continue
;
}
let
rule
:
monarchCommon
.
IRule
=
rules
[
idx
];
if
(
rule
.
action
.
nextEmbedded
!==
'
@pop
'
)
{
if
(
monarchCommon
.
isIAction
(
rule
.
action
)
&&
rule
.
action
.
nextEmbedded
!==
'
@pop
'
)
{
continue
;
}
hasEmbeddedPopRule
=
true
;
...
...
@@ -518,7 +518,7 @@ export class MonarchTokenizer implements modes.ITokenizationSupport {
// regular expression group matching
// these never need cloning or equality since they are only used within a line match
let
groupActions
:
monarchCommon
.
I
Action
[]
=
null
;
let
groupActions
:
monarchCommon
.
Fuzzy
Action
[]
=
null
;
let
groupMatches
:
string
[]
=
null
;
let
groupMatched
:
string
[]
=
null
;
let
groupRule
:
monarchCommon
.
IRule
=
null
;
...
...
@@ -531,7 +531,7 @@ export class MonarchTokenizer implements modes.ITokenizationSupport {
let
matches
:
string
[]
=
null
;
let
matched
:
string
=
null
;
let
action
:
monarchCommon
.
IAction
=
null
;
let
action
:
monarchCommon
.
FuzzyAction
|
monarchCommon
.
FuzzyAction
[]
=
null
;
let
rule
:
monarchCommon
.
IRule
=
null
;
let
enteringEmbeddedMode
:
string
=
null
;
...
...
@@ -604,11 +604,11 @@ export class MonarchTokenizer implements modes.ITokenizationSupport {
pos
+=
matched
.
length
;
// maybe call action function (used for 'cases')
while
(
action
.
test
)
{
while
(
monarchCommon
.
isFuzzyAction
(
action
)
&&
monarchCommon
.
isIAction
(
action
)
&&
action
.
test
)
{
action
=
action
.
test
(
matched
,
matches
,
state
,
pos
===
lineLength
);
}
let
result
:
string
|
monarchCommon
.
I
Action
[]
=
null
;
let
result
:
monarchCommon
.
FuzzyAction
|
monarchCommon
.
Fuzzy
Action
[]
=
null
;
// set the result: either a string or an array of actions
if
(
typeof
action
===
'
string
'
||
Array
.
isArray
(
action
))
{
result
=
action
;
...
...
@@ -739,7 +739,7 @@ export class MonarchTokenizer implements modes.ITokenizationSupport {
// return the result (and check for brace matching)
// todo: for efficiency we could pre-sanitize tokenPostfix and substitutions
let
tokenType
:
string
=
null
;
if
(
result
.
indexOf
(
'
@brackets
'
)
===
0
)
{
if
(
monarchCommon
.
isString
(
result
)
&&
result
.
indexOf
(
'
@brackets
'
)
===
0
)
{
let
rest
=
result
.
substr
(
'
@brackets
'
.
length
);
let
bracket
=
findBracket
(
this
.
_lexer
,
matched
);
if
(
!
bracket
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录