Golemon - A Go port of the lemon parser generator

Go lemon port

A port of the Lemon Parser to Go.

State

This work was done entirely in support of gopikchr. It works well enough to turn pikchr.y into pikchr.go, but there are almost certainly further bugs. Pull requests are welcome: I intend no support for this project, but if you're obscure enough to want a Go port of the Lemon Parser, then we share a strange kind of kinship, and I welcome your contributions.

Goals

  • Keep the code structure as close to the original as possible, to make tracking and applying future changes as straight-forward as possible.
  • Convert to Go idioms only where the conversion remains clear.

See also

  • nsf/golemon - 11 years out-of date 😞 . Went in the opposite direction: the parser generator is still written in C, but generates Go code

Changes

  • You must define func testcase(bool) in your code.
  • The various #defines have been turned into constants.

TODOs

  • Use the embed package to embed the template in the binary.
  • Create a github action that follows the rss feed for changes to lemon.c and lempar.c and creates issues. - [ ] Figure out a better way to do constants: either put them in a separate file that is only (re)generated optionally, or make them settable with flags, or something.
  • Possibly, go back and incorporate the lessons learned from porting pikchr.y to Go: use a []byte to represent the main char * pointers and pointer arithmetic, instead of converting to []rune.

Contributors

Similar Resources

Clean-Swift source and test code auto-generator. It can save you time typing 500-600 lines of code.

Clean-Swift source and test code auto-generator. It can save you time typing 500-600 lines of code.

Clean-Swift source & test code auto generator Overview Run Output Basic Usage make config.yaml target_project_name: Miro // target project name copyri

Apr 13, 2022

Fast, scalable pseudo random number generator based on xxh3

Fast, scalable pseudo random number generator based on xxh3

XXH3-Based Pseudorandom Number Generator This package contains an experimental implementation of a noise based pseudorandom number generator that scal

Nov 24, 2022

Galvanity is Algorand vanity address generator written in Go

Galvanity Galvanity is Algorand vanity address generator written in Go Usage galvanity [search-type] pattern search-type is matching function to sea

Nov 14, 2022

xgen generator with extend features

XGen Plus Generator Introduction xgen is a library written in pure Go providing a set of functions that allow you to parse XSD (XML schema definition)

Dec 8, 2021

Color generator with golang

Color generator with golang

color-generator How to use this repo img src="https://color-pallete-gen.herokuapp.com/hexCode" / Like this: Getting Started Copy sample.env to .env

Oct 22, 2021

Rest Api Generator for Golang Programming Language

Rest Api Generator for Golang Programming Language

Nov 29, 2021

A prototype code-generator library for golang.

A prototype code-generator library for golang.

Jul 28, 2022

Julia Set Generator Written In Golang

 Julia Set Generator Written In Golang

Julia Set Generator Written In Golang This is a simple (naive) Julia Set generator written in Golang. The project utilizes concurrent workers to speed

Nov 5, 2021

Code generator that generates boilerplate code for a go http server

http-bootstrapper This is a code generator that uses go templates to generate a bootstrap code for a go http server. Usage Generate go http server cod

Nov 20, 2021
Comments
  • Assert function signature is incorrect

    Assert function signature is incorrect

    I think the assert signature (https://github.com/gopikchr/golemon/blob/main/lempar.go.tpl#L1006) is incorrect. In the sqlite parse.y there are many calls to assert without a message. I think we need to make the message string optional.

    // assert is used in various places in the generated and template code
    // to check invariants.
    func assert(condition bool, message ...string) {
    }
    
  • `go test` fails

    `go test` fails

    $ go test
    # github.com/gopikchr/golemon
    ./golemon.go:3586:6: github.com/gopikchr/golemon.ErrorMsg call needs 2 args but has 3 args
    ./golemon.go:5527:3: fmt.Printf format %r has unknown verb r
    
  • Remove the intermediate package

    Remove the intermediate package

    Since it doesn't build, maybe we can move it somewhere else?

    cd intermediate
    package github.com/gopikchr/golemon/intermediate: C source files not allowed when not using cgo or SWIG: lemon.c lempar.c
    
Related tags
GoLang port of Google's libphonenumber library

phonenumbers golang port of Google's libphonenumber, forked from libphonenumber from ttacon which in turn is a port of the original Java library. You

Jan 4, 2023
Serial-locate - A simple tool for searching the COM port

serial-locate A simple tool for searching the COM port Usage Direct query serial

Jan 18, 2022
bebop is a bebop parser written in Go, for generating Go code.

bebop is a bebop parser written in Go, for generating Go code. bebop can read .bop files and output .go files representing them: package main i

Dec 24, 2022
A parser for Ontario's baby name data
A parser for Ontario's baby name data

obnp What? A parser for Ontario's baby name data Why? I wanted to see if a specific name existed in both the male and female datasets. This tool is mo

Mar 15, 2022
A data parser lib for Go with pythonic grammar sugar and as concern as possible for high performance

mapinterface - A data parser lib for Go with pythonic grammar sugar and as concern as possible for high performance mapinterface 旨在消灭对map/list解析而产生的层层

Nov 10, 2021
Golang flags parser with zero dependency

flags Golang flags parser with zero dependency. Usage See simple.go for basic usage. Concept flags gives a simple way to get flag's value from argumen

Jan 16, 2022
Versatile Go code generator.
Versatile Go code generator.

Generis Versatile Go code generator. Description Generis is a lightweight code preprocessor adding the following features to the Go language : Generic

Nov 30, 2022
An enum generator for go

go-enum An enum generator for go How it works The goal of go-enum is to create an easy to use enum generator that will take a decorated type declarati

Dec 22, 2022
Jennifer is a code generator for Go

Jennifer Jennifer is a code generator for Go. package main import ( "fmt" . "github.com/dave/jennifer/jen" ) func main() { f := NewFile("m

Jan 4, 2023
Fast and scalable pseudorandom generator for Go

fastrand Fast pseudorandom number generator. Features Optimized for speed. Performance scales on multiple CPUs. How does it work? It abuses sync.Pool

Dec 22, 2022