Bebop
bebop wire format in Go
Install / Use
/learn @200sc/BebopREADME
bebop
bebop is a bebop parser written in Go, for generating Go code.
bebop can read .bop files and output .go files representing them:
mybebop.bop:
struct Foo {
Bar bar;
}
message Bar {
1 -> float64 x;
2 -> float64 y;
3 -> float64 z;
}
package main
import (
"github.com/200sc/bebop"
)
func main() {
f, _ := os.Open("mybebop.bop")
defer f.Close()
bopf, _ := bebop.ReadFile(f)
out, _ := os.Create("mybebop.go")
defer out.Close()
settings := bebop.GenerateSettings{
PackageName: "mybebop",
}
bopf.Generate(out, settings)
}
These files can then be used to encode and decode their represented records:
package server
import (
"github.com/my/project/mybebop"
"net"
)
func sendFoo(cn net.Conn) (success bool) {
fooReq := mybebop.FooRequest{
Bar: "buzz",
}
if err := fooReq.EncodeBebop(cn); err != nil {
// ...
}
fooResp := mybebop.FooResponse{}
if err := fooResp.DecodeBebop(cn); err != nil {
// ...
}
return fooResp.Success
}
bebobc-go
At main/bebobc-go there is a cli utility to take .bop files and produce .go files from them, what is effectively a
little more sophisticated version of the first example in this document.
bebopfmt
At main/bebopfmt there is a cli utility to format and rewrite bop files. It takes in a -w argument to rewrite files in place, and accepts both directories and individual filepaths.
Known limitations
The following is a list of known issues with the current version of the project, ordered by approximate priority for addressing them.
-
We should be able to generate server code with handlers given all valid messages have op codes.
-
Tokenization and parsing could attempt corrective fixes to be able to report more than one error.
-
There are several incompatibilities between this compiler and the original compiler. These incompatibilities are documented (see testdata/incompatible), but we should attempt to resolve them. Trivially resolvable incompatibilities have been resolved already, remaining notes should involve raising upstream issues.
Credit
Original bebop compiler (C#, Typescript, ...): https://github.com/RainwayApp/bebop
In addition to defining the spec this package follows, most initial testdata was taken from the above project.
Related Skills
node-connect
349.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.7kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
