Tomlin: a TOML parser in Janet #608
                  
                    
                      pyrmont
                    
                  
                
                  started this conversation in
                Show and tell
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've recently completed Tomlin, a TOML parser in Janet. Tomlin converts a TOML-formatted string into a Janet data structure. Details of the conversion are in Tomlin's api.md.
One of the interesting things was seeing how relatively easy it was to convert the ABNF grammar for TOML to a parser expression grammar for Tomlin. So these rules:
became these rules:
TOML is an intentionally simple language but I nevertheless think it's a good example of the power of PEGs.
A lot of the initial development time was actually spent writing conformance tests. The most popular repository of tests (iarna/toml-spec-tests) only includes output tests in YAML. Since (a) Janet doesn't have a YAML parser and (b) the in-progress official TOML conformance repository (toml-lang/compliance) proposes to use JSON, I wrote output tests encoded in the proposed encoding. These specs are not included in Tomlin but are available in toml-specs.
Beta Was this translation helpful? Give feedback.
All reactions