gofor x { y }
is translated to
go func () { for x { y } }()
The framework's shortcomings are many (processing is purely sequential,
no proper error checking, incorrect line number reporting, no system for
watching nested depth of {}/[]/(), etc.), but it should be sufficient to
make playing around with various language extensions easy.
Goinstall'able from github.com/bytbox/goprep/goprep.
Happy hacking!
[1] https://github.com/bytbox/goprep
[2] https://github.com/bytbox/goprep/blob/master/examples/goforpp.go
--
Scott Lawrence
On Jan 2, 11:45 am, Scott Lawrence <byt...@gmail.com> wrote:> A new
toy some might find useful: goprep[1] is a lexical preprocessor>That's cool; I did LuaMacro for exactly the same reasons, as a way to
framework for go.
get a feeling for new syntax extensions without having to actually
modify the parser.
And yes, error checking and line number translation was definitely the
trickiest part of that project. A language like C is built for
preprocessing and has #line directives. Lua can be executed from a
It's still somewhat tricky to get right, especially with go's automatic
semicolon insertion that makes it difficult to tell exactly what line
one is currently on.
Error handling during the translation stage is still problematic, of course.
--
Scott Lawrence
On 01/02/2012 10:25 AM, minux wrote:It's still somewhat tricky to get right, especially with go's automatic
> //line <filename>:<linenr>
semicolon insertion that makes it difficult to tell exactly what line
one is currently on.