question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Zig implementation progress/thoughts

See original GitHub issue

I’ll comment out the pointer to zig-nestedtext for now. Let me know when it is ready.

_Originally posted by @KenKundert in https://github.com/KenKundert/nestedtext/issues/20#issuecomment-787214182_

@KenKundert zig-nestedtext is looking pretty good now, I think it’s handling everything in the spec except for quotes around object keys (and the error reporting is extremely minimal). My next job will be to hook it up to your suite of testcases to iron out these remaining bits.

The main aspect of the language spec I’m questioning at this point is the fact that keys may be quoted - is there really a need to allow keys to start with - or >, or contain : or whitespace? This feels like unnecessary complexity for a language spec that strives to be simple, and indeed leads to more than two thirds of the text in the file format spec for dictionary lines:

The key must be quoted if it:

  • starts with a list-item or string-item tag,
  • contains a dict-item tag,
  • starts with a quote character, or
  • has leading or trailing spaces or tabs.

A key is quoted by delimiting it with matching single or double quote characters, which are discarded. Unlike traditional programming languages, a quoted key delimited with single quote characters may contain additional single quote characters. Similarly, a quoted key delimited with double quote characters may contain additional double quote characters. Also, backslash is not used as an escape character; backslash has no special meaning anywhere in NestedText.

A quoted key starts with the leading quote character and ends when the matching quote character is found along with a trailing colon (there may be white space between the closing quote and the colon). A key is invalid if it contains two or more instances of a quote character separated from :␣ by zero or more space characters where the quote character in one is a single quote and the quote character in another is the double quote. In this case the key cannot be quoted with either character so that the separator from the key and value can be identified unambiguously.

Here’s an example of it working (modulo spaces in object keys and object field ordering):

$./zig-cache/bin/nt-cli -f samples/employees.nt | jq
{
  "treasurer": [
    {
      "email": "fumiko.purvis@hotmail.com",
      "name": "Fumiko Purvis",
      "address": "3636 Buffalo Ave\nTopeka, Kansas 20692\n",
      "phone": "1-268-555-0280",
      "additional-roles": [
        "accounting task force"
      ]
    },
    {
      "email": "merrill.eldridge@yahoo.com",
      "name": "Merrill Eldridge",
      "phone": "1-268-555-3602"
    }
  ],
  "vice-president": {
    "email": "margaret.hodge@ku.edu",
    "name": "Margaret Hodge",
    "address": "2586 Marigold Lane\nTopeka, Kansas 20682\n",
    "phone": "1-470-555-0398",
    "additional-roles": [
      "new membership task force",
      "accounting task force"
    ]
  },
  "president": {
    "email": "KateMcD@aol.com",
    "name": "Katheryn McDaniel",
    "address": "138 Almond Street\nTopeka, Kansas 20697\n",
    "phone": {
      "cell": "1-210-555-5297",
      "home": "1-210-555-8470"
    },
    "additional-roles": [
      "board member"
    ]
  }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
KenKundertcommented, Apr 3, 2021

First, on multiline strings

> Hey now!

becomes “Hey now!”, whereas

> Hey now!
>

becomes “Hey now!\n”

0reactions
LewisGaulcommented, Apr 4, 2021

See https://github.com/KenKundert/nestedtext/issues/16#issuecomment-718904027:

All white space after a key is ignored to allow values to be lined up without affecting the keys.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Thinking about zig implementation - Google Groups
I'm looking into playing with capnp and zig (https://ziglang.org/). Zig is a relatively new language that ... Is there any progress on a...
Read more >
Assorted thoughts on zig (and rust)
It should be relatively trivial to implement specialization the same way, which has been a work in progress in rust for years and...
Read more >
Some Thoughts on Zig | Hacker News
The unique things it's attempting to do are manual memory management with handrails (not dissimilar to pascal, but maybe with a few more...
Read more >
Self Hosted Compiler Meetings · ziglang/zig Wiki - GitHub
General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software. - Self Hosted Compiler Meetings · ziglang/zig ...
Read more >
Zig seems great but it is still in its infancy. - Reddit
My thoughts are with the dev team of Bun.sh who are forced to ... Goodbye to the C++ Implementation of Zig: How we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found