Code Monkey home page Code Monkey logo

magic.lambda.hyperlambda's Introduction

magic.lambda.hyperlambda - Parsing and creating Hyperlambda

This is the Hyperlambda parser and generator in Magic, and allows you to parse Hyperlambda, in addition to generate Hyperlambda. More specifically, this project provides you with the following slots.

  • [hyper2lambda] - Transforms a piece of Hyperlambda (text) to a lambda hierarchy
  • [lambda2hyper] - Transforms a lambda hierarchy to Hyperlambda (text)

Using these slots, you can both easily create, serialize, and parse Hyperlambda to lambda, and vice versa. Below is an example of parsing a piece of text as Hyperlambda, for then to dynamically execute it afterwards.

.hl:@"log.info:""This was logged from a piece of text"""

hyper2lambda:x:-

eval:x:-

You can also reverse the process, such as the following illustrates.

.hl
   log.info:This is some example logging invocation

lambda2hyper:x:-/*

The above two slots, allows you to dynamically generate plain text from a lambda structure, and vice versa, allowing you to for instance persist execution objects and structured data into files, your database, or for that matter transmit it over the network to another machine. Below is an example of dynamically loading a Hyperlambda file from disc, for then to execute it. Notice, in order to have the following snippet work, you'll need an actual file called "foo.hl" inside of your backend's "files/" folder.

io.file.load:/foo.hl

hyper2lambda:x:-

eval:x:-

Notice - Both of these slots can optionally be given a [comments] arguments with a value of true, at which point both [lambda2hyper] and [hyper2lambda] will preserve comments, and persist these as [..] nodes into your lambda, and reverse the process for the other direction. This allows you to keep the comments of your Hyperlambda parts as semantic nodes, as you handle your Hyperlambda and node hierarchy.

How to use [hyper2lambda]

This slot creates a semantic lambda object (graph object) from the specified text. Below is an example of usage.

.hl:@"log.info:""This was logged from a piece of text"""
hyper2lambda:x:-

The above of course produces an executable lambda object from your specified Hyperlambda text.

How to use [lambda2hyper]

This slot creates a Hyperlambda string from your specified lambda object. This allows you to transfer your Hyperlambda to some other server, and/or persist it to disc. Below is example usage.

.hl
   log.info:This is some example logging invocation
lambda2hyper:x:-/*

Magic's GitHub project page

Magic is 100% Open Source and you can find the primary project GitHub page here.

Project website for magic.lambda.hyperlambda

The source code for this repository can be found at github.com/polterguy/magic.lambda.hyperlambda, and you can provide feedback, provide bug reports, etc at the same place.

  • Build status
  • Quality Gate Status
  • Bugs
  • Code Smells
  • Coverage
  • Duplicated Lines (%)
  • Lines of Code
  • Maintainability Rating
  • Reliability Rating
  • Security Rating
  • Technical Debt
  • Vulnerabilities

Copyright and maintenance

The projects is copyright Thomas Hansen 2023 - 2024, and professionally maintained by AINIRO.IO.

magic.lambda.hyperlambda's People

Contributors

polterguy avatar

Stargazers

 avatar  avatar  avatar  avatar  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.