Commit aea1ab6 1 parent ed0b963 commit aea1ab6 Copy full SHA for aea1ab6
File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change
1
+ 有用的技巧:
2
+
3
+ - vscode 中没有在[ 文档里] ( https://code.visualstudio.com/api/references/commands ) 列出来的 command,例如 补全时的触发 signature help。以及通过检查快捷键绑定的方式找到的 command
4
+
5
+ - 语言服务器应当返回和客户端无关的信息。如果想针对某个编辑器做特定的行为要怎么做?客户端在收到服务器返回后,可以二次加工,再真正渲染到代码编辑器里。例如 vscode-languageclinet 就有个 [ middleware] ( https://github.com/microsoft/vscode-languageserver-node/blob/main/client/src/common/client.ts#L364 ) 。Go 的 vscode 插件就是通过劫持 gopls 的信息,做一些针对 vscode 的处理后,才真正返回。例如代码补全 code completion 中,选择函数或者方法后,触发 vscode 特有的 command,来[ 唤起 signature help] ( https://github.com/golang/vscode-go/blob/master/extension/src/language/goLanguageServer.ts#L714 )
6
+
7
+ - 卸载插件时可以执行一段脚本,来做清理工作,官方文档中藏的很深:https://code.visualstudio.com/updates/v1_21#_extension-uninstall-hook
Original file line number Diff line number Diff line change @@ -66,6 +66,8 @@ indexTypeClauseOpt:
66
66
67
67
在大部分场景下,可选值 ` ? ` 性能比分支 ` | ` 更好。例如,假设一门语言的 if 语句的条件可以带括号,也可以不带
68
68
69
+ <!-- TODO: 例子不太好,括号应该成对出现 -->
70
+
69
71
``` antlr
70
72
ifStatement:
71
73
'if' '(' expression ')'
@@ -79,9 +81,9 @@ ifStatement:
79
81
'if' ('(')? expression (')')?
80
82
```
81
83
82
- ### 谓词
84
+ ### 语义谓词(semantic predicates)
83
85
84
- 谓词是值 .g4 文件中用 ` {} ` 花括号包括起来的部分。这些部分需要 antlr 生成目标代码后自行编写函数实现逻辑。
86
+ 语义谓词是指 .g4 文件中用 ` {} ` 花括号包括起来的部分。这些部分需要 antlr 生成目标代码后自行编写函数实现逻辑。
85
87
语法分析文件中(parser.g4)谓词放到最前
86
88
词法分析文件中(lexer.g4)谓词放到最后
87
89
@@ -100,3 +102,4 @@ antlr 是个比较活跃的项目,更新还是比较频繁的。
100
102
101
103
https://tomassetti.me/improving-the-performance-of-an-antlr-parser/
102
104
https://groups.google.com/g/antlr-discussion/c/PpgPQU5jA3Q/m/P4K6Y0BXBQAJ
105
+ https://github.com/antlr/antlr4/issues/4613
You can’t perform that action at this time.
0 commit comments