Skip to content

Commit aea1ab6

Browse files
committed
update
1 parent ed0b963 commit aea1ab6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

source/_drafts/LSP4.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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

source/_posts/提高-ANTLR-parser-性能.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ indexTypeClauseOpt:
6666

6767
在大部分场景下,可选值 `?` 性能比分支 `|` 更好。例如,假设一门语言的 if 语句的条件可以带括号,也可以不带
6868

69+
<!-- TODO: 例子不太好,括号应该成对出现 -->
70+
6971
```antlr
7072
ifStatement:
7173
'if' '(' expression ')'
@@ -79,9 +81,9 @@ ifStatement:
7981
'if' ('(')? expression (')')?
8082
```
8183

82-
### 谓词
84+
### 语义谓词(semantic predicates)
8385

84-
谓词是值 .g4 文件中用 `{}` 花括号包括起来的部分。这些部分需要 antlr 生成目标代码后自行编写函数实现逻辑。
86+
语义谓词是指 .g4 文件中用 `{}` 花括号包括起来的部分。这些部分需要 antlr 生成目标代码后自行编写函数实现逻辑。
8587
语法分析文件中(parser.g4)谓词放到最前
8688
词法分析文件中(lexer.g4)谓词放到最后
8789

@@ -100,3 +102,4 @@ antlr 是个比较活跃的项目,更新还是比较频繁的。
100102

101103
https://tomassetti.me/improving-the-performance-of-an-antlr-parser/
102104
https://groups.google.com/g/antlr-discussion/c/PpgPQU5jA3Q/m/P4K6Y0BXBQAJ
105+
https://github.com/antlr/antlr4/issues/4613

0 commit comments

Comments
 (0)