xelf

module
v0.0.0-...-7e8a755 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2020 License: BSD-2-Clause

README

xelf

xelf is a cross-platform expression language framework. It is meant to be a simple notation for all things crossing process or language boundaries.

A small set of opinionated packages are the foundation to build simple domain specific languages, that provide expression resolution and a practical type system with inference out of the box.

It is in an alpha state and can be used for experimentation.

Overview GoDoc

  • cor: minimal runtime utilities for generated code
  • bfr: common interface for buffered writers and bytes buffer pool
  • lex: token lexer and tree scanner
  • typ: composable type system and a parser, comparison and unification
  • lit: literal parser, generic implementations and support for comparison and conversion
  • prx: literal adapters and proxies to native go data using reflection
  • exp: simple extensible expression language
  • std: built-in expression resolvers
  • utl: extra utilities and resolvers

Motivation

The author envisioned this tool, while building a typical back-office software, where:

  • configuration files could benefit from variables and simple expressions
  • templates could help generating html and PDFs on both the server and client
  • complex queries for data heavy pages would accumulate expression like parameters
  • data schema was needed at runtime and to generate code for different languages

For all of those cases there are projects and solutions available that can be used and implemented. Each has its own environment with a different syntax and limitations. That is fine at first.

But then you want to customize one aspect of the library you are using for your problem or need to use the same functionality in another language. The result is adapter code or handwritten niche solutions, that continue to grow and keep you busy writing similar boilerplate for each environment, for every change.

The vision for xelf is to have basic meta-language as versatile tool for creating simple domain specific languages, that can be used as data format and translated to other language targets. In contrast to other DSL frameworks, scripting languages or LISPs, the xelf language is specifically designed to be easy to gradually implement and to work with in other languages.

After about two years of experiments of varying success, I naturally arrived at a Lisp-style syntax, using a simple, yet powerful type system in combination with JSON compatible literals, a small set of built-in operators and expressions and an extensible evaluation process, that can be used to liberally change or extend the language.

The result is not a Lisp and is much more restricted than one, primarily to make it as easy as possible to translate expressions to idiomatic code in different languages, even SQL.

Examples

There are two projects in development, that will demonstrate how xelf can be used.

The daql project provides tools to define, migrate and query domain models as well as packages used for to facilitate these features.

The layla project provides a layout format, that can be printed on a specific label printer or rendered as PDF or HTML preview.

License

Copyright (c) 2019 Martin Schnabel. All rights reserved. Use of the source code is governed by a BSD-style license that can found in the LICENSE file.

Directories

Path Synopsis
Package bfr provides a common interface for buffered writers and a bytes.Buffer pool.
Package bfr provides a common interface for buffered writers and a bytes.Buffer pool.
Package cor has some utility function for working with numeric and character literal values.
Package cor has some utility function for working with numeric and character literal values.
Package exp is a simple and extensible expression language, built on xelf types and literals.
Package exp is a simple and extensible expression language, built on xelf types and literals.
Package lex provides a token and tree lexer, tree splitter and string quoting code.
Package lex provides a token and tree lexer, tree splitter and string quoting code.
Package lit provides code for working with literals.
Package lit provides code for working with literals.
Package prx provides literal proxies that write though to the underlying go data structure.
Package prx provides literal proxies that write though to the underlying go data structure.
Package std provides built-in expression resolvers.
Package std provides built-in expression resolvers.
Package typ provides a restricted but combinable type system.
Package typ provides a restricted but combinable type system.
Package utl provides helpers to extend the xelf language and some common library function specs.
Package utl provides helpers to extend the xelf language and some common library function specs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL