Created
June 28, 2024 13:24
-
-
Save ftaiolivista/752d04e0ad939461c1fe19da26f05a51 to your computer and use it in GitHub Desktop.
PeggyJS ini file grammar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
function makeObject(entries) { | |
const result = {}; | |
for (const [key, value] of entries) { | |
result[key] = value; | |
} | |
return result; | |
} | |
} | |
IniFile | |
= _ sections:Section* _ { return makeObject(sections); } | |
Section | |
= "[" _ name:Identifier _ "]" _ entries:Entry* _ { return [name, makeObject(entries)]; } | |
Entry | |
= key:Identifier _ "=" _ value:Value _ { return [key, value]; } | |
Identifier | |
= chars:[a-zA-Z0-9_]+ { return chars.join(''); } | |
Value | |
= chars:[^\n#]+ { return chars.join('').trim(); } | |
_ | |
= (Whitespace / Comment)* | |
Whitespace | |
= [ \t\r\n]+ | |
Comment | |
= [#|;] [^\n]* | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment