1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
import type ;
import generators ;
import "class" : new ;
type.register WHL : whl ;
type.register DLP : dlp ;
type.register WHL_LR0 : lr0 ;
type.register WD : wd ;
generators.register-standard extra.whale : WHL : CPP WHL_LR0 H H(%_symbols) ;
generators.register-standard extra.dolphin : DLP : CPP ;
generators.register-standard extra.wd : WD : WHL(%_parser) DLP(%_lexer) ;
class wd-to-cpp : generator
{
rule __init__ ( * : * : * )
{
generator.__init__ $(1) : $(2) : $(3) ;
}
rule run ( project name ? : property-set : source )
{
local new-sources ;
if ! [ $(source).type ] in WHL DLP
{
local r1 = [ generators.construct $(project) $(name)
: WHL : $(property-set) : $(source) ] ;
local r2 = [ generators.construct $(project) $(name)
: DLP : $(property-set) : $(source) ] ;
new-sources = [ sequence.unique $(r1[2-]) $(r2[2-]) ] ;
}
else
{
new-sources = $(source) ;
}
local result ;
for local i in $(new-sources)
{
local t = [ generators.construct $(project) $(name) : CPP
: $(property-set) : $(i) ] ;
result += $(t[2-]) ;
}
return $(result) ;
}
}
generators.override extra.wd-to-cpp : extra.whale ;
generators.override extra.wd-to-cpp : extra.dolphin ;
generators.register [ new wd-to-cpp extra.wd-to-cpp : : CPP ] ;
rule whale ( targets * : sources * : properties * )
{
}
actions whale
{
echo "Whale consuming " $(>)
touch $(<)
}
rule dolphin ( targets * : source * : properties * )
{
}
actions dolphin
{
echo "Dolphin consuming" $(>)
touch $(<)
}
rule wd ( targets * : source * : properties * )
{
}
actions wd
{
echo "WD consuming" $(>)
touch $(<)
}
rule x ( target * : source * : properties * )
{
}
actions x
{
echo "X: source is " $(>)
touch $(<)
}
rule x_pro ( target * : source * : properties * )
{
}
actions x_pro
{
echo "X_PRO: source is " $(>)
touch $(<)
}
|