vscode工具,需要安装所有推荐关于.y文件的插件;
包括:
- bison;
- flex;
- yacc;
例如:
文件名为:test.y
package sqlparser
%type <item>
select_statement
%type <statement>
command
%start any_command
%%
any_command:
command opt_semicolon
{
setParseTree(yylex, $1)
}
command:
select_statement
{
$$ = $1.(ast.SelectStatement)
}
opt_semicolon:
{}
| ';'
{}
注解:此段代码只用于演示,不能编译;
在vscode的右下角,如果显示:bison,点击修改:
最后的结果为:
在vscode下,F12可以快速跳转;