Visual studio code 使用EBNF在Visual Studio代码中创建代码段
他们说我们可以使用EBNF生成代码,但我不明白怎么做,它似乎只接受JSON。有人知道怎么做吗?Visual studio code 使用EBNF在Visual Studio代码中创建代码段,visual-studio-code,code-snippets,ebnf,Visual Studio Code,Code Snippets,Ebnf,他们说我们可以使用EBNF生成代码,但我不明白怎么做,它似乎只接受JSON。有人知道怎么做吗? 提前谢谢。您提到的链接并没有说我们可以使用EBNF生成新的代码片段 他们记录了如下内容: 下面是代码片段的EBNF(扩展的Backus Naur表单) 然后。。他们为代码片段提供了EBNF any ::= tabstop | placeholder | choice | variable | text tabstop ::= '$' int | '${' int '}' pla
提前谢谢。您提到的链接并没有说我们可以使用EBNF生成新的代码片段 他们记录了如下内容: 下面是代码片段的EBNF(扩展的Backus Naur表单) 然后。。他们为代码片段提供了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 ::= .*
它说明了代码段可以接受的可能组合和关键字。通过查看EBNF,我可以说它确实是JSON格式。目前代码段的创建仅限于此。我们无法在当前版本(1.24版)中生成高级代码段
请通读该文档,以获得有关如何使用给定变量和替换逻辑生成新代码段的更多信息。谢谢