Recompile nagaqueen + rock with the latest peg instead of greg #407

nddrylliog opened this Issue May 17, 2012 · 9 comments

5 participants

ooc language member

Ian Piumarta, Giulio Paci and myself have been discussing lately the opportunity to merge greg (_why's fork that I forked) with Ian's original peg/leg implementation.

Ian added the few missing features (re-entrancy, error reporting) that were added to greg. As a result, I believe we can make nagaqueen/rock work with their peg/leg now.

Ian's version can be checked out via SVN, here:

(Ping @duckinator @showstopper @shamanas @fredreichbier for the discussion).


Well if it'll work, then why not? That means one less thing that's specific to ooc/rock!

ooc language member

I agree, if it isn't too hard to switch nor any tremendous (negative) side effects are introduced, let's give it a shot o/


I'll try to make it work today or tomorrow.

ooc language member

@shamanas news? :)


@nddrylliog There seems to be some trouble with error reporting (leg can't parse the grammar when it uses ~{...} constructs) so I removed those and tried recompiling but there still was some error with the "core" variable... I don't really have the time to fix those yet, I'm in the middle of my exams now but in a couple of week I should have some time :)

ooc language member

Yes, the error handling mechanism implemented by Ian is different than what we have in greg. According to him however, it should be a strict superset of what we used to have (and the implementation is cleaner!). He has updated the docs here: (you might want to rebuild that to get a proper HTML page)


@nddrylliog Ok I'll check it out sometime :)


Recently I migrated a project (kiwi) from leg (0.1.7) to greg. Now I am testing it with leg (svn version).
I am able to compile it using leg with these changes:

  1. Replace GREG* g = yyparse_new(k) with something like this:
GREG* g = (GREG *) calloc(1, sizeof(GREG));
((GREG*)g)->data = k;
  1. Replace yyparse_free(g) with something like this:
  1. Remove last argument, D, from YY_INPUT definition
  2. Add something like this near the end of the code preamble:
#define G yy
#define _yycontext _GREG
#define yycontext GREG
#define YY_XTYPE void *
#define YY_CTX_LOCAL
#define YY_INPUT(buf, result, max_size) handle_input(G->data, buf, &result, max_size)
#define yydeinit(a) YYRELEASE(a)

The first two points can be applied even if you continue to use GREG. I was not using error reporting features from GREG, so I do not have advices about it.

I hope this would be helpful.


@giuliopaci Thanks, this is very helpful :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment