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

Latest commit

 

History

History
37 lines (24 loc) · 1.18 KB

README.md

File metadata and controls

37 lines (24 loc) · 1.18 KB

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.