Skip to content

realistschuckle/goll1e

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is it?

I have implemented an LL(1) parser generator for the Go programming language. I did this to build parse trees for my HAML parser.
You can find out more about LL(1) parsers at LL Parser (Wikipedia)
You can find out more about GO at golang.org

Check out the wiki for information on the input grammar, the generated file structure, and other stufff (but not much other stuff).

This branch compiles with 6g/8g version release.r60 9481.

Is it done?

For a first draft, yes, I think so. Features include:

  • Yacc-like input grammar files
    • Ad-Hoc Syntax Directed Translations
    • Custom type handling with yystype, %token-, and %type declarations
  • “Dev” mode to emit printing instructions for the generated parser
  • Package setting
  • Sample input.y file with the expected command-line calculator grammar with operator precedence

How can I install this?

Just follow the simple directions from the command line.

goinstall "github.com/realistschuckle/goll1e"
pushd $GOROOT/src/pkg/github.com/realistschuckle/goll1e/
make install
popd

HEY! This doesn’t build! What’s wrong with you?

Ok, the release and master branches contain code that compiles against the latest documented release of Go. Sometimes, those
awesome and crazy Go guys change the cr4p out of the API and that breaks goll1e. Try switching over to the preview branch
and compiling that one. I try to keep it up to date with breaking changes to Go.

Thanks. That was fun. How can I uninstall this?

Just follow the simple directions from the command line:

pushd $GOROOT/src/pkg/github.com/realistschuckle/goll1e/
make nuke
popd
rm -rf $GOROOT/src/pkg/github.com/realistschuckle/goll1e/

How can I test this out?

Just follow the simple directions from the command line:

git clone git://github.com/realistschuckle/goll1e.git goll1e
cd goll1e
make gen
test/test
1 * 2 + 3 / 4 - 5 eof

How can I use it?

Create a grammar file, run goll1e against it, and include that .go file in your project. The command syntax goes something like goll1e input.y output.go. Then, call the yyparse(int, func(*yystype)int)bool function. It’ll return true if the parse succeeded and the result of your computations will exist in yyres[0]. Otherwise, you’ll get a false and junk will populate yyres.

Can I type to goll1e on stdin?

Yep. And, it’ll print to standard out, too. Just type goll1e at the command prompt after installation and you can type all you want with a CTRL+D to signal EOF.

About

An LL(1) parser generator for the Go programming language.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages