dyon icon indicating copy to clipboard operation
dyon copied to clipboard

Meta parsing design

Open bvssvni opened this issue 8 years ago • 0 comments

Notice: This is still under work!

Dyon uses the Piston-Meta library for meta parsing.

List of included functions for meta parsing

  • fn load_meta_file(meta_file: str, file: str) -> res[[]]
  • fn load_meta_url(meta_file: str, url: str) -> res[[]]

What is meta parsing?

Meta parsing is like having a language like regular expressions, but for whole text documents. The rules describes the syntax in a short and concise form.

When a document is read through meta parsing, it gets transformed into a list of commands describing a tree structure called "meta data". This structure consists of these commands:

  • start node (name)
  • end node (name)
  • bool (name, value)
  • f64 (name, value)
  • string (name, value)

Meta parsing happens in two steps:

  1. Convert text document into meta data
  2. Convert meta data into application data

When there is a syntax error in the text document, the meta parser reports this with a nice error message.

Example: JSON

This meta format validates JSON documents:

0 , = [.w? "," .w?]
1 object = ["{" .w? .s?(, [.t? .w? ":" .w? value .w?]) "}"]
2 array = ["[" .w? .s?(, value) .w? "]"]
3 value = [{
    .t?
    .$
    object
    array
    "true"
    "false"
    "null"
}]
4 document = [.w? value .w?]

Why use meta parsing?

Meta parsing has the following benefits:

  • easy to design your own custom human readable text formats by need
  • easy to verify document structure of a JSON document
  • can read a wide variety of existing text documents that uses JSON building blocks

Dyon's syntax is using meta parsing!

Dyon uses meta parsing on its own syntax. Dyon's meta syntax.

You can use this to parse Dyon code, generate documentation, do some analysis etc.

bvssvni avatar May 16 '16 12:05 bvssvni