Code Monkey home page Code Monkey logo

xdrgen's Introduction

XDR Schema Compiler

xdrgen compiles XDR schemas, as defined in RFC 4506 and extended in RFC 5531, into a collection of formats:

  • A binary format (itself defined in XDR) which can be used to implement new compiler backends with relative ease
  • A JSON format derived from the above schema (this can also be used for the same purpose, but primarily exists to help inspect the output of the compiler)
  • Go code

This should not yet be considered well tested: this is an early stage project. That said, it is useful with many XDR schemas.

This implementation stick fairly close to the specifications, though does make some minor non-standard additions:

  • Attributes can be added to definitions by prefixing them with an attribute set. Attribute sets are wrapped in square brackets and formatted as [a, b, c("string param"), d(1 /* int param)]. They take the form of a key-value map
  • Attributes can be added to the specification itself by ensuring that the first non-comment entry in the file is an attribute set preceded by a hash, i.e. #[foo("bar")]

Some common attributes are defined:

  • doc: A documentation comment for the associated item
  • mode: Specifies a non-standard generation mode for a declaration. Currently the only defined mode is "map", which when used on a flexible array declaration where the type has two members, will cause a map to be generated in the resulting code
  • go_package: Defines what package name to use when generating Go code

Installation and Usage

The xdrgen binary provides a parser and frontend, while xdrgen-X provides the generator for (selected by passing the -G X option to xdrgen). Therefore, you should install both xdrgen and the generator binaries:

go install go.e43.eu/xdrgen/cmd/xdrgen{,-go,-xb,-json}

Generate Go code by invoking xdrgen -G go foo.x; this will output foo.x.go

Stability

The code generated by this package should continue working with new versions of the XDR package, and new versions of xdrgen

The XDR binary format (specified in ast.x) is not yet considered stable. The interface between xdrgen and generator plugins is subject to change.

(Near) Future Directions

  • Add syntax for importing types from other packages
  • Implement support for defining ONC RPC schemas as specified in Section 12 of RFC 5531
  • Implement support for RX schemas (as used by AFS)?

xdrgen's People

Contributors

erincandescent avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.