From: Maxime van Noppen <yabo(a)lrde.epita.fr>
To: transformers-patches(a)lrde.epita.fr, olena-patches(a)lrde.epita.fr
Subject: scool r125: Start work on static functions
URL:
https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-10-31 Maxime van Noppen <yabo(a)lrde.epita.fr>
Start work on static functions.
* scl-syn/Lexical.sdf: Fix typo.
* scoolt/Class.str: Fix typos and handle the StaticClassFunction
constructor (work still in progress).
* scl-syn/Declaration.sdf:
* scoolt/Declaration.str: Change the place of the class qualifiers
to be more coherent with Scool's philosphy.
---
scl-syn/Declaration.sdf | 6 +++---
scl-syn/Lexical.sdf | 2 +-
scoolt/Class.str | 15 +++++++++++++--
scoolt/Declaration.str | 15 ++++++++++++---
4 files changed, 29 insertions(+), 9 deletions(-)
Index: branches/scool-ng/src/scoolt/Class.str
===================================================================
--- branches/scool-ng/src/scoolt/Class.str (revision 124)
+++ branches/scool-ng/src/scoolt/Class.str (revision 125)
@@ -79,13 +79,13 @@
<? None()> cqualif
CheckDaughter(| scl_idf):
- daughter -> 42 // The result isn't used
+ daughter -> 42 // The result isn't used, should this be a strategy ?
where
<?Identifier(idf)> scl_idf
; <eq> (daughter, idf)
CheckDaughter(| scl_idf):
- daughter -> <say(<concat-strings> [ "Error: class name
\"", daughter, "\" doest not match with \"", idf,
"\"" ]); fail>
+ daughter -> <say(<concat-strings> [ "Error: class name
\"", daughter, "\" does not match with \"", idf,
"\"" ]); fail>
where
<?Identifier(idf)> scl_idf
@@ -114,6 +114,17 @@
; <IdentifierToCxx> idf => cxx_idf
; <InheritanceToCxx(| cqualif, cxx_idf)> mother => cxx_mother
+
+ // Handle static class functions
+
+ StaticClassFunctionToCxx(|cqualif, idf, params, body):
+ _ -> CxxClassDecl(cxx_params, cxx_idf, [], cxx_body)
+ where
+ <IdentifierToCxx> idf => cxx_idf
+ ; <AddExactType(| cqualif)> <ParametersToCxx> params => cxx_params //
FIXME: cqualif is rather a qualifier of the function than the returned class
+ ; ![] => cxx_body
+
+
strategies
ClassInit = rules(IsInClass: _ -> 0)
Index: branches/scool-ng/src/scoolt/Declaration.str
===================================================================
--- branches/scool-ng/src/scoolt/Declaration.str (revision 124)
+++ branches/scool-ng/src/scoolt/Declaration.str (revision 125)
@@ -68,7 +68,7 @@
////////////////////////////////////////////////////////////////////////////////
DeclarationToCxx:
- ClassDeclaration(cqualif, idf, _) -> CxxClassDecl(cxx_params, cxx_idf, [])
+ ClassDeclaration(idf, cqualif, _) -> CxxClassDecl(cxx_params, cxx_idf, [])
where
<AddExactType(|cqualif)> [] => cxx_params
; <IdentifierToCxx> idf => cxx_idf
@@ -79,14 +79,23 @@
DeclarationToCxx:
- ClassDefinition(cqualif, idf, None(), ClassBlock(body)) ->
CxxClassDecl(cxx_params, cxx_idf, [], cxx_body)
+ ClassDefinition(idf, cqualif, None(), ClassBlock(body)) ->
CxxClassDecl(cxx_params, cxx_idf, [], cxx_body)
where
<AddExactType(|cqualif)> [] => cxx_params
; <IdentifierToCxx> idf => cxx_idf
; <ClassBodyToCxx> body => cxx_body
+// FIXME: handle multiple where clauses
DeclarationToCxx:
- ClassDefinition(cqualif, idf, Some(ClassWhereClause([wclause])), ClassBlock(body))
-> cxx_code
+ ClassDefinition(idf, cqualif, Some(ClassWhereClause([wclause])), ClassBlock(body))
-> cxx_code
where
<ClassWhereClauseToCxx(|cqualif, idf, body)> wclause => cxx_code
+ ////////////////////////////////////////////////////////////////////////////////
+ // Static functions //
+ ////////////////////////////////////////////////////////////////////////////////
+
+ DeclarationToCxx:
+ StaticClassFunction(idf, params, cqualif, StaticClassBlock(body)) -> cxx_code
+ where
+ <StaticClassFunctionToCxx(|cqualif, idf, params, body)> [] => cxx_code
Index: branches/scool-ng/src/scl-syn/Declaration.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Declaration.sdf (revision 124)
+++ branches/scool-ng/src/scl-syn/Declaration.sdf (revision 125)
@@ -27,7 +27,7 @@
FunctionQualifier? Identifier ":" FunctionType "=" FunctionBlock
-> Declaration {cons("FunctionDefinition")}
Identifier ":" ParametersDeclaration "->" "type"
"=" StaticBlock -> StaticFunction
{cons("StaticTypeFunction")}
- ClassQualifier? Identifier ":" ParametersDeclaration "->"
"class" "=" StaticClassBlock -> StaticFunction
{cons("StaticClassFunction")}
+ Identifier ":" ParametersDeclaration "->" ClassQualifier?
"class" "=" StaticClassBlock -> StaticFunction
{cons("StaticClassFunction")}
- ClassQualifier? Identifier ":" "class" ClassWhereClause?
";" -> Declaration {cons("ClassDeclaration")}
- ClassQualifier? Identifier ":" "class" ClassWhereClause?
"=" ClassBlock -> Declaration {cons("ClassDefinition")}
+ Identifier ":" ClassQualifier? "class" ClassWhereClause?
";" -> Declaration {cons("ClassDeclaration")}
+ Identifier ":" ClassQualifier? "class" ClassWhereClause?
"=" ClassBlock -> Declaration {cons("ClassDefinition")}
Index: branches/scool-ng/src/scl-syn/Lexical.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Lexical.sdf (revision 124)
+++ branches/scool-ng/src/scl-syn/Lexical.sdf (revision 125)
@@ -29,7 +29,7 @@
"var" -> SimpleQualifier
"final" -> ClassQualifier
- "abtract" -> ClassQualifier
+ "abstract" -> ClassQualifier
"models" -> TypeQualifier
"abtract" -> FunctionQualifier
"mutable" -> FunctionQualifier