Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/csgn/pipo
Config Parser
https://github.com/csgn/pipo
config-parser parser
Last synced: about 9 hours ago
JSON representation
Config Parser
- Host: GitHub
- URL: https://github.com/csgn/pipo
- Owner: csgn
- License: mit
- Created: 2025-02-04T20:15:58.000Z (4 days ago)
- Default Branch: main
- Last Pushed: 2025-02-05T14:03:24.000Z (3 days ago)
- Last Synced: 2025-02-05T15:22:36.725Z (3 days ago)
- Topics: config-parser, parser
- Language: Scala
- Homepage:
- Size: 136 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pipo
# Grammar
```ebnf
grammar = { field } ;
field = namespace , newline, variables ;
namespace = "[" , lit , "]", newline ;
variables = { variable } ;
variable = key, '=', value, newline
key = lit ;
value = lit ;
lit = letter , { letter | digit | "_" } ;character = letter | digit | symbol | "_" ;
letter = "A" | "B" | "C" | "D" | "E" | "F" | "G"
| "H" | "I" | "J" | "K" | "L" | "M" | "N"
| "O" | "P" | "Q" | "R" | "S" | "T" | "U"
| "V" | "W" | "X" | "Y" | "Z" | "a" | "b"
| "c" | "d" | "e" | "f" | "g" | "h" | "i"
| "j" | "k" | "l" | "m" | "n" | "o" | "p"
| "q" | "r" | "s" | "t" | "u" | "v" | "w"
| "x" | "y" | "z" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;symbol = "[" | "]" | "{" | "}" | "(" | ")" | "<" | ">"
| "'" | '"' | "=" | "|" | "." | "," | ";" ;newline = "\n" ;
```# Example
```
# Source
[namespace_1]
key1=value1
key2=value2# AST
PipoGrammar(
List(
PipoField(
PipoNamespace(
PipoLit(namespace_1),
List(
PipoVariable(
PipoKey(
PipoLit(key1)
),
PipoValue(
PipoLit(value1)
)
),
PipoVariable(
PipoKey(
PipoLit(key2)
),
PipoValue(
PipoLit(value2)
)
),
PipoVariable(
PipoKey(
PipoLit(key3)
),
PipoValue(
PipoLit(value3)
)
)
)
)
)
)
)
```# Usage
```scala
import pipo.core._val input = """[namespace_1]
|key1=value1
|key2=value2
|""".stripMarginval parser = Pipo()
val Some((_, ast)) = parser.run(input)
```# Run tests
```sh
$ sbt test
```