Giter Site home page Giter Site logo

asn-meta's Introduction

ASN::META

Experimental Raku module that is able to compile ASN.1 specification into set of Raku types.

What ASN::META does not?

  • It does not generate Raku code (at least, textual form).
  • The module knows nothing about ASN.1 encoding means, it purely generates Raku types. For this purpose a separate module may be used. Currently, goal is to have full compatibility with ASN::BER module.

What ASN::META does?

Main workflow is as follows:

  • A specification is passed to ASN::META on module use
  • (internally, ASN::Grammar is used to parse the specification)
  • ASN::META uses parsed specification to generate appropriate types with MOP
  • Generated types for particular ASN.1 specification are precompiled and exported

What it does?

Synopsis

# In file `schema.asn`:
WorldSchema

DEFINITIONS IMPLICIT TAGS ::= BEGIN
Rocket ::= SEQUENCE
{
   name      UTF8String,
   message   UTF8String DEFAULT "Hello World",
   fuel      ENUMERATED {
       solid(0),
       liquid(1),
       gas(2)
   },
   speed     CHOICE {
      mph    [0] INTEGER,
      kmph   [1] INTEGER
   }  OPTIONAL,
   payload   SEQUENCE OF UTF8String
}
END

# In file `User.pm6`:
# Note usage of BEGIN block to gather file's content at compile time
use ASN::META BEGIN [ 'file', slurp 'schema.asn' };
# In case of re-compilation on dependency change, package User may be
# re-built from the place where local paths are useless, in this case use %?RESOURCES:
# `use ASN::META BEGIN { 'file', slurp %?RESOURCES<schema.asn> }`

# `Rocket` type is exported by ASN::META
my Rocket $rocket = Rocket.new(name => 'Rocker', :fuel(solid),
        speed => Speed.new((mph => 9001)),
        payload => Array[Str].new('A', 'B', 'C'));


# As well as inner types being promoted to top level:
say Fuel;  # generated enum
say solid; # value of this enum, (solid ~~ Fuel) == true
say Speed; # Generated type based on ASNChoice from ASN::BER

asn-meta's People

Contributors

altai-man avatar vrurg avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

vrurg

asn-meta's Issues

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.