Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
scie
提交
48044ba0
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 搜索 >>
未验证
提交
48044ba0
编写于
9月 03, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: remove unsued vaules defs
上级
feac0f7c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
20 addition
and
65 deletion
+20
-65
scie-grammar/src/grammar/grammar.rs
scie-grammar/src/grammar/grammar.rs
+10
-11
scie-grammar/src/inter/mod.rs
scie-grammar/src/inter/mod.rs
+1
-37
scie-grammar/src/rule/reg_exp_source.rs
scie-grammar/src/rule/reg_exp_source.rs
+8
-8
src/main.rs
src/main.rs
+1
-9
未找到文件。
scie-grammar/src/grammar/grammar.rs
浏览文件 @
48044ba0
...
...
@@ -133,7 +133,7 @@ impl Grammar {
}
let
scope_list
=
ScopeListElement
::
new
(
None
,
root_scope_name
);
let
mut
state
=
StackElement
::
new
(
let
state
=
StackElement
::
new
(
None
,
self
.root_id
.clone
(),
-
1
,
...
...
@@ -176,7 +176,7 @@ impl Grammar {
)
->
Option
<
StackElement
>
{
let
_
line_length
=
line_text
.len
();
let
mut
_
stop
=
false
;
let
mut
anchor_position
=
-
1
;
let
anchor_position
=
-
1
;
if
check_while_conditions
{
// todo: add realy logic
...
...
@@ -189,8 +189,8 @@ impl Grammar {
);
}
let
mut
line_pos
=
origin_line_pos
.clone
();
let
mut
is_first_line
=
origin_is_first
.clone
();
let
line_pos
=
origin_line_pos
.clone
();
let
is_first_line
=
origin_is_first
.clone
();
while
!
_
stop
{
let
r
=
self
.match_rule
(
line_text
.clone
(),
...
...
@@ -225,7 +225,7 @@ impl Grammar {
if
capture_indices
[
0
]
.end
==
_
line_length
{
begin_rule_capture_eol
=
true
;
}
let
mut
new_stack
=
stack
.clone
()
.push
(
let
new_stack
=
stack
.clone
()
.push
(
matched_rule_id
,
line_pos
,
anchor_position
,
...
...
@@ -247,17 +247,16 @@ impl Grammar {
return
None
;
}
_
=>
{
_
stop
=
true
;
return
None
;
}
}
}
if
capture_indices
[
0
]
.end
>
line_pos
as
usize
{
line_pos
=
capture_indices
[
0
]
.end
as
i32
;
is_first_line
=
false
;
}
//
//
if capture_indices[0].end > line_pos as usize {
//
line_pos = capture_indices[0].end as i32;
//
is_first_line = false;
//
}
}
Some
(
stack
.clone
())
}
...
...
scie-grammar/src/inter/mod.rs
浏览文件 @
48044ba0
...
...
@@ -17,7 +17,7 @@ pub use self::raw_rule::IRawRule;
#[cfg(test)]
mod
tests
{
use
crate
::
inter
::{
IRawCaptures
,
IRawGrammar
,
IRawRule
,
InjectionMap
};
use
crate
::
inter
::{
IRawCaptures
,
IRawGrammar
,
IRawRule
};
use
serde
::{
Deserialize
,
Serialize
};
use
std
::
fs
;
use
std
::
fs
::
File
;
...
...
@@ -53,42 +53,6 @@ mod tests {
assert_eq!
(
"punctuation.definition.item.text"
,
name
.unwrap
())
}
#[test]
fn
should_convert_injections
()
{
let
data
=
r#"
"injections": {
"R:text.html - comment.block": {
"comment": "Use R: to ensure this matches after any other injections.",
"patterns": [
{
"match": "<",
"name": "invalid.illegal.bad-angle-bracket.html"
}
]
}
}"#
;
let
p
:
InjectionMap
=
serde_json
::
from_str
(
data
)
.unwrap
();
let
pattern
=
p
.map
.get
(
"R:text.html - comment.block"
)
.unwrap
()
.patterns
.clone
();
assert_eq!
(
1
,
pattern
.clone
()
.unwrap
()
.len
());
assert_eq!
(
"<"
,
pattern
.clone
()
.unwrap
()
.first
()
.unwrap
()
.match_s
.clone
()
.unwrap
()
)
}
#[test]
fn
should_convert_rawrule
()
{
let
data
=
r#"
...
...
scie-grammar/src/rule/reg_exp_source.rs
浏览文件 @
48044ba0
...
...
@@ -3,19 +3,19 @@ use crate::rule::CompiledRule;
#[derive(Clone,
Debug,
Serialize)]
pub
struct
AnchorCache
{
A0_G
0
:
Option
<
String
>
,
A0_G
1
:
Option
<
String
>
,
A1_G
0
:
Option
<
String
>
,
A1_G
1
:
Option
<
String
>
,
a0_g
0
:
Option
<
String
>
,
a0_g
1
:
Option
<
String
>
,
a1_g
0
:
Option
<
String
>
,
a1_g
1
:
Option
<
String
>
,
}
impl
Default
for
AnchorCache
{
fn
default
()
->
Self
{
AnchorCache
{
A0_G
0
:
None
,
A0_G
1
:
None
,
A1_G
0
:
None
,
A1_G
1
:
None
,
a0_g
0
:
None
,
a0_g
1
:
None
,
a1_g
0
:
None
,
a1_g
1
:
None
,
}
}
}
...
...
src/main.rs
浏览文件 @
48044ba0
use
scie_grammar
::
inter
::{
ILocatable
,
ILocation
,
IRawCaptures
};
use
std
::
collections
::
HashMap
;
fn
main
()
{
let
location
=
ILocation
{
filename
:
""
.to_string
(),
line
:
""
.to_string
(),
chart
:
""
.to_string
(),
};
println!
(
"{:?}"
,
location
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录