Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
scie
提交
f385bf00
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 搜索 >>
未验证
提交
f385bf00
编写于
8月 23, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: init stack elemetn struct
上级
a4e36f70
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
16 deletion
+40
-16
scie-grammar/src/grammar/grammar/mod.rs
scie-grammar/src/grammar/grammar/mod.rs
+17
-16
scie-grammar/src/grammar/grammar/scope_list_element.rs
scie-grammar/src/grammar/grammar/scope_list_element.rs
+5
-0
scie-grammar/src/grammar/grammar/stack_element.rs
scie-grammar/src/grammar/grammar/stack_element.rs
+18
-0
未找到文件。
scie-grammar/src/grammar/grammar/mod.rs
浏览文件 @
f385bf00
pub
mod
stack_element
;
pub
mod
scope_list_element
;
use
crate
::
inter
::{
IRawGrammar
,
IRawRepository
,
ILocation
,
IRawRule
,
IRawRepositoryMap
};
use
crate
::
rule
::{
RuleFactory
,
IRuleFactoryHelper
,
IGrammarRegistry
,
IRuleRegistry
,
Rule
,
AbstractRule
,
BeginEndRule
};
use
onig
::
*
;
use
std
::
collections
::
HashMap
;
use
std
::
borrow
::
Borrow
;
pub
struct
StackElement
{}
use
crate
::
grammar
::
grammar
::
stack_element
::
StackElement
;
pub
struct
IToken
{
pub
start_index
:
i32
,
...
...
@@ -38,14 +40,10 @@ pub trait IGrammar {
fn
tokenize_line2
(
line_text
:
String
,
prev_state
:
Option
<
StackElement
>
)
->
ITokenizeLineResult2
;
}
pub
trait
Matcher
{
}
pub
trait
Matcher
{}
#[derive(Debug,
Clone)]
pub
struct
TokenTypeMatcher
{
}
pub
struct
TokenTypeMatcher
{}
#[derive(Debug,
Clone)]
pub
struct
Grammar
{
...
...
@@ -86,7 +84,7 @@ impl Grammar {
grammar
:
_
grammar
,
root_id
:
-
1
,
rule_id2desc
:
Default
::
default
(),
_
token_type_matchers
:
vec!
[]
_
token_type_matchers
:
vec!
[]
,
}
}
// todo: refactor to callback ??
...
...
@@ -114,26 +112,29 @@ impl Grammar {
let
mut
is_first_line
:
bool
=
false
;
if
let
None
=
prev_state
{
is_first_line
=
true
}
else
{
}
}
else
{}
let
lineText
=
format!
(
"{:?}
\n
"
,
line_text
);
let
onigLineText
=
self
.create_onig_string
(
lineText
);
self
.tokenize
String
(
onigLineText
.parse
()
.unwrap
(),
is_first_line
,
0
)
self
.tokenize
_string
(
onigLineText
.parse
()
.unwrap
(),
is_first_line
,
0
,
true
)
}
pub
fn
tokenize
String
(
&
mut
self
,
line_text
:
String
,
is_first_line
:
bool
,
line_pos
:
i32
)
{
pub
fn
tokenize
_string
(
&
mut
self
,
line_text
:
String
,
is_first_line
:
bool
,
line_pos
:
i32
,
check_while_conditions
:
bool
)
{
let
line_length
=
line_text
.len
();
let
mut
stop
=
false
;
let
mut
anchorPosition
=
-
1
;
if
check_while_conditions
{
self
.check_while_conditions
(
line_text
.clone
(),
is_first_line
,
line_pos
)
}
self
.match_rule_or_injections
(
line_text
,
is_first_line
,
line_pos
,
anchorPosition
);
}
pub
fn
match_rule_or_injections
(
&
mut
self
,
line_text
:
String
,
is_first_line
:
bool
,
line_pos
:
i32
,
anchor_position
:
i32
)
{
pub
fn
check_while_conditions
(
&
mut
self
,
line_text
:
String
,
is_first_line
:
bool
,
line_pos
:
i32
)
{}
}
pub
fn
match_rule_or_injections
(
&
mut
self
,
line_text
:
String
,
is_first_line
:
bool
,
line_pos
:
i32
,
anchor_position
:
i32
)
{
}
pub
fn
tokenize_line
(
&
mut
self
,
line_text
:
String
,
prev_state
:
Option
<
StackElement
>
)
{
self
.tokenize
(
line_text
,
prev_state
,
false
)
...
...
scie-grammar/src/grammar/grammar/scope_list_element.rs
0 → 100644
浏览文件 @
f385bf00
pub
struct
ScopeListElement
{
pub
parent
:
Option
<
Box
<
ScopeListElement
>>
,
pub
scope
:
String
,
pub
metadata
:
i32
}
\ No newline at end of file
scie-grammar/src/grammar/grammar/stack_element.rs
0 → 100644
浏览文件 @
f385bf00
use
crate
::
grammar
::
grammar
::
scope_list_element
::
ScopeListElement
;
pub
struct
StackElement
{
pub
parent
:
Option
<
Box
<
StackElement
>>
,
pub
depth
:
i32
,
pub
rule_id
:
i32
,
pub
enter_pos
:
i32
,
pub
anchor_pos
:
i32
,
pub
begin_rule_captured_eol
:
bool
,
pub
end_rule
:
Option
<
String
>
,
pub
name_scopes_list
:
ScopeListElement
,
pub
content_name_scopes_list
:
ScopeListElement
,
}
impl
StackElement
{
pub
fn
NULL
()
{}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录