https://github.com/poppa/pike-toml
TOML parser for Pike
https://github.com/poppa/pike-toml
lexer parser pike tokenizer toml toml-parser
Last synced: 6 months ago
JSON representation
TOML parser for Pike
- Host: GitHub
- URL: https://github.com/poppa/pike-toml
- Owner: poppa
- License: mit
- Created: 2018-03-27T19:35:20.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-11-10T19:01:09.000Z (over 5 years ago)
- Last Synced: 2025-04-08T04:44:46.684Z (over 1 year ago)
- Topics: lexer, parser, pike, tokenizer, toml, toml-parser
- Language: Pike
- Homepage:
- Size: 160 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TOML parser for [Pike](https://pike.lysator.liu.se)
A [TOML](https://github.com/toml-lang/toml) parser trying to comply to the
v0.5 spec.
## Examle
```toml
# config.toml
name = "Global Server Config"
support = ["email@support.com", "055-5555"]
last-updated = 2020-11-10T12:13:14+01:00
[server.dev]
host = "dev.host.com"
port = 1337
tls = false
os.platform = "CentOS"
os.version = "6.5"
[server.prod]
host = "host.com"
port = 80
tls = true
# This is the same as in `server.dev`
os = { platform = "CentOS", version = "7.6" }
[[regex]]
dot = '\.'
[[regex]]
dot = '\.\.'
```
Pass this file to `Parser.TOML.parse_file()` like so:
```pike
mapping res = Parser.TOML.parse_file("config.toml");
```
and expect `res` to contain the following content:
```pike
([
"last-updated": Second(Tue 10 Nov 2020 12:13:14 UTC+1),
"name": "Global Server Config",
"regex": ({
([ "dot": "\\." ]),
([ "dot": "\\.\\." ])
}),
"server": ([
"dev": ([
"host": "dev.host.com",
"os": ([
"platform": "CentOS",
"version": "6.5"
]),
"port": 1337,
"tls": Val.false
]),
"prod": ([
"host": "host.com",
"os": ([
"platform": "CentOS",
"version": "7.6"
]),
"port": 80,
"tls": Val.true
])
]),
"support": ({
"email@support.com",
"055-5555"
})
])
```