From: Maxime van Noppen <yabo(a)lrde.epita.fr>
To: transformers-patches(a)lrde.epita.fr, olena-patches(a)lrde.epita.fr
Subject: scool r127: Handle typedefs
URL:
https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-11-12 Maxime van Noppen <yabo(a)lrde.epita.fr>
Handle typedefs.
* pp-cxx/CxxFun.str: Fix pretty print of identifiers.
* scl-syn/Declaration.sdf: Add the grammar entry for typedefs.
* scoolt/Declaration.str: Traduce the scool typedef into a C++
* typedef.
---
pp-cxx/CxxFun.str | 2 +-
scl-syn/Declaration.sdf | 10 +++++++---
scoolt/Declaration.str | 12 ++++++++++++
3 files changed, 20 insertions(+), 4 deletions(-)
Index: branches/scool-ng/src/pp-cxx/CxxFun.str
===================================================================
--- branches/scool-ng/src/pp-cxx/CxxFun.str (revision 126)
+++ branches/scool-ng/src/pp-cxx/CxxFun.str (revision 127)
@@ -50,7 +50,7 @@
CxxTopLevelToAbox:
CxxTypedef(t, idf) ->
- H hs=0 [ H hs=1 [ "typedef" ~<CxxTypeToAbox> t ~S(idf)] ";" ]
+ H hs=0 [ H hs=1 [ "typedef" ~<CxxTypeToAbox> t ~<CxxIdToAbox> idf]
";" ]
CxxArgDefToAbox:
(t, idf) ->
Index: branches/scool-ng/src/scoolt/Declaration.str
===================================================================
--- branches/scool-ng/src/scoolt/Declaration.str (revision 126)
+++ branches/scool-ng/src/scoolt/Declaration.str (revision 127)
@@ -91,6 +91,7 @@
where
<ClassWhereClauseToCxx(|cqualif, idf, body)> wclause => cxx_code
+
////////////////////////////////////////////////////////////////////////////////
// Static functions //
////////////////////////////////////////////////////////////////////////////////
@@ -99,3 +100,14 @@
StaticClassFunction(idf, params, cqualif, StaticClassBlock(body)) -> cxx_code
where
<StaticClassFunctionToCxx(|cqualif, idf, params, body)> [] => cxx_code
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Static functions //
+ ////////////////////////////////////////////////////////////////////////////////
+
+ DeclarationToCxx:
+ TypeDefinition(tqualif, idf, StaticInitialiser(type)) -> CxxTypedef(cxx_type,
cxx_idf)
+ where
+ <IdentifierToCxx> idf => cxx_idf
+ ; <TypeToCxx> type => cxx_type
Index: branches/scool-ng/src/scl-syn/Declaration.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Declaration.sdf (revision 126)
+++ branches/scool-ng/src/scl-syn/Declaration.sdf (revision 127)
@@ -4,7 +4,7 @@
Lexical Type Statement Expression Class
exports
- sorts Declaration Block FunctionBlock SimpleDeclaration StaticFunction
+ sorts Declaration Block FunctionBlock SimpleDeclaration StaticFunction
ExpressionInitialiser StaticExpressionInitialiser
context-free syntax
StaticFunction -> Declaration
@@ -17,10 +17,14 @@
"{" StaticStatement* "}" -> StaticBlock
{cons("StaticBlock")}
"{" StaticClassStatement* "}" -> StaticClassBlock
{cons("StaticClassBlock")}
- "=" Expression -> Initialiser {cons("Initialiser")}
+ "=" Expression -> ExpressionInitialiser
{cons("Initialiser")}
+ "=" StaticExpression -> StaticExpressionInitialiser
{cons("StaticInitialiser")}
- SimpleQualifier? Identifier ":" SimpleType Initialiser? ";"
-> SimpleDeclaration {cons("SimpleDeclaration")}
+ SimpleQualifier? Identifier ":" SimpleType ExpressionInitialiser?
";" -> SimpleDeclaration {cons("SimpleDeclaration")}
+
+ SimpleQualifier? Identifier ":" "type" ";"
-> SimpleDeclaration {cons("TypeDeclaration")}
+ SimpleQualifier? Identifier ":" "type"
StaticExpressionInitialiser ";" -> SimpleDeclaration
{cons("TypeDefinition")}
FunctionQualifier? Identifier ":" FunctionType ";" ->
Declaration {cons("FunctionDeclaration")}