像许多人一样,我创建了一个点文件存储库,并尝试将非私有的位提取到各自的点文件中。我通常会.whatever.local加载一个文件(如果存在),该文件可能包含我不想签入存储库的信息。Rubygems 使用~/.gemrc文件,但我看不到一种将私人信息从中提取到单独文件中的方法。有谁知道如何做到这一点?
我特别想要sources.gemrc 文件的外部列表。
我的vimrc中有以下映射:
noremap <leader>b :buffers<CR>:buffer<Space>
Run Code Online (Sandbox Code Playgroud)
不幸的是,显示缓冲列表大约有半秒到二秒的延迟.这有明显的原因吗?如果没有我怎么调试呢?
我是PEG解析的新手,并试图编写一个简单的解析器来解析出一个像"term1 OR term2 anotherterm"这样的表达式,理想情况下是一个看起来像这样的AST:
OR
-----------|---------
| |
"term1" "term2 anotherterm"
Run Code Online (Sandbox Code Playgroud)
我目前正在使用Grappa(https://github.com/fge/grappa)但它甚至不匹配更基本的表达式"term1 OR term2".这就是我所拥有的:
package grappa;
import com.github.fge.grappa.annotations.Label;
import com.github.fge.grappa.parsers.BaseParser;
import com.github.fge.grappa.rules.Rule;
public class ExprParser extends BaseParser<Object> {
@Label("expr")
Rule expr() {
return sequence(terms(), wsp(), string("OR"), wsp(), terms(), push(match()));
}
@Label("terms")
Rule terms() {
return sequence(whiteSpaces(),
join(term()).using(wsp()).min(0),
whiteSpaces());
}
@Label("term")
Rule term() {
return sequence(oneOrMore(character()), push(match()));
}
Rule character() {
return anyOf(
"0123456789" +
"abcdefghijklmnopqrstuvwxyz" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"-_");
}
@Label("whiteSpaces")
Rule whiteSpaces() {
return join(zeroOrMore(wsp())).using(sequence(optional(cr()), lf())).min(0);
} …Run Code Online (Sandbox Code Playgroud) 通过在二叉搜索树上执行递归和非递归前序遍历,我得不到相同的结果
递归方法
public static void preorder(TreeNode root) {
if (root == null)
return;
else {
System.out.print(root);
inorder(root.getLeftPtr());
inorder(root.getRightPtr());
}
}
Run Code Online (Sandbox Code Playgroud)
非递归方法
public static void preorder2(TreeNode root){
if(root==null)return;
Stack<TreeNode> stack=new Stack<TreeNode>();
while(true){
while(root!=null){
//process current Node
System.out.print(root);
stack.push(root);
root=root.getLeftPtr();
}
if(stack.isEmpty())break;
root=stack.pop();
root=root.getRightPtr();
}
}
Run Code Online (Sandbox Code Playgroud)
结果
recursive method-> 10-> 5-> 6-> 8-> 12-> 15-> 20
non recursive method-> 10-> 6-> 5-> 8-> 15-> 12-> 20
Run Code Online (Sandbox Code Playgroud)