antlr / antlr/antlr4

Making Parse Tree Serializable

Open
#233 22 comments 0 reactions 0 assignees View on GitHub
type:feature
Dominant language
Java
Stars
19k
Forks
3.5k
PR merge metrics
No merged PRs in 30d

Description

Is it possible to save up the parse tree generated by ANTLR4? For example, by making ParserRuleContext serializable.

I'd like to use ANTLR4 to parse the source files in my project. My project is quite large and contains hundreds of source files. Usually, I need to walk through the parse trees of several source files to get my desire info. It takes a while to parse even just 1 source file. So, it would be impractical to parse all the source files again every time I start my tool in order to get 1 piece of information (e.g. callers of a function). It would be nice if I can just parse once and save the parser output into the hard disk.

Another scenario is say I need to parse a cpp source file together and its related header files. e.g. to retrieve the function declarations from the header files for each function definition in the cpp file. But each header file is also used by another cpp file so it means its parse tree would be needed again when we examine the parse tree of a second cpp file.

Contributor guide

Open the contributing guide

Research direction

Start by examining ParserRuleContext and the parse-tree structures involved in ANTLR4 parsing. Define how a tree could be saved and restored for reuse across tool runs and shared source/header processing, then identify the compatibility and runtime requirements before proposing an implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.