3

I've tried a couple. And there is only a couple of tutorials in Google for re2c+lemon.
Currently for all examples I get similar bunch of errors like:

In file included from main.cpp:2:0:
parser.y:44:5: error: ‘yygotominor’ was not declared in this scope
     A.int_value = B.int_value * C.int_value;
     ^
In file included from main.cpp:2:0:
parser.c:770:16: error: ‘YY_MAX_SHIFTREDUCE’ was not declared in this scope
   if( yyact <= YY_MAX_SHIFTREDUCE ){
                ^
parser.c:771:15: error: ‘YY_MAX_SHIFT’ was not declared in this scope
     if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
               ^

Where is it declared?

PS: don't post 10y old articles (even without code or if the code can't be compiled now). If you can - write an example here. If not - don't post links from Google.

Sergey
  • 19,487
  • 13
  • 44
  • 68

1 Answers1

4

This tutorial works for me:

  1. Get re2c (see re2c install page for details http://re2c.org/install/install.html).

  2. Get lemon: download tarball wget http://prdownloads.sourceforge.net/souptonuts/lemon_examples.tar.gz, extract and build (I had to add #include <stdlib.h> to many examples for malloc).

  3. Clone github repo https://github.com/tokuhirom/re2c-lemon-tutorial : git clone https://github.com/tokuhirom/re2c-lemon-tutorial.git

  4. Patch re2c-lemon-tutorial/Makefile to find lemon and re2c (if needed).

  5. make, ./mycalc and enjoy (hit Ctrl+D to stop and emit result).

More re2c examples on re2c website: http://re2c.org, more lemon examples inside of lemon tarball.

skvadrik
  • 586
  • 1
  • 3
  • 11
  • None of these links have a small working example of using re2c + lemon that can be even compiled (Even that shit from 2008). And you know what.. surprize... I don't want to look into a CAD system to learn how to get CALC compiled correctly. You helped a lot. – Sergey Mar 26 '16 at 00:33
  • 2
    I've updated the answer (this time I checked it works). :) – skvadrik Mar 26 '16 at 11:00