Is there a BNF mode for Emacs?

前端 未结 4 794
忘掉有多难
忘掉有多难 2021-01-02 13:01

I have to edit lots of grammar files in .bnf format. Is there a mode for this in Emacs?

I\'ve looked at CEDET\'s semantic package, and it seems that it USED to have

4条回答
  •  走了就别回头了
    2021-01-02 13:53

    To be more readable and findable as an answer, jmmcd answered his own question with the following. You can find more in the emacs Help > elisp > 23.2.6 Generic Modes.


    "I put this in my .emacs and it seems to work."

    (define-generic-mode 'bnf-mode 
      '("#") 
      nil 
      '(("^<.*?>" . 'font-lock-variable-name-face) 
        ("<.*?>" . 'font-lock-keyword-face) 
        ("::=" . 'font-lock-warning-face) 
        ("\|" . 'font-lock-warning-face))
      '("\\.bnf\\.pybnf\\'") 
      nil 
      "Major mode for BNF highlighting.")
    

提交回复
热议问题