Skip to content

Inital pass at a convert .properties to abstract syntax token (AST). It works, but isn't as pretty as I usually prefer. Still fun :)

Notifications You must be signed in to change notification settings

matthewbub/dot-properties-ast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Properties AST

An abstract syntax tree generator for those .properties files

.properties logic

I can't think of much beyond this.

  • Keys and values are always seperated by an =
  • Comments always lead with a #
  • Values can be single line or multi line
    • multi line values always trail with a \

Setup

I'm using deno, there's no dependieces so you can run whatever just gotta handle the ts however you want srry

deno run --allow-read=./test.properties index.ts

Example

Given this .properties file

# This is a comment
greeting = Hello, world!
farewell = Goodbye!
multiline = This is a long value \
            that spans multiple lines.

Recieve an AST

{
  "type": "PropertiesFile",
  "body": [
    {
      "type": "Comment",
      "value": "This is a comment"
    },
    {
      "type": "Property",
      "key": "greeting",
      "value": "Hello, world!"
    },
    {
      "type": "Property",
      "key": "farewell",
      "value": "Goodbye!"
    },
    {
      "type": "Property",
      "key": "multiline",
      "value": ["This is a long value ", "that spans multiple lines."]
    }
  ]
}

About

Inital pass at a convert .properties to abstract syntax token (AST). It works, but isn't as pretty as I usually prefer. Still fun :)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published