URL:
https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-09-16 Maxime van Noppen <yabo(a)lrde.epita.fr>
Handle function parameters
* src/scoolt/Declaration.str: Handle function parameters.
* src/scoolt/Function.str: Convert parameters.
* src/scoolt/Type.str: Handle the "type" keyword.
Declaration.str | 5 +++--
Function.str | 37 +++++++++++++++++++++++++++++++++++--
Type.str | 3 +++
3 files changed, 41 insertions(+), 4 deletions(-)
Index: branches/scool-ng/src/scoolt/Type.str
===================================================================
--- branches/scool-ng/src/scoolt/Type.str (revision 83)
+++ branches/scool-ng/src/scoolt/Type.str (revision 84)
@@ -15,6 +15,9 @@
<+ <eq> (type, "double")
TypeToCxx:
+ "type" -> CxxType("typename")
+
+ TypeToCxx:
SimpleType(type) -> CxxType(type)
TypeToCxx:
Index: branches/scool-ng/src/scoolt/Declaration.str
===================================================================
--- branches/scool-ng/src/scoolt/Declaration.str (revision 83)
+++ branches/scool-ng/src/scoolt/Declaration.str (revision 84)
@@ -42,16 +42,17 @@
////////////////////////////////////////////////////////////////////////////////
DeclarationToCxx:
- |[ ~idf : ~ftype:fun_type; ]| -> CxxFun([], cxx_ret_type, cxx_idf, cxx_args)
+ |[ ~idf : ~ftype:fun_type; ]| -> CxxFun(cxx_params, cxx_ret_type, cxx_idf,
cxx_args)
where
<IdentifierToCxx> idf => cxx_idf
; <TypeToCxx> <GetReturnType> fun_type => cxx_ret_type
+ ; <ParametersToCxx> <GetParameters> fun_type => cxx_params
; <ArgumentsToCxx> <GetArguments> fun_type => cxx_args
DeclarationToCxx:
|[ ~idf : ~ftype:fun_type = { ~fbody:body } ]| -> CxxFun([], cxx_ret_type,
cxx_idf, cxx_args, cxx_body)
where
- <?FunctionType(None(), _, _)> fun_type // Ensure there are no parameters
+ <?FunctionType(None(), _, _)> fun_type // Ensure that there is no parameters
; <IdentifierToCxx> idf => cxx_idf
; <TypeToCxx> <GetReturnType> fun_type => cxx_ret_type
; <ArgumentsToCxx> <GetArguments> fun_type => cxx_args
Index: branches/scool-ng/src/scoolt/Function.str
===================================================================
--- branches/scool-ng/src/scoolt/Function.str (revision 83)
+++ branches/scool-ng/src/scoolt/Function.str (revision 84)
@@ -4,12 +4,40 @@
rules
- GetReturnType:
- FunctionType(_, _, ret_type) -> ret_type
+ // Extract data from a FunctionType
+
+ GetParameters:
+ FunctionType(None(), _, _) -> None()
+
+ GetParameters:
+ FunctionType(Some(params), _, _) -> params
GetArguments:
FunctionType(_, args, _) -> args
+ GetReturnType:
+ FunctionType(_, _, ret_type) -> ret_type
+
+
+
+
+ // Convert parameters (templates)
+
+ ParametersToCxx:
+ None() -> []
+
+ ParametersToCxx:
+ ParametersDeclaration(param_list) -> <map (ParameterToCxx)> param_list
+
+ ParameterToCxx:
+ TypedId(idf, type) -> (cxx_type, cxx_idf)
+ where
+ <IdentifierToCxx> idf => cxx_idf
+ ; <TypeToCxx> type => cxx_type
+
+
+ // Convert arguments
+
ArgumentsToCxx:
ArgumentsDeclaration(arg_list) -> <map (ArgumentToCxx)> arg_list
@@ -19,6 +47,11 @@
<TypeToConstRefCxx <+ TypeToCxx> type => cxx_type
; <IdentifierToCxx> idf => cxx_idf
+
+
+
+ // Convert function statements
+
FunctionStatementToCxx:
ReturnStatement(exp) -> CxxExpStm(CxxKeyword("return", cxx_exp))
where
Property changes on: branches/scool-ng
___________________________________________________________________
Name: mailto
- transformers-patches(a)lrde.epita.fr
olena-patches(a)lrde.epita.fr
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ \_____)