【问题标题】:Creating code snippets in Visual Studio Code using EBNF使用 EBNF 在 Visual Studio Code 中创建代码片段
【发布时间】:2018-06-07 10:03:37
【问题描述】:

Here 他们说我们可以使用 EBNF 生成代码,但我不明白如何,它似乎只接受 JSON。有谁知道怎么做?
提前谢谢你。

【问题讨论】:

    标签: visual-studio-code code-snippets ebnf


    【解决方案1】:

    您提到的链接,不是说我们可以使用 EBNF 生成新的 sn-p。

    他们记录了类似的内容:

    以下是 sn-ps 的 EBNF(扩展巴科斯-瑙尔形式)

    然后.. 他们为 sn-ps 提供了 EBNF。

    any         ::= tabstop | placeholder | choice | variable | text
    tabstop     ::= '$' int | '${' int '}'
    placeholder ::= '${' int ':' any '}'
    choice      ::= '${' int '|' text (',' text)* '|}'
    variable    ::= '$' var | '${' var }'
                    | '${' var ':' any '}'
                    | '${' var '/' regex '/' (format | text)+ '/' options '}'
    format      ::= '$' int | '${' int '}'
                    | '${' int ':' '/upcase' | '/downcase' | '/capitalize' '}'
                    | '${' int ':+' if '}'
                    | '${' int ':?' if ':' else '}'
                    | '${' int ':-' else '}' | '${' int ':' else '}'
    regex       ::= JavaScript Regular Expression value (ctor-string)
    options     ::= JavaScript Regular Expression option (ctor-options)
    var         ::= [_a-zA-Z] [_a-zA-Z0-9]*
    int         ::= [0-9]+
    text        ::= .*
    

    它告诉 Snippet 接受的可能组合和关键字是什么。通过查看 EBNF,我可以说它确实是 JSON 格式。目前sn-p的创作仅限于此。我们无法在当前版本(版本 1.24)中生成高级 sn-p。

    请通读文档以获取有关如何使用给定变量和替换逻辑制作新 sn-p 的更多信息。谢谢。

    【讨论】:

      猜你喜欢
      • 2019-02-03
      • 1970-01-01
      • 2019-04-15
      • 2021-11-11
      • 1970-01-01
      • 2017-05-23
      • 1970-01-01
      • 2010-10-19
      • 2020-09-07
      相关资源
      最近更新 更多