URL:
https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-10-08 Maxime van Noppen <yabo(a)lrde.epita.fr>
Work on static inheritance
* pp-cxx/CxxDecl.str: Insert a space before the ':' used to declare an
* inheritance relationship.
* pp-cxx/CxxType.str: Handle int as parameters and ensure that '<' and
* '>' always have spaces around them to avoid ambiguities.
* scl-syn/Class.sdf: Allow inheritance from static expressions rather
* than only ids.
* scl-syn/Expression.sdf: Resolve and ambiguity when parsing static
* expressions.
* scoolt/Class.str: Add the exact parameter when needed.
pp-cxx/CxxDecl.str | 8 ++++----
pp-cxx/CxxType.str | 9 ++++++++-
scl-syn/Class.sdf | 2 +-
scl-syn/Expression.sdf | 2 +-
scoolt/Class.str | 4 ++--
5 files changed, 16 insertions(+), 9 deletions(-)
Index: branches/scool-ng/src/pp-cxx/CxxFun.str
===================================================================
Index: branches/scool-ng/src/pp-cxx/CxxDecl.str
===================================================================
--- branches/scool-ng/src/pp-cxx/CxxDecl.str (revision 110)
+++ branches/scool-ng/src/pp-cxx/CxxDecl.str (revision 111)
@@ -41,7 +41,7 @@
";"
]
]
-
+/*
CxxTopLevelToAbox:
CxxClassDecl(params, idf, parents) ->
V vs=0 [
@@ -52,7 +52,7 @@
";"
]
]
-
+*/
CxxTopLevelToAbox:
CxxComment(txt) ->
H hs=1 [ "//" ~S(txt) ]
@@ -70,8 +70,8 @@
CxxClassDecl(params, idf, parents, body) ->
V vs=0 [
~<CxxParamsToAbox> params
- H hs=0 [
- H hs=1 [ "class" ~<CxxIdToAbox> idf ]
+ H hs=1 [
+ "class" ~<CxxIdToAbox> idf
~<CxxParentsToAbox> parents
]
V vs=0 is=2 [ "{" V vs=0 [ ~*<map (CxxBodyToAbox <+
CxxTopLevelToAbox)> body ] ]
Index: branches/scool-ng/src/pp-cxx/CxxType.str
===================================================================
--- branches/scool-ng/src/pp-cxx/CxxType.str (revision 110)
+++ branches/scool-ng/src/pp-cxx/CxxType.str (revision 111)
@@ -5,6 +5,9 @@
rules
CxxTypeToAbox:
+ CxxId(idf) -> S(idf)
+
+ CxxTypeToAbox:
CxxType(idf) -> <CxxIdToAbox> idf
CxxTypeToAbox:
@@ -14,7 +17,7 @@
CxxRefType(t) -> H hs=0 [ ~<CxxTypeToAbox> t "&" ]
CxxTypeToAbox:
- CxxType(idf, params) -> H hs=0 [ ~<CxxIdToAbox> idf "<"
~<CxxListToAbox(CxxTypeToAbox|",")> params ">" ]
+ CxxType(idf, params) -> H hs=0 [ ~<CxxIdToAbox> idf H hs=1 [ "<"
~<CxxListToAbox(CxxTypeToAbox|",")> params ">" ] ]
CxxTypeToAbox:
CxxConstType(t) -> H [ "const" ~<CxxTypeToAbox> t]
@@ -30,3 +33,7 @@
CxxTypeToAbox:
CxxTypename(t) -> H hs=1 [ "typename" ~<CxxTypeToAbox> t ]
+
+ // An int can be a template parameter
+ CxxTypeToAbox:
+ CxxInt(i) -> S(i)
Index: branches/scool-ng/src/scoolt/Class.str
===================================================================
--- branches/scool-ng/src/scoolt/Class.str (revision 110)
+++ branches/scool-ng/src/scoolt/Class.str (revision 111)
@@ -52,7 +52,7 @@
AddExactParameter(| cqualif, cxx_idf):
SimpleType(type) -> cxx_class
where
- <ExactParameter(| cqualif, cxx_idf)> [] => params
+ <ExactParameter(| cqualif, cxx_idf)> "x" => params
; <StaticExpressionToCxx> StaticFunctionCall(Identifier(type),
Parameters([params])) => cxx_class
AddExactParameter(| cqualif, cxx_idf):
@@ -85,7 +85,7 @@
// FIXME: allow other inheritances than the public one
InheritanceToCxx(| cqualif, cxx_idf):
- mother -> ("public", cxx_mother)
+ mother -> [("public", cxx_mother)]
where
<AddExactParameter(| cqualif, cxx_idf)> mother => cxx_mother
Index: branches/scool-ng/src/scl-syn/Class.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Class.sdf (revision 110)
+++ branches/scool-ng/src/scl-syn/Class.sdf (revision 111)
@@ -17,7 +17,7 @@
"where" {ClassCondition ";"}* -> ClassWhereClause
{cons("ClassWhereClause")}
- Id "->" Id -> ClassCondition {cons("Inherits")}
+ Id "->" StaticExpression -> ClassCondition {cons("Inherits")}
lexical restrictions
Index: branches/scool-ng/src/scl-syn/Expression.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Expression.sdf (revision 110)
+++ branches/scool-ng/src/scl-syn/Expression.sdf (revision 111)
@@ -18,7 +18,7 @@
"(" {Expression ","}* ")" ->
Arguments {cons("Arguments")}
Identifier Parameters ->
StaticFunctionCall {cons("StaticFunctionCall")}
- StaticFunctionCall -> StaticExpression
+ StaticFunctionCall -> StaticExpression {prefer}
Identifier Parameters? Arguments ->
Expression {cons("FunctionCall")}
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ \_____)