cons-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: compiling flex & bison files


From: Erich Waelde
Subject: Re: compiling flex & bison files
Date: Mon, 18 Feb 2002 08:04:33 +0100

Howdy, downunder ...

> What is the best way to compile flex and bison files using ConsPlus?

> Do people use Language or a set of Command calls?


I use the following snippets with some success:

-----------------------------------------------------
$hoc6 = new cons (
        ENV     => { PATH => "$PATH" },
   ...
        YACC    => "bison",
        YFLAGS  => "-y -d",
        LIBS    => "-lm -lfl",
        LEX     => "flex",
        LFLAGS  => "-t",
   ... 
        );



Command $hoc6 "lex.c", "lex.l", q(
        %LEX %LFLAGS %< > %>
);

Command $hoc6 ["y.tab.h", "hoc6.c"], "hoc6.y", q(
        %YACC %YFLAGS %<
        mv y.tab.c hoc6.c
        );
-----------------------------------------------------

This example uses Command() calls, note that processing hoc6.y
produces 2 output files (hoc6.c and y.tab.h), both used further.


Using Cons::Plus I got the "lex" bit to work like this (in
a lower Conscript in this case):

-----------------------------------------------------
use Cons::Plus;

Import qw( top_env PATH );

Language "Lex",
        SRC_SUFFIX => ".l",
        OBJ_SUFFIX => ".c",
        PREFIX     => "L_",
        ENV => {
            LEX    => "flex",
            LFLAGS => "-t",
            L_COM  => "cd %<:d; %LEX %LFLAGS %<:f > %>:f",
    };

$tgt = Cons::Plus->new (
        ENV    => { PATH => "$PATH" },
);

$tgt->Objects( "lex.l" );
----------------------------------------------------

The "yacc" bit I still do with Command() calls, since I failed
to make cons/Cons::Plus realize that 
*one* command actually produces
*two* derived files

Maybe Cons::Plus does provide dealing with a list like Command() 
in the above example ? Maybe it can be changed to do it with
modest effort?

Maybe there are other ways of doing it ...

Cheers,
Erich




reply via email to

[Prev in Thread] Current Thread [Next in Thread]