如何在SMIE中定义多个字符括号

时间:2015-04-29 12:15:45

标签: emacs indentation parentheses auto-indent smie

我复制了关于SMIE的GNU手册中的代码。 beginend的缩进效果很好。

(defvar sample-smie-grammar
  (smie-prec2->grammar
   (smie-bnf->prec2
    '((id)
      (inst ("begin" insts "end")
            ("if" exp "then" inst "else" inst)
            (id ":=" exp)
            (exp))
      (insts (insts ";" insts) (inst))
      (exp (exp "+" exp)
           (exp "*" exp)
           ("(" exps ")"))
      (exps (exps "," exps) (exp)))
    '((assoc ";"))
    '((assoc ","))
    '((assoc "+") (assoc "*")))))

但是当我尝试添加class / endclassmodule / endmodule时,新添加的对根本不会缩进。当我启用show-paren-mode时。它们不会突出显示为beginend

(defvar sample-smie-grammar
  (smie-prec2->grammar
   (smie-bnf->prec2
    '((id)
      (inst ("begin" insts "end")
            ("module" insts "endmodule")
            ("class" insts "endclass")
            ("if" exp "then" inst "else" inst)
            (id ":=" exp)
            (exp))
      (insts (insts ";" insts) (inst))
      (exp (exp "+" exp)
           (exp "*" exp)
           ("(" exps ")"))
      (exps (exps "," exps) (exp)))
    '((assoc ";"))
    '((assoc ","))
    '((assoc "+") (assoc "*")))))

0 个答案:

没有答案