Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
scie
提交
671e0e2b
S
scie
项目概览
Phodal
/
scie
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
scie
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
671e0e2b
编写于
8月 29, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: fix stack element issues
上级
ec19ab29
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
16 deletion
+31
-16
scie-grammar/src/grammar/grammar/mod.rs
scie-grammar/src/grammar/grammar/mod.rs
+13
-10
scie-grammar/src/grammar/grammar/stack_element.rs
scie-grammar/src/grammar/grammar/stack_element.rs
+17
-2
scie-grammar/src/grammar/grammar_reader.rs
scie-grammar/src/grammar/grammar_reader.rs
+1
-4
未找到文件。
scie-grammar/src/grammar/grammar/mod.rs
浏览文件 @
671e0e2b
...
@@ -9,6 +9,7 @@ use crate::rule::{
...
@@ -9,6 +9,7 @@ use crate::rule::{
};
};
use
crate
::
rule
::
rule_factory
::
RuleFactory
;
use
crate
::
rule
::
rule_factory
::
RuleFactory
;
use
crate
::
grammar
::
line_tokens
::{
LineTokens
,
TokenTypeMatcher
};
use
crate
::
grammar
::
line_tokens
::{
LineTokens
,
TokenTypeMatcher
};
use
crate
::
grammar
::
grammar
::
scope_list_element
::
ScopeListElement
;
pub
mod
scope_list_element
;
pub
mod
scope_list_element
;
pub
mod
scope_metadata
;
pub
mod
scope_metadata
;
...
@@ -103,7 +104,7 @@ impl Grammar {
...
@@ -103,7 +104,7 @@ impl Grammar {
fn
tokenize
(
fn
tokenize
(
&
mut
self
,
&
mut
self
,
line_text
:
String
,
line_text
:
String
,
prev_state
:
Option
<
StackElement
>
,
mut
prev_state
:
Option
<
StackElement
>
,
emit_binary_tokens
:
bool
,
emit_binary_tokens
:
bool
,
)
{
)
{
if
self
.root_id
.clone
()
==
-
1
{
if
self
.root_id
.clone
()
==
-
1
{
...
@@ -125,13 +126,18 @@ impl Grammar {
...
@@ -125,13 +126,18 @@ impl Grammar {
}
}
}
}
if
is_first_line
{
let
scope_list
=
ScopeListElement
::
default
();
prev_state
=
Some
(
StackElement
::
new
(
None
,
self
.root_id
.clone
(),
-
1
,
-
1
,
false
,
None
,
scope_list
.clone
(),
scope_list
.clone
()))
}
let
format_line_text
=
format!
(
"{:?}
\n
"
,
line_text
);
let
format_line_text
=
format!
(
"{:?}
\n
"
,
line_text
);
let
line_tokens
=
LineTokens
::
new
(
emit_binary_tokens
,
line_text
,
self
._token_type_matchers
.clone
());
let
line_tokens
=
LineTokens
::
new
(
emit_binary_tokens
,
line_text
,
self
._token_type_matchers
.clone
());
self
.tokenize_string
(
self
.tokenize_string
(
format_line_text
.parse
()
.unwrap
(),
format_line_text
.parse
()
.unwrap
(),
is_first_line
,
is_first_line
,
0
,
0
,
prev_state
,
prev_state
.unwrap
()
,
line_tokens
,
line_tokens
,
true
,
true
,
)
)
...
@@ -142,7 +148,7 @@ impl Grammar {
...
@@ -142,7 +148,7 @@ impl Grammar {
line_text
:
String
,
line_text
:
String
,
is_first_line
:
bool
,
is_first_line
:
bool
,
line_pos
:
i32
,
line_pos
:
i32
,
prev_state
:
Option
<
StackElement
>
,
prev_state
:
StackElement
,
line_tokens
:
LineTokens
,
line_tokens
:
LineTokens
,
check_while_conditions
:
bool
,
check_while_conditions
:
bool
,
)
{
)
{
...
@@ -161,9 +167,8 @@ impl Grammar {
...
@@ -161,9 +167,8 @@ impl Grammar {
);
);
}
}
if
let
Some
(
stack
)
=
prev_state
{
self
.match_rule_or_injections
(
line_text
,
is_first_line
,
line_pos
,
stack
.clone
(),
anchor_position
);
self
.match_rule_or_injections
(
line_text
,
is_first_line
,
line_pos
,
prev_state
,
anchor_position
);
}
}
}
pub
fn
check_while_conditions
(
pub
fn
check_while_conditions
(
...
@@ -171,13 +176,11 @@ impl Grammar {
...
@@ -171,13 +176,11 @@ impl Grammar {
line_text
:
String
,
line_text
:
String
,
is_first_line
:
bool
,
is_first_line
:
bool
,
line_pos
:
i32
,
line_pos
:
i32
,
_
stack
:
Option
<
StackElement
>
,
_
stack
:
StackElement
,
line_tokens
:
LineTokens
,
line_tokens
:
LineTokens
,
)
{
)
{
let
mut
anchor_position
=
-
1
;
let
mut
anchor_position
=
-
1
;
if
let
Some
(
stack
)
=
_
stack
{
if
_
stack
.begin_rule_captured_eol
{
anchor_position
=
0
}
if
stack
.begin_rule_captured_eol
{
anchor_position
=
0
}
};
// let while_rules = vec![];
// let while_rules = vec![];
}
}
...
...
scie-grammar/src/grammar/grammar/stack_element.rs
浏览文件 @
671e0e2b
...
@@ -18,8 +18,8 @@ pub struct StackElement {
...
@@ -18,8 +18,8 @@ pub struct StackElement {
}
}
impl
StackElement
{
impl
StackElement
{
pub
fn
null
()
->
S
tackElement
{
pub
fn
null
()
->
S
elf
{
S
tackElement
{
S
elf
{
parent
:
None
,
parent
:
None
,
depth
:
0
,
depth
:
0
,
rule_id
:
0
,
rule_id
:
0
,
...
@@ -32,10 +32,25 @@ impl StackElement {
...
@@ -32,10 +32,25 @@ impl StackElement {
}
}
}
}
pub
fn
pop
(
&
self
)
->
Option
<
Box
<
StackElement
>>
{
pub
fn
pop
(
&
self
)
->
Option
<
Box
<
StackElement
>>
{
self
.clone
()
.parent
self
.clone
()
.parent
}
}
pub
fn
get_rule
(
&
self
,
grammar
:
&
mut
Grammar
)
->
Box
<
dyn
AbstractRule
>
{
pub
fn
get_rule
(
&
self
,
grammar
:
&
mut
Grammar
)
->
Box
<
dyn
AbstractRule
>
{
grammar
.get_rule
(
self
.rule_id
)
grammar
.get_rule
(
self
.rule_id
)
}
}
pub
fn
new
(
parent
:
Option
<
Box
<
StackElement
>>
,
rule_id
:
i32
,
enter_pos
:
i32
,
anchor_pos
:
i32
,
begin_rule_captured_eol
:
bool
,
end_rule
:
Option
<
String
>
,
name_scopes_list
:
ScopeListElement
,
content_name_scopes_list
:
ScopeListElement
)
->
Self
{
StackElement
{
parent
,
// todo: this.depth = (this.parent ? this.parent.depth + 1 : 1);
depth
:
1
,
rule_id
,
enter_pos
,
anchor_pos
,
begin_rule_captured_eol
,
end_rule
,
name_scopes_list
,
content_name_scopes_list
}
}
}
}
scie-grammar/src/grammar/grammar_reader.rs
浏览文件 @
671e0e2b
...
@@ -23,9 +23,6 @@ mod tests {
...
@@ -23,9 +23,6 @@ mod tests {
#[test]
#[test]
fn
should_run
()
{
fn
should_run
()
{
let
grammar
=
parse_raw_grammar
(
String
::
from
(
"hello"
),
Some
(
String
::
from
(
"world.json"
)));
let
grammar
=
parse_raw_grammar
(
String
::
from
(
"hello"
),
Some
(
String
::
from
(
"world.json"
)));
assert_eq!
(
assert_eq!
(
format!
(
"{:?}"
,
grammar
.unwrap
()
.location
),
"None"
);
format!
(
"{:?}"
,
grammar
.unwrap
()
.location
),
"ILocatable { textmate_location: None }"
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录