Is it feasible to use Antlr for source code completion?

后端 未结 2 865

I don\'t know, if this question is valid since i\'m not very familiar with source code parsing. My goal is to write a source code completion function for one existing progra

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-01 03:53

    Xtext uses ANTLR3 and has good autocomplete facilities. The problem is, it generates a seperate parser (again using antlr3) for autocomplete processing which is derived from AbstractInternalContentAssistParser. This multi-thousand line code part shows that the error recovery of ANTLR3 alone found to be insufficient by the xtext team.

    Meanwhile ANTLR4 has a function parser.getExpectedTokensWithinCurrentRule() which lists possible token types for given position. It works when used in a ParseTreeListener. Remaining is semantics, scoping etc which is out of ANTLRs scope.

提交回复
热议问题