1
1
Fork
You've already forked jevko.nim
1
A parser for the Jevko syntax for Nim
  • Nim 100%
Find a file
2023年01月12日 21:43:42 -03:00
src Removed unnecessary Option[] wrapping 2023年01月12日 21:43:42 -03:00
jevko.nimble update descriptions 2022年12月07日 22:41:57 -03:00
LICENSE initial commit 2022年11月30日 13:16:41 -03:00
README.md update descriptions 2022年12月07日 22:41:57 -03:00

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()