Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
scie
提交
f1980b93
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 搜索 >>
未验证
提交
f1980b93
编写于
8月 29, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: extract begin end rule
上级
e2441010
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
68 addition
and
62 deletion
+68
-62
scie-grammar/src/rule/begin_end_rule.rs
scie-grammar/src/rule/begin_end_rule.rs
+65
-0
scie-grammar/src/rule/mod.rs
scie-grammar/src/rule/mod.rs
+3
-62
未找到文件。
scie-grammar/src/rule/begin_end_rule.rs
浏览文件 @
f1980b93
use
crate
::
rule
::
reg_exp_source
::{
RegExpSource
,
RegExpSourceList
};
use
crate
::
rule
::{
Rule
,
AbstractRule
};
use
crate
::
inter
::
ILocation
;
use
crate
::
rule
::
rule_factory
::
ICompilePatternsResult
;
#[derive(Clone,
Debug,
Serialize)]
pub
struct
BeginEndRule
{
#[serde(flatten)]
pub
rule
:
Rule
,
pub
_
begin
:
RegExpSource
,
pub
begin_captures
:
Vec
<
Box
<
dyn
AbstractRule
>>
,
pub
_
end
:
RegExpSource
,
// pub endHasBackReferences: Option<bool>,
pub
end_captures
:
Vec
<
Box
<
dyn
AbstractRule
>>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
apply_end_pattern_last
:
Option
<
bool
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
_
cached_compiled_patterns
:
Option
<
RegExpSourceList
>
,
pub
patterns
:
Vec
<
i32
>
,
pub
has_missing_patterns
:
bool
,
}
impl
BeginEndRule
{
pub
fn
new
(
location
:
Option
<
ILocation
>
,
id
:
i32
,
name
:
Option
<
String
>
,
content_name
:
Option
<
String
>
,
begin
:
String
,
begin_captures
:
Vec
<
Box
<
dyn
AbstractRule
>>
,
_
end
:
String
,
end_captures
:
Vec
<
Box
<
dyn
AbstractRule
>>
,
apply_end_pattern_last
:
Option
<
bool
>
,
patterns
:
ICompilePatternsResult
,
)
->
BeginEndRule
{
BeginEndRule
{
rule
:
Rule
{
_
type
:
String
::
from
(
"BeginEndRule"
),
_
location
:
location
,
id
,
_
name
:
name
,
_
content_name
:
content_name
,
},
_
begin
:
RegExpSource
::
new
(
begin
.clone
(),
id
.clone
()),
begin_captures
,
_
end
:
RegExpSource
::
new
(
_
end
.clone
(),
id
.clone
()),
end_captures
,
apply_end_pattern_last
,
has_missing_patterns
:
patterns
.clone
()
.has_missing_patterns
,
patterns
:
patterns
.patterns
,
_
cached_compiled_patterns
:
None
,
}
}
}
impl
AbstractRule
for
BeginEndRule
{
fn
id
(
&
self
)
->
i32
{
self
.rule.id
}
fn
type_of
(
&
self
)
->
String
{
String
::
from
(
self
.rule
.clone
()
._type
)
}
fn
has_missing_pattern
(
&
self
)
->
bool
{
self
.has_missing_patterns
}
}
scie-grammar/src/rule/mod.rs
浏览文件 @
f1980b93
pub
mod
rule_factory
;
pub
mod
rule_convert
;
pub
mod
reg_exp_source
;
pub
mod
compiled_rule
;
pub
mod
abstract_rule
;
pub
mod
begin_end_rule
;
pub
mod
compiled_rule
;
pub
use
self
::
abstract_rule
::
AbstractRule
;
pub
use
self
::
compiled_rule
::
CompiledRule
;
// pub use self::begin_end_rule::Abstract
Rule;
pub
use
self
::
begin_end_rule
::
BeginEnd
Rule
;
use
crate
::
inter
::{
ILocation
,
IRawGrammar
,
IRawRepository
};
use
reg_exp_source
::{
RegExpSource
,
RegExpSourceList
};
...
...
@@ -181,66 +182,6 @@ impl AbstractRule for MatchRule {
}
}
#[derive(Clone,
Debug,
Serialize)]
pub
struct
BeginEndRule
{
#[serde(flatten)]
pub
rule
:
Rule
,
pub
_
begin
:
RegExpSource
,
pub
begin_captures
:
Vec
<
Box
<
dyn
AbstractRule
>>
,
pub
_
end
:
RegExpSource
,
// pub endHasBackReferences: Option<bool>,
pub
end_captures
:
Vec
<
Box
<
dyn
AbstractRule
>>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
apply_end_pattern_last
:
Option
<
bool
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
_
cached_compiled_patterns
:
Option
<
RegExpSourceList
>
,
pub
patterns
:
Vec
<
i32
>
,
pub
has_missing_patterns
:
bool
,
}
impl
BeginEndRule
{
pub
fn
new
(
location
:
Option
<
ILocation
>
,
id
:
i32
,
name
:
Option
<
String
>
,
content_name
:
Option
<
String
>
,
begin
:
String
,
begin_captures
:
Vec
<
Box
<
dyn
AbstractRule
>>
,
_
end
:
String
,
end_captures
:
Vec
<
Box
<
dyn
AbstractRule
>>
,
apply_end_pattern_last
:
Option
<
bool
>
,
patterns
:
ICompilePatternsResult
,
)
->
BeginEndRule
{
BeginEndRule
{
rule
:
Rule
{
_
type
:
String
::
from
(
"BeginEndRule"
),
_
location
:
location
,
id
,
_
name
:
name
,
_
content_name
:
content_name
,
},
_
begin
:
RegExpSource
::
new
(
begin
.clone
(),
id
.clone
()),
begin_captures
,
_
end
:
RegExpSource
::
new
(
_
end
.clone
(),
id
.clone
()),
end_captures
,
apply_end_pattern_last
,
has_missing_patterns
:
patterns
.clone
()
.has_missing_patterns
,
patterns
:
patterns
.patterns
,
_
cached_compiled_patterns
:
None
,
}
}
}
impl
AbstractRule
for
BeginEndRule
{
fn
id
(
&
self
)
->
i32
{
self
.rule.id
}
fn
type_of
(
&
self
)
->
String
{
String
::
from
(
self
.rule
.clone
()
._type
)
}
fn
has_missing_pattern
(
&
self
)
->
bool
{
self
.has_missing_patterns
}
}
#[derive(Clone,
Debug,
Serialize)]
pub
struct
CaptureRule
{
pub
rule
:
Rule
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录