mirror of
https://github.com/boostorg/build.git
synced 2026-02-16 01:12:13 +00:00
Add support for Whale/Dolphin parser/lexer generators.
The toolsets are not very common, but: 1. I use them. 2. I've tied to maintaining this outside V2 CVS. 3. The toolset file is small. [SVN r29366]
This commit is contained in:
107
v2/tools/whale.jam
Normal file
107
v2/tools/whale.jam
Normal file
@@ -0,0 +1,107 @@
|
||||
# Copyright (C) Vladimir Prus 2002-2005.
|
||||
|
||||
# Use, modification and distribution is subject to the Boost Software
|
||||
# License Version 1.0. (See accompanying file LICENSE_1_0.txt or
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# This module implements support for Whale/Dolphin/WD parser/lexer tools.
|
||||
# See http://www.cs.queensu.ca/home/okhotin/whale/ for details.
|
||||
#
|
||||
# There are three interesting target types:
|
||||
# - WHL (the parser sources), that are converted to CPP and H
|
||||
# - DLP (the lexer sources), that are converted to CPP and H
|
||||
# - WD (combined parser/lexer sources), that are converted to WHL + DLP
|
||||
|
||||
import type ;
|
||||
import generators ;
|
||||
import path ;
|
||||
import "class" : new ;
|
||||
|
||||
rule init ( path # path the Whale/Dolphin/WD binaries
|
||||
)
|
||||
{
|
||||
if $(.configured)
|
||||
{
|
||||
errors.error "Attempt to reconfigure Whale support" ;
|
||||
}
|
||||
.configured = true ;
|
||||
|
||||
.whale = [ path.join $(path) whale ] ;
|
||||
.dolphin = [ path.join $(path) dolphin ] ;
|
||||
.wd = [ path.join $(path) wd ] ;
|
||||
}
|
||||
|
||||
|
||||
# Declare the types.
|
||||
type.register WHL : whl ;
|
||||
type.register DLP : dlp ;
|
||||
type.register WHL_LR0 : lr0 ;
|
||||
type.register WD : wd ;
|
||||
|
||||
# Declare standard generators.
|
||||
generators.register-standard whale.whale : WHL : CPP H H(%_symbols) ;
|
||||
generators.register-standard whale.dolphin : DLP : CPP H ;
|
||||
generators.register-standard whale.wd : WD : WHL(%_parser) DLP(%_lexer) ;
|
||||
|
||||
# The conversions defines above a ambiguious when we generated CPP from WD.
|
||||
# We can either go via WHL type, or via DLP type.
|
||||
# The following custom generator handles this by running both conversions.
|
||||
|
||||
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 whale.wd-to-cpp : whale.whale ;
|
||||
generators.override whale.wd-to-cpp : whale.dolphin ;
|
||||
|
||||
|
||||
generators.register [ new wd-to-cpp whale.wd-to-cpp : : CPP ] ;
|
||||
|
||||
|
||||
actions whale
|
||||
{
|
||||
$(.whale) -d $(<[1]:D) $(>)
|
||||
}
|
||||
|
||||
actions dolphin
|
||||
{
|
||||
$(.dolphin) -d $(<[1]:D) $(>)
|
||||
}
|
||||
|
||||
actions wd
|
||||
{
|
||||
$(.wd) -d $(<[1]:D) -g $(>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user