URL:
https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-09-17 Maxime van Noppen <yabo(a)lrde.epita.fr>
Handle templates in function calls
* scoolt/Expression.str: Factorize code and handle static expressions.
* scoolt/Declaration.str: Handle templates in function calls.
* scoolt/Function.str: Handle templates.
* cxx-syn/CxxExp.sdf: Add grammar for templates in function calls
* scl-syn/Expression.sdf: Use simpler constructor names.
* scl-syn/Type.sdf,
* scl-syn/Lexical.sdf: Factorize reject rules.
cxx-syn/CxxExp.sdf | 3 ++-
scl-syn/Expression.sdf | 11 ++++++-----
scl-syn/Lexical.sdf | 31 ++++++++++++++++---------------
scl-syn/Type.sdf | 13 +------------
scoolt/Declaration.str | 6 +++---
scoolt/Expression.str | 30 ++++++++++++++++++++++++++----
scoolt/Function.str | 14 +++++++++++++-
7 files changed, 67 insertions(+), 41 deletions(-)
Index: branches/scool-ng/src/scoolt/Expression.str
===================================================================
--- branches/scool-ng/src/scoolt/Expression.str (revision 85)
+++ branches/scool-ng/src/scoolt/Expression.str (revision 86)
@@ -7,14 +7,25 @@
IdentifierToCxx:
Identifier(idf) -> CxxId(idf)
- ExpressionToCxx:
+
+ BaseExpressionToCxx:
idf -> cxx_idf
where
<IdentifierToCxx> idf => cxx_idf
- ExpressionToCxx:
+ BaseExpressionToCxx:
Integer(int) -> CxxInt(int)
+
+
+ ExpressionToCxx:
+ bexp -> cxx_bexp
+ where
+ <BaseExpressionToCxx> bexp => cxx_bexp
+
+ ExpressionToCxx:
+ String(str) -> <un-double-quote> str
+
ExpressionToCxx:
// |[ ~exp:e1 + ~exp:e2; ]| -> CxxSum(cxx_e1, cxx_e2)
Sum(e1, e2) -> CxxSum(cxx_e1, cxx_e2)
@@ -23,7 +34,18 @@
; <ExpressionToCxx> e2 => cxx_e2
ExpressionToCxx:
- FunctionCall(idf, params, args) -> CxxFunCall(cxx_idf, cxx_args)
+ FunctionCall(idf, params, args) -> CxxFunCall(cxx_params, cxx_idf, cxx_args)
where
<IdentifierToCxx> idf => cxx_idf
- ; <ArgumentsToCxx> args => cxx_args // FIXME
+ ; <ParametersToCxx> params => cxx_params
+ ; <ArgumentsToCxx> args => cxx_args
+
+
+
+ StaticExpressionToCxx:
+ bexp -> cxx_bexp
+ where
+ <BaseExpressionToCxx> bexp => cxx_bexp
+
+ StaticExpressionToCxx:
+ SimpleType(type) -> CxxType(type)
Index: branches/scool-ng/src/scoolt/Declaration.str
===================================================================
--- branches/scool-ng/src/scoolt/Declaration.str (revision 85)
+++ branches/scool-ng/src/scoolt/Declaration.str (revision 86)
@@ -50,10 +50,10 @@
; <ArgumentsToCxx> <GetArguments> fun_type => cxx_args
DeclarationToCxx:
- |[ ~idf : ~ftype:fun_type = { ~fbody:body } ]| -> CxxFun([], cxx_ret_type,
cxx_idf, cxx_args, cxx_body)
+ |[ ~idf : ~ftype:fun_type = { ~fbody:body } ]| -> CxxFun(cxx_params, cxx_ret_type,
cxx_idf, cxx_args, cxx_body)
where
- <?FunctionType(None(), _, _)> fun_type // Ensure that there is no parameters
- ; <IdentifierToCxx> idf => cxx_idf
+ <IdentifierToCxx> idf => cxx_idf
; <TypeToCxx> <GetReturnType> fun_type => cxx_ret_type
+ ; <ParametersToCxx> <GetParameters> fun_type => cxx_params
; <ArgumentsToCxx> <GetArguments> fun_type => cxx_args
; <map (DeclarationToCxx <+ FunctionStatementToCxx) <+ ExpressionToCxx>
body => cxx_body
Index: branches/scool-ng/src/scoolt/Function.str
===================================================================
--- branches/scool-ng/src/scoolt/Function.str (revision 85)
+++ branches/scool-ng/src/scoolt/Function.str (revision 86)
@@ -23,11 +23,12 @@
// Convert parameters (templates)
+ // Parameters in function declarations
ParametersToCxx:
None() -> []
ParametersToCxx:
- ParametersDeclaration(param_list) -> <map (ParameterToCxx)> param_list
+ ParametersDeclaration(params) -> <map (ParameterToCxx)> params
ParameterToCxx:
TypedId(idf, type) -> (cxx_type, cxx_idf)
@@ -35,9 +36,16 @@
<IdentifierToCxx> idf => cxx_idf
; <TypeToCxx> type => cxx_type
+ // Parameters in function calls
+ ParametersToCxx:
+ Some(Parameters(params)) -> <map (StaticExpressionToCxx)> params
+
+
+
// Convert arguments
+ // Arguments in function declarations
ArgumentsToCxx:
ArgumentsDeclaration(arg_list) -> <map (ArgumentToCxx)> arg_list
@@ -48,6 +56,10 @@
; <IdentifierToCxx> idf => cxx_idf
+ // Arguments in function calls
+ ArgumentsToCxx:
+ Arguments(args) -> <map (ExpressionToCxx)> args
+
// Convert function statements
Index: branches/scool-ng/src/scl-syn/Expression.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Expression.sdf (revision 85)
+++ branches/scool-ng/src/scl-syn/Expression.sdf (revision 86)
@@ -8,18 +8,19 @@
context-free syntax
Id -> Expression {cons("Identifier")}
- Id -> StaticExpression {cons("Identifier")}
Integer -> Expression {cons("Integer")}
+ Integer -> StaticExpression {cons("Integer")}
String -> Expression {cons("String")}
- "[" {StaticExpression ","}* "]" ->
StaticArguments {cons("StaticArguments")}
- "(" {Expression ","}* ")" ->
DynamicArguments {cons("DynamicArguments")}
+ SimpleType -> StaticExpression
+ "[" {StaticExpression ","}* "]" ->
Parameters {cons("Parameters")}
+ "(" {Expression ","}* ")" ->
Arguments {cons("Arguments")}
- Identifier StaticArguments ->
StaticFunctionCall {cons("StaticFunctionCall")}
+ Identifier Parameters ->
StaticFunctionCall {cons("StaticFunctionCall")}
StaticFunctionCall -> StaticExpression
- Identifier StaticArguments? DynamicArguments ->
Expression {cons("FunctionCall")}
+ Identifier Parameters? Arguments ->
Expression {cons("FunctionCall")}
Expression "+" Expression -> Expression {cons("Sum")}
Expression "-" Expression ->
Expression {cons("Substraction")}
Index: branches/scool-ng/src/scl-syn/Lexical.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Lexical.sdf (revision 85)
+++ branches/scool-ng/src/scl-syn/Lexical.sdf (revision 86)
@@ -26,6 +26,7 @@
[\/] -> Slash
[\*] -> Asterisk
+
"var" -> SimpleQualifier
"final" -> ClassQualifier
"models" -> TypeQualifier
@@ -33,20 +34,23 @@
"decl" -> FunctionQualifier
"abtract" -> MethodQualifier
- context-free syntax
+ "class" -> Keyword
+ "concept" -> Keyword
+ "var" -> Keyword
+ "final" -> Keyword
+ "models" -> Keyword
+ "type" -> Keyword
+ "ref" -> Keyword
+ "public" -> Keyword
+ "protected" -> Keyword
+ "private" -> Keyword
+ "where" -> Keyword
+
+ context-free syntax
- "class" -> Identifier {reject}
- "concept" -> Identifier {reject}
- "var" -> Identifier {reject}
- "final" -> Identifier {reject}
- "models" -> Identifier {reject}
- "type" -> Identifier {reject}
- "ref" -> Identifier {reject}
- "public" -> Identifier {reject}
- "protected" -> Identifier {reject}
- "private" -> Identifier {reject}
- "where" -> Identifier {reject}
+ Id -> Identifier {cons("Identifier")}
+ Keyword -> Identifier {reject}
"char" -> Identifier {reject}
"int" -> Identifier {reject}
@@ -54,9 +58,6 @@
"string" -> Identifier {reject}
"void" -> Identifier {reject}
-
- Id -> Identifier {cons("Identifier")}
-
lexical restrictions
Id -/- [A-Za-z0-9\_]
Asterisk -/- [\/]
Index: branches/scool-ng/src/scl-syn/Type.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Type.sdf (revision 85)
+++ branches/scool-ng/src/scl-syn/Type.sdf (revision 86)
@@ -29,15 +29,4 @@
ParametersDeclaration? ArgumentsDeclaration "->" Type ->
FunctionType {cons("FunctionType")}
- "class" -> SimpleType {reject}
- "type" -> SimpleType {reject}
- "concept" -> SimpleType {reject}
- "var" -> SimpleType {reject}
- "final" -> SimpleType {reject}
- "models" -> SimpleType {reject}
- "type" -> SimpleType {reject}
- "ref" -> SimpleType {reject}
- "public" -> SimpleType {reject}
- "protected" -> SimpleType {reject}
- "private" -> SimpleType {reject}
- "where" -> SimpleType {reject}
+ Keyword -> SimpleType {reject}
Index: branches/scool-ng/src/cxx-syn/CxxExp.sdf
===================================================================
--- branches/scool-ng/src/cxx-syn/CxxExp.sdf (revision 85)
+++ branches/scool-ng/src/cxx-syn/CxxExp.sdf (revision 86)
@@ -8,7 +8,8 @@
context-free syntax
CxxInt -> CxxExp {cons("CxxInt")}
- CxxId "(" {CxxExp ","}* ")" ->
CxxExp {cons("CxxFunCall")}
+ CxxId "<" {CxxType ","}* ">" "(" {CxxExp
","}* ")" -> CxxExp {cons("CxxFunCall")}
+ CxxId "<" {CxxInt ","}* ">" "(" {CxxExp
","}* ")" -> CxxExp {cons("CxxFunCall")}
CxxId CxxExp ";" -> CxxExp {cons("CxxKeyword")}
CxxExp "+" CxxExp -> CxxExp {cons("CxxSum")}
"&" CxxExp -> CxxExp {cons("CxxAdressOf")}
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ \_____)