OK, so let's look at how to go at this.  The problem is you're getting
an empty csg_scanner.c file, which is obviously incorrect.  That C
file is generated by re2c, so let's take a look at what re2c is
reporting by running make VERBOSE=1 :

[100%] [RE2C][csg_scanner] Building scanner with brlcad/build/bin/re2c
cd brlcad/src/conv/csg && brlcad/build/bin/re2c --no-debug-info
--no-generation-date -c -o brlcad/build/src/conv/csg/csg_scanner.c
brlcad/build/src/conv/csg/csg_scanner.c.re
re2c: error: line 677, column 19: can't find symbol

Ah - we have an re2c error.  If we look at the generated file
csg_scanner.c.re at line 677:

<code>(optional_ws)(group_begin) {

we see it is saying it doesn't know about one of the definitions on
that line.  Well, <code> is an re2c tag - that leaves optional_ws and
group_begin.  Checking our original perplex template
csg_scanner.perplex, we see that the only definitions present are:

group_begin = "group() {";
group_content = [a-z]+ "("*")";
group_end = "}";

Ah-ha!  optional_ws isn't defined, and isn't an re2c "built-in" of
some sort.  Since we're basing this off of the dom2dox code as a
starting point, the next thing to check is whether *it* has a
definition for optional_ws.  As it turns out, it does:

optional_ws = [ \t]*;

So if we add that definition in with the group_* defininitions, re2c
can proceed.

Now, as the build progresses further, we get this problem (or at
least, my compiler does):

In file included from brlcad/build/src/conv/csg/csg_scanner.c:22:0:
brlcad/build/src/conv/csg/csg_scanner.c: In function ‘PERPLEX_LEXER_private’:
brlcad/src/conv/csg/csg.h:59:14: error: unused variable ‘tokenData’
[-Werror=unused-variable]
     token_t *tokenData = appData->tokenData;
              ^
brlcad/build/src/conv/csg/csg_scanner.c:654:5: note: in expansion of
macro ‘PERPLEX_ON_ENTER’
     PERPLEX_ON_ENTER;
     ^
brlcad/build/src/conv/csg/csg_scanner.c: At top level:
brlcad/build/src/conv/csg/csg_scanner.c:462:1: error: ‘getTokenText’
defined but not used [-Werror=unused-function]
 getTokenText(perplex_t scanner)
 ^
cc1: all warnings being treated as errors

That's going to be typical of problems you'll encounter using
autogenerated code, especially in the early stages.  So we'll do what
we did with the lemon parser and add some pragmas to
csg_scanner.perplex to locally squash those particular warnings (we
want to leave on as many as the templates will let us, since long term
we want to remove all of these pragmas once we're properly using the
various parts of the lexer/parser system.)

/* perplex input file */
#include "csg.h"

/* Temporarily suppress some warnings, to make for easier development */
#if defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) &&
!defined(__clang__)
#  pragma GCC diagnostic ignored "-Wunused-variable"
#  pragma GCC diagnostic ignored "-Wunused-parameter"
#  pragma GCC diagnostic ignored "-Wunused-function"
#endif
#if defined(__clang__)
#  pragma clang diagnostic ignored "-Wunused-variable"
#  pragma clang diagnostic ignored "-Wunused-parameter"
#  pragma clang diagnostic ignored "-Wunused-function"
#endif

/* condition states - no idea what this enum does but I modified it according
to what I used below */
enum {INITIAL, code, group, group_in};

With those changes, I get a successful build here.  Note that I have
not tested it at all - this is simply a compilation fix, so far.
Hopefully the above also illustrates how and where to look for
problems when using this particular toolchain - if you need to drill
deeper, you can also run perplex and re2c outside of the build system
to use additional options and get more specific info.

I've committed things at the state outlined above into the main tree
as of commit r65209 so you can use that as a starting point for
subsequent work, since it seems to constitute a minimum-building state
(well, we'll see about Windows).

Cheers,
CY


On Tue, Jun 2, 2015 at 3:38 PM, Ilinca Andrei <andrei.ilinc...@gmail.com> wrote:
> Hello,
>
> As we previously discussed, I started modifying code in the src/conv/csg (
> on top of your integrated patch, Cliff) to make it parse group() and
> identify some basic tokens. The problem I encountered and could not solve is
> the following:
>
> [ 91%] [ 91%] Building C object
> src/conv/csg/CMakeFiles/csg.dir/csg_scanner.c.o
> Building C object src/conv/csg/CMakeFiles/csg.dir/csg_parser.c.o
> [ 91%] /home/andrei/buildbrlcad/src/conv/csg/csg_scanner.c:1:0: error: ISO C
> forbids an empty translation unit [-Wpedantic]
> make[2]: *** [src/conv/csg/CMakeFiles/csg.dir/csg_scanner.c.o] Error 1
>
> I tried adding # pragma GCC diagnostic ignored "-Wpedantic" to the parser
> file but the error persisted, and it's obviously not the right way to go,
> either. Parser is generating and empty file (csg_scanner.c) . Most likely,
> this isn't intended behavior, but I can't seem to reason what causes this.
> Presumably, there is an issue with the grammar, but I could not figure out a
> fix.
>
> I attached below a patch with my code.
>
> Cheers,
> Andrei

------------------------------------------------------------------------------
_______________________________________________
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to