refactor: try to fix last issues

上级 f0d9a11f
......@@ -155,7 +155,6 @@ impl Grammar {
let stack = &mut next_state.clone().unwrap();
let vec = line_tokens.get_result(stack, line_length as i32);
TokenizeResult {
// line_length,
tokens: vec,
rule_stack: Box::new(next_state.clone()),
}
......@@ -764,11 +763,11 @@ hellomake: $(OBJ)
for token in result.tokens {
let start = token.start_index.clone() as usize;
let end = token.end_index.clone() as usize;
// let new_line: String = String::from(line)
// .chars()
// .skip(start)
// .take(end - start)
// .collect();
let new_line: String = String::from(line)
.chars()
.skip(start)
.take(end - start)
.collect();
let token_str: String = token.scopes.join(", ");
println!(
" - token from {:?} to {:?} ({:?}) with scopes {:?}",
......
......@@ -64,11 +64,12 @@ impl LineTokens {
self._tokens.pop();
}
let tokens_len = self._tokens.len();
if tokens_len == 0 {
if self._tokens.len() == 0 {
self._last_token_end_index = -1;
self.produce(stack, line_length);
self._tokens[tokens_len - 1].start_index = 0;
let new_tokens_len = self._tokens.len();
self._tokens[new_tokens_len - 1].start_index = 0;
}
self._tokens.clone()
......
......@@ -167,7 +167,7 @@ impl RuleFactory {
if rule.has_missing_pattern() && rule.patterns_length() == 0 {
match rule.get_rule_instance() {
RuleEnum::BeginEndRule(r) => {
println!("{:?}", r);
println!("missing patterns -> {:?}", r);
}
_ => {}
}
......
......@@ -21,12 +21,13 @@ const registry = new vsctm.Registry({
createOnigString: (str) => new oniguruma.OnigString(str)
}),
loadGrammar: (scopeName) => {
return readFile('./syntaxes/json/c.json').then(data => vsctm.parseRawGrammar(data.toString(), "c.json"))
return readFile('./syntaxes/json/makefile.json').then(data => vsctm.parseRawGrammar(data.toString(), "c.json"))
}
});
registry.loadGrammar('source.c').then(grammar => {
const text = `#include <stdio.h>`.split("\n");
registry.loadGrammar('source.makefile').then(grammar => {
const text = `hellomake: $(OBJ)
\t$(CC) -o $@ $^ $(CFLAGS)`.split("\n");
let ruleStack = vsctm.INITIAL;
for (let i = 0; i < text.length; i++) {
const line = text[i];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册