Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

spencercjh/gitconfig-antlr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gitconfig-antlr

A demo to show how to use ANTLR to parse gitconfig file.

Usage

Generate ANTLR Java files,

./mvnw clean package

then run the tests to verify the result.

./mvnw test

Please pay attention to the src/test/java/org/example/GitConfigListenerImplTest.java for assert details.

Tech Details

Referring INF file grammar and git configuration docs, I complete GitConfig.g4.

Then I use ANTLR maven plugin to generate Java files, and implement GitConfigListenerImpl to parse the gitconfig file.

Unlike INF files, I need to support the following gitconfig dialects:

  • subsection header: [remote "origin"]
  • deprecated subsection header: [remote.origin]
  • colon : in the section value: url = https://example.com/git (Maybe INF file spec is really supported it, but I didn’t see it in the INF file grammar mentioned above)

Welcome to add more gitconfig syntax I was missing through Github issue, and I will update it ASAP.

About

A demo to show how to use ANTLR to parse gitconfig file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published