Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema/dmt: first pass at a parser #253

Merged
merged 1 commit into from
Sep 28, 2021
Merged

schema/dmt: first pass at a parser #253

merged 1 commit into from
Sep 28, 2021

Commits on Sep 28, 2021

  1. schema/dsl: first pass at a schema parser

    Plenty of TODOs scattered around,
    but it's complete enough that it can parse the schema-schema.
    
    We include ParseBytes for the upcoming go:embed usecases,
    and ParseFile for the common non-embed usecase.
    
    The parser is largely inspired by github.com/ipld/go-ipld-schema/parser,
    with some notable differences.
    
    First, it follows a top-down recursive descent design,
    with methods such as "consume token" and "peek token".
    This also enables us to provide consistently good errors.
    
    Second, it's not line-based, using bufio.Reader instead.
    This keeps the code simpler, as we aren't forced to tokenize by line,
    and we also avoid potential mistakes when slicing tokens by hand.
    
    Third, it parses straight into the new bindnode DMT types,
    which allows for Parse and Compile to be chained together.
    
    Note that the parser lives in schema/dsl,
    which sits on top of schema/dmt with the Go types and schema definition.
    This is a nice separation at a conceptual level,
    and also means one can use the DMT without pulling in the DSL parser.
    
    Finally, we bump the ipld submodule to get Eric's schema-schema changes
    that mean implicit scalar values are no longer quoted in the DSL.
    
    Updates #188.
    mvdan committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    4f65c94 View commit details
    Browse the repository at this point in the history