JSPM

uffda

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q28328F
  • License MIT

Parser generator for domain specific languages

Package Exports

  • uffda

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (uffda) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Uffda

NOTE: work in progress!

Uffda is a parser generator for domain specific languages.

It is different from many parser generators in that the syntax is expressive enough to support parsing strings as well as objects, arrays or any other value type. The result of this capability is that each step of the compiler can be expressed as dsl.

OMeta’s key insight is the realization that all of the passes in a traditional compiler are essentially pattern matching operations

~ Experimenting with Programming Languages, Alessandro Warth 2009

How to use

npm i uffda
import { uffda } from "uffda"
import { Digit } from "uffda/parsers/tokenizer"

// This generates a parser which can be used as a 
export const calc = uffda`
  Add = x:Number '+' y:Number -> ${({ x, y }) => x + y}
  Number = i:${Digit} -> ${({ i }) => parseInt(i)}
  Main
    = Add
    | Number
`

// Parses a calculator dsl which procuces mathematical results
const { value } = calc`1+2`
assert(value === 3)

Documentation

This is a work in progress

Resources

This project is based on a previous project I made called Meta# which was a C# implementation of the ideas written in the OMeta paper by Alessandro Warth.