Skip to content

Parser accepts key paths #83

Open
lebotlan wants to merge 1 commit into
ocaml-toml:masterfrom
lebotlan:accept-key-paths
Open

Parser accepts key paths #83
lebotlan wants to merge 1 commit into
ocaml-toml:masterfrom
lebotlan:accept-key-paths

Conversation

@lebotlan

@lebotlan lebotlan commented Jun 18, 2026

Copy link
Copy Markdown

What

The parser now accepts key paths (instead of single keys), e.g. k1.k2.k3 = 100

Why

It is part of the spec! (and can be occasionally useful)

How

The only modified code is in the parser: menhir_parser.mly

  • grammar is extended to accept key paths
  • functions that create tables now expect key paths instead of single keys. The path is split into a list of keys and the last key. The list of keys leads to the hashtable in which the last key will be inserted.

Testing

I added a couple of tests, in particular path_example1.toml and path_example2.toml which are expected to give the same TOML tree, although the input syntax is different.

Besides

I have replaced most of the $1 $2 in the parser by named variables, to avoid position-dependent parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant