Commit 214a35d2 authored by pouill_n's avatar pouill_n
Browse files

from Nicolas Pouillard <ertai@lrde.epita.fr>

	* src/syn/Expressions/OperatorsExpressions.sdf: Add an ast tag.
	* src/syn/Declarations.sdf: Add a pp tag.
	* src/parser/parse-specs.str: Add an option.
	* src/specs-to-cxx/test/test_cast.spec: Add.
	* src/specs-to-cxx/Specs-to-Cxx.str: Lots of corrections.
	* src/specs-to-cxx/Makefile.am,
	* src/strategospecs/Makefile.am,
	* Makefile.am: Update.
parent 31c4cc0e
2004-05-05 Nicolas Pouillard <ertai@lrde.epita.fr>
* src/syn/Expressions/OperatorsExpressions.sdf: Add an ast tag.
* src/syn/Declarations.sdf: Add a pp tag.
* src/parser/parse-specs.str: Add an option.
* src/specs-to-cxx/test/test_cast.spec: Add.
* src/specs-to-cxx/Specs-to-Cxx.str: Lots of corrections.
* src/specs-to-cxx/Makefile.am,
* src/strategospecs/Makefile.am,
* Makefile.am: Update.
2004-05-05 Clement Vasseur <clement.vasseur@lrde.epita.fr>
* configure.ac: Clean the tools checks for SDF and ESDF.
......
......@@ -4,4 +4,5 @@ ACLOCAL_AMFLAGS = -I config
SUBDIRS = config src
BOOTCLEAN_SUBDIRS = src
EXTRA_DIST = bootstrap ChangeLog
XTC_IMPORT = $(STRATEGOXT)/share/strategoxt/XTC
XTC_IMPORT = $(STRATEGOXT)/share/strategoxt/XTC \
$(CXX_GRAMMAR)/share/cxx-grammar/XTC
......@@ -22,7 +22,7 @@ strategies
io-parse-specs =
xtc-io-wrap(
xtc-transform(!"sglr", !["-2", "-fi", "-s", "Start",
xtc-transform(!"sglr", !["-2", "-fi", "-s", "Start", (* XXX "-s", "Expression", XXX *)
"-p", <!"SPECS.tbl"; xtc-find> ]);
xtc-implode-asfix
)
include $(top_srcdir)/config/Makefile.xt
STRINCLUDES = -I $(top_builddir)/src/strategospecs -I $(top_builddir)/src/sig -I $(CXX_GRAMMAR)/share/cxx-grammar
STRINCLUDES = -I $(top_builddir)/src/strategospecs \
-I $(CXX_GRAMMAR)/share/cxx-grammar \
-I $(top_builddir)/src/specs-renamed #-I $(top_builddir)/src/sig
bin_PROGRAMS = Specs-to-Cxx
CLEANFILES = Specs-to-Cxx{,.c,.c.dep}
......
......@@ -6,59 +6,59 @@ imports
rules
T: |SPECS-Start[ DeclarationSeq ]| -> |TranslationUnit[ DeclarationSeq ]c++|
T: |Start{ DeclarationSeq }| -> |TranslationUnit[ DeclarationSeq ]c++|
T: |SPECS-PostfixExpression[ PostfixExpression ^ ]| -> |PostfixExpression[ ( * PostfixExpression ) ]c++|
T: |SPECS-PostfixExpression[ PostfixExpression @ ]| -> |PostfixExpression[ ( & PostfixExpression ) ]c++|
T: |PostfixExpression{ PostfixExpression ^ }| -> |PostfixExpression[ ( * PostfixExpression ) ]c++|
T: |PostfixExpression{ PostfixExpression @ }| -> |PostfixExpression[ ( & PostfixExpression ) ]c++|
TAllocationExpression: |SPECS-AllocationExpression[ UnaryExpression ]| -> |PmExpression[ UnaryExpression ]c++|
TAllocationExpression: |SPECS-AllocationExpression[ NewExpression ]| -> |PmExpression[ NewExpression ]c++|
TAllocationExpression: |SPECS-AllocationExpression[ DeleteExpression ]| -> |PmExpression[ DeleteExpression ]c++|
TAllocationExpression: |AllocationExpression{ UnaryExpression }| -> |PmExpression[ UnaryExpression ]c++|
TAllocationExpression: |AllocationExpression{ NewExpression }| -> |PmExpression[ NewExpression ]c++|
TAllocationExpression: |AllocationExpression{ DeleteExpression }| -> |PmExpression[ DeleteExpression ]c++|
TMultiplicativeExpression: |SPECS-MultiplicativeExpression[ AllocationExpression ]| -> |MultiplicativeExpression[ PmExpression ]c++|
where <debug; TAllocationExpression>AllocationExpression => PmExpression
TMultiplicativeExpression: |SPECS-MultiplicativeExpression[ MultiplicativeExpression * AllocationExpression ]|
TMultiplicativeExpression: |MultiplicativeExpression{ AllocationExpression }| -> |MultiplicativeExpression[ PmExpression ]c++|
where < TAllocationExpression > AllocationExpression => PmExpression
TMultiplicativeExpression: |MultiplicativeExpression{ MultiplicativeExpression * AllocationExpression }|
-> |MultiplicativeExpression[ MultiplicativeExpression * PmExpression ]c++|
where <debug; TAllocationExpression>AllocationExpression => PmExpression
TMultiplicativeExpression: |SPECS-MultiplicativeExpression[ MultiplicativeExpression / AllocationExpression ]|
where < TAllocationExpression > AllocationExpression => PmExpression
TMultiplicativeExpression: |MultiplicativeExpression{ MultiplicativeExpression / AllocationExpression }|
-> |MultiplicativeExpression[ MultiplicativeExpression / PmExpression ]c++|
where <debug; TAllocationExpression>AllocationExpression => PmExpression
TMultiplicativeExpression: |SPECS-MultiplicativeExpression[ MultiplicativeExpression % AllocationExpression ]|
where < TAllocationExpression > AllocationExpression => PmExpression
TMultiplicativeExpression: |MultiplicativeExpression{ MultiplicativeExpression % AllocationExpression }|
-> |MultiplicativeExpression[ MultiplicativeExpression % PmExpression ]c++|
where <debug; TAllocationExpression>AllocationExpression => PmExpression
TFundamentalType: |SPECS-FundamentalType[ char ]| -> |TypeSpecifierSeq[ char ]c++|
TFundamentalType: |SPECS-FundamentalType[ unsigned char ]| -> |TypeSpecifierSeq[ unsigned char ]c++|
TFundamentalType: |SPECS-FundamentalType[ signed char ]| -> |TypeSpecifierSeq[ signed char ]c++|
TFundamentalType: |SPECS-FundamentalType[ wchar_t ]| -> |TypeSpecifierSeq[ wchar_t ]c++|
TFundamentalType: |SPECS-FundamentalType[ bool ]| -> |TypeSpecifierSeq[ bool ]c++|
TFundamentalType: |SPECS-FundamentalType[ int ]| -> |TypeSpecifierSeq[ int ]c++|
TFundamentalType: |SPECS-FundamentalType[ unsigned int ]| -> |TypeSpecifierSeq[ unsigned int ]c++|
TFundamentalType: |SPECS-FundamentalType[ signed int ]| -> |TypeSpecifierSeq[ signed int ]c++|
TFundamentalType: |SPECS-FundamentalType[ short int ]| -> |TypeSpecifierSeq[ short int ]c++|
TFundamentalType: |SPECS-FundamentalType[ long int ]| -> |TypeSpecifierSeq[ long int ]c++|
TFundamentalType: |SPECS-FundamentalType[ short unsigned int ]| -> |TypeSpecifierSeq[ short unsigned int ]c++|
TFundamentalType: |SPECS-FundamentalType[ short signed int ]| -> |TypeSpecifierSeq[ short signed int ]c++|
TFundamentalType: |SPECS-FundamentalType[ long unsigned int ]| -> |TypeSpecifierSeq[ long unsigned int ]c++|
TFundamentalType: |SPECS-FundamentalType[ long signed int ]| -> |TypeSpecifierSeq[ long signed int ]c++|
TFundamentalType: |SPECS-FundamentalType[ float ]| -> |TypeSpecifierSeq[ float ]c++|
TFundamentalType: |SPECS-FundamentalType[ double ]| -> |TypeSpecifierSeq[ double ]c++|
TFundamentalType: |SPECS-FundamentalType[ long double ]| -> |TypeSpecifierSeq[ long double ]c++|
TFundamentalType: |SPECS-FundamentalType[ void ]| -> |TypeSpecifierSeq[ void ]c++|
TTypeID: |SPECS-TypeID[ FundamentalType ]| -> |TypeId[ TypeSpecifierSeq ]c++| where <TFundamentalType>FundamentalType => TypeSpecifierSeq
where < TAllocationExpression >AllocationExpression => PmExpression
TFundamentalType: |FundamentalType{ char }| -> |TypeSpecifierSeq[ char ]c++|
TFundamentalType: |FundamentalType{ unsigned char }| -> |TypeSpecifierSeq[ unsigned char ]c++|
TFundamentalType: |FundamentalType{ signed char }| -> |TypeSpecifierSeq[ signed char ]c++|
TFundamentalType: |FundamentalType{ wchar_t }| -> |TypeSpecifierSeq[ wchar_t ]c++|
TFundamentalType: |FundamentalType{ bool }| -> |TypeSpecifierSeq[ bool ]c++|
TFundamentalType: |FundamentalType{ int }| -> |TypeSpecifierSeq[ int ]c++|
TFundamentalType: |FundamentalType{ unsigned int }| -> |TypeSpecifierSeq[ unsigned int ]c++|
TFundamentalType: |FundamentalType{ signed int }| -> |TypeSpecifierSeq[ signed int ]c++|
TFundamentalType: |FundamentalType{ short int }| -> |TypeSpecifierSeq[ short int ]c++|
TFundamentalType: |FundamentalType{ long int }| -> |TypeSpecifierSeq[ long int ]c++|
TFundamentalType: |FundamentalType{ short unsigned int }| -> |TypeSpecifierSeq[ short unsigned int ]c++|
TFundamentalType: |FundamentalType{ short signed int }| -> |TypeSpecifierSeq[ short signed int ]c++|
TFundamentalType: |FundamentalType{ long unsigned int }| -> |TypeSpecifierSeq[ long unsigned int ]c++|
TFundamentalType: |FundamentalType{ long signed int }| -> |TypeSpecifierSeq[ long signed int ]c++|
TFundamentalType: |FundamentalType{ float }| -> |TypeSpecifierSeq[ float ]c++|
TFundamentalType: |FundamentalType{ double }| -> |TypeSpecifierSeq[ double ]c++|
TFundamentalType: |FundamentalType{ long double }| -> |TypeSpecifierSeq[ long double ]c++|
TFundamentalType: |FundamentalType{ void }| -> |TypeSpecifierSeq[ void ]c++|
TTypeID: |TypeID{ FundamentalType }| -> |TypeId[ TypeSpecifierSeq ]c++| where <TFundamentalType>FundamentalType => TypeSpecifierSeq
(*
TTypeID: |SPECS-TypeID[ RestrictedTypeID ]|
TTypeID: |TypeID{ RestrictedTypeID }|
TBracketedName: SPECS-BracketedName(p, t, e) -> TypeId()
TTypeID : SPECS-TypeID(SPECS-BracketedName()) ->
*)
T: |SPECS-PostfixExpression[ cast <[ TypeID ]> ( Expression ) ]| -> |PostfixExpression[ ( ( TypeId ) ( Expression ) ) ]c++|
T: |PostfixExpression{ cast <[ TypeID ]> ( Expression ) }| -> |PostfixExpression[ ( ( TypeId ) ( Expression ) ) ]c++|
where <TTypeID>TypeID => TypeId
(************************
T: |SPECS-FunctionDefinition[ func FuncName : FunctionSpecifier* CVQualifier? ( FuncParameters -> TypeID ) ExceptionSpecification? ]| ->
T: |FunctionDefinition{ func FuncName : FunctionSpecifier* CVQualifier? ( FuncParameters -> TypeID ) ExceptionSpecification? }| ->
|FunctionDefinition[ DeclSpecifier* TypeId FuncName ( ParameterDeclaratinClause ) CVQualifier? ExceptionSpecification? ]c++|
where <TFunSpec>FunctionSpecifier* => DeclSpecifier*
; <TFunParam>FuncParameters => ParameterDeclaratinClause
......@@ -151,4 +151,4 @@ TDeclaration: |[ func fun : specifer* ( param* -> typeid ) ]| -> |[ specifier* t
strategies
// t = T <+ all(t)
main = iowrap(bottomup(try(T + TMultiplicativeExpression)))
cast <[ int ]> ( 5 )
//{
cast <[ int ]> (5),
dynamic_cast <[ ^ char ]> ("toto"),
static_cast<[typename pouet]>(3 + 5),
reinterpret_cast <[ class s_f ]> (i),
const_cast <[ union u_e ]> (333)
//}
......@@ -2,19 +2,21 @@ include $(top_srcdir)/config/Makefile.xt
PGEN_FLAGS = -m $*
SCFLAGS = --main io-$* --verbose 0 $(XTCFLAGS) \
-I $(STRATEGO_FRONT)/share/sdf/sdf-front
SDFINCLUDES = -I $(STRATEGO_FRONT)/share/sdf/stratego-front \
-I $(top_srcdir)/src/strategospecs \
-I $(top_srcdir)/../cxx-grammar/src/strategocxx \
-I $(top_srcdir)/../cxx-grammar/src/sdf \
-I $(top_builddir)/src/specs-renamed
pkgdata_DATA = StrategoSPECS.tbl StrategoSPECS.pp StrategoSPECS.def
-I $(CXX_GRAMMAR)/share/sdf/cxx-grammar \
-I $(top_srcdir)/src/specs-renamed
SRCS = StrategoSPECSGen.str
pkgdata_DATA = StrategoSPECS.tbl StrategoSPECS.def #StrategoSPECS.pp
bin_PROGRAMS = StrategoSPECSGen
StrategoSPECS.sdf: StrategoSPECSGen.pl
./StrategoSPECSGen.pl ../syn/*.sdf ../syn/*/*.sdf > $@
EXTRA_DIST = StrategoSPECS.sdf \
SPECS-Variables.sdf \
StrategoSPECSGen.sdf
StrategoSPECS.sdf: StrategoSPECSGen ../syn/SPECS.def
sglri -p `xtc get Sdf2-Syntax.tbl` -i ../syn/SPECS.def | ./StrategoSPECSGen | pp-sdf -o $@
CLEANFILES = StrategoSPECS.* */*.sdf */*.str *.sdf
BOOTCLEANFILES = StrategoSPECSGen.c
EXTRA_DIST = $(SRCS)
CLEANFILES = StrategoSPECS.* */*.sdf */*.str *.sdf StrategoSPECSGen.c.dep
......@@ -37,7 +37,7 @@ exports
context-free syntax
Declaration+ -> DeclarationSeq
Declaration+ -> DeclarationSeq { pp(V[_1]) }
%% 7 [dcl.dcl]
BlockDeclaration -> Declaration
......@@ -57,7 +57,7 @@ exports
"obj" ObjectPrefix TypeSpecUnion -> ObjectDeclaration { cons("ObjUnionDecl"), pp(H[KW["obj"] _1 _2]) }
"obj" ObjectPrefix TypeSpecSimple -> ObjectDeclaration { cons("ObjSimplDecl"), pp(H[KW["obj"] _1 _2]) }
"obj" ObjectPrefix TypeSpecEnum -> ObjectDeclaration { cons("ObjEnumDecl"), pp(H[KW["obj"] _1 _2]) }
"type" TypeName ":" -> TypePrefix { pp(H[KW["type"] _1 KW[":"]]) }
TypePrefix TypeSpecClass -> TypeDeclaration { cons("TypeClassDecl"), pp(H[_1 _2]) }
......
......@@ -33,8 +33,8 @@ exports
%% 5.6 [expr.mul]
AllocationExpression -> MultiplicativeExpression
MultiplicativeExpression "*" AllocationExpression -> MultiplicativeExpression {cons("Mul"), pp(H[H[_1 KW["*"]] _2])}
MultiplicativeExpression "/" AllocationExpression -> MultiplicativeExpression {cons("Div"), pp(H[H[_1 KW["/"]] _2])}
MultiplicativeExpression "*" AllocationExpression -> MultiplicativeExpression {ast(Infix(Op("*", NoSig), _1, _2)), pp(H[H[_1 KW["*"]] _2])}
MultiplicativeExpression "/" AllocationExpression -> MultiplicativeExpression {ast(Infix(Op("/", NoSig), _1, _2)), pp(H[H[_1 KW["/"]] _2])}
MultiplicativeExpression "%" AllocationExpression -> MultiplicativeExpression {cons("Mod"), pp(H[H[_1 KW["%"]] _2])}
%% 5.7 [expr.add]
......@@ -102,7 +102,7 @@ exports
"!:=" -> AssignmentOperator
%% 5.18 [expr.comma]
{ AssignmentExpression "," }+ -> Expression {pp(HV[_1], .1:iter-sep=H hs=0[_1 KW[","]])}
{ AssignmentExpression "," }+ -> Expression {cons("Exp") ,pp(HV[_1], .1:iter-sep=H hs=0[_1 KW[","]])}
%% 5.19 [expr.const]
ConditionalExpression -> ConstantExpression
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment