

GitHub - weberc2/tdl: A simple type description language
source link: https://github.com/weberc2/tdl
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

weberc2/tdl
README
Disclaimer: This is an experiment in code generation; it's largely a project for my own amusement and utility. Don't use this in production.
tdl
is a terse, expressive type description language. For now, I'm using it
to generate Go boilerplate, which is particularly useful for modeling sum
types. Besides generating type declarations, tdl
could also be used to
generate serializers/deserializers/validators, and not just for Go but for any
language. This would make it usable as a simplified, expressive alternative for
protobufs. I'd really like to use it as the type grammar of a ML-like language
that compiles to Go.
If any of this interests you, drop me a line: [email protected]
TDL-GO
Right now, there is only one implementation (tdl-go
)--a Go type definition
compiler (tdl goes in, Go type stubs come out). Eventually I want to build the
aforementioned applications as well as compilers for other languages
(tdl-py
and tdl-js
are high on my list).
INSTALL
The repository contains generated.go
, which is generated from types.tdl
, so
all you need to install the compiler is the go toolchain: go install ./tdl-go
.
USAGE
tdl-go
currently reads from stdin and writes to stdout, so you invoke it like
this: cat ./types.tdl | tdl-go > ./generated.go
.
EXAMPLES
tdl-go
is self-hosted, so check out its type description and the
generated output. Also, ./examples/json contains a toy program that
serializes Go data types to JSON by first converting them to generated JSON
types.
Here is the type description for TDL's AST:
type Ident = string
type Field = {Name Ident; Type Type}
type Enum = []Field
type Struct = []Field
type Tuple = []Type
type Pointer = {Type Type}
type Slice = {Type Type}
type Type = Ident Ident
| Enum Enum
| Struct Struct
| Tuple Tuple
| Pointer Pointer
| Slice Slice
type TypeDecl = {Name Ident; Type Type}
Recommend
-
6
Files Permalink Latest commit message Commit time
-
6
Armin's BlogSimple description of popular software licensesJune 05, 2016
-
10
React Fiber Architecture Introduction React Fiber is an ongoing reimplementation of React's core algorithm. It is the culmination of over two years of research by the React team. The goal of React Fiber is to increase...
-
7
TDL,高效率工作的核心武器 张丽俊 • 2021-05-17 09:32:21 来源:张丽俊 E600G0...
-
5
How to Update GitHub Topic Icon and Description GitHub has Topics. For example, when you search for “Azure” on GitHub it displays the Azure topic:
-
24
bazel_rules_hdl Hardware Description Language (Verilog, VHDL, Chisel, nMigen, etc) with open tools (Yosys, Verilator, OpenROAD, etc) rules for Bazel (https://bazel.build) Project Vision...
-
6
Pinned packages Public Repo to help explain the differ...
-
12
Many Worlds: a philosophy of data collaboration Data collaboration is a key driver of modern organisational success. No aspect of modern life is untouched by the need and importance of data collaboration. It is really expansive, cove...
-
3
WSDL is short for Web Service Description Language. WSDL is used to describe the interface of a web service. If you do not know the interface of a web service, how could you call it? This WSDL tutorial is an introductio...
-
7
[RFC] MDL: A Micro-Architecture Description Language for LLVMTL;DR: We’ve created a DSL and compiler for modeling micro-architecture that handles a very broad class of architectures - CPU, GPUs, VLIWs, DSPs, ML accelerat...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK