A parser for the Jevko syntax for Nim
- Nim 100%
|
|
||
|---|---|---|
| src | Removed unnecessary Option[] wrapping | |
| jevko.nimble | update descriptions | |
| LICENSE | initial commit | |
| README.md | update descriptions | |
Jevko parser for Nim
Jevko has no semantics (unlike JSON or XML) so the structure is a raw tree with a variable amount of leaves. That means that the interpretation of the underlying data is concern of the program, not the parser.
Any contributions that make the code less ugly and faster are welcome.
This parser assumes that the stream is UTF-8 encoded.
Installation
nimble install https://codeberg.org/torupediron/jevko.nim
Usage
# Dump the parsed document tree
import jevko, std/streams
let doc = """
first name [John]
last name [Smith]
is alive [true]
age [27]
address [
street address [21 2nd Street]
city [New York]
state [NY]
postal code [10021-3100]
]
phone numbers [
[
type [home]
number [212 555-1234]
]
[
type [office]
number [646 555-4567]
]
]
children [seq]
spouse [nil]
"""
let docStream = newStringStream(doc)
var jevkoCtx = jevkoNew(docStream)
let jevkoTree = jevkoCtx.jevkoParse()
jevkoTree.dumpJevkoRec()
docStream.close()