Skip to content

simoneguidi94/gopapageno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go PAPAGENO

Go PAPAGENO (PArallel PArser GENeratOr) is a parallel parser generator based on Floyd's Operator Precedence Grammars.

It generates parallel Go parsers starting from a lexer and a grammar specification. These specification files resemble Flex and Bison ones, although with some differences.

The generated parsers are self-contained and can be used without further effort.

This work is based on Papageno, a C parallel parser generator.

Installation

go get github.com/simoneguidi94/gopapageno

Parser generator example

package main

import (
	"github.com/simoneguidi94/gopapageno/generator"
)

func main() {
	generator.Generate("languages/arithmetic/lexer/arith.l", "languages/arithmetic/parser/arith.g", "languages/arithmetic")
}

Parser usage example

package main

import (
    "fmt"

    "github.com/simoneguidi94/gopapageno/languages/arithmetic"
)

func main() {
    root, err := arithmetic.ParseFile("expression.txt", 2)
    
    if err == nil {
        fmt.Printf("Result: %d\n", *root.Value.(*int64))
    } else {
        fmt.Printf("Parse failed!")
        fmt.Println(err.Error())
    }
}

Authors and Contributors

Releases

No releases published

Packages

No packages published