URL:
https://svn.lrde.epita.fr/svn/scool/trunk
ChangeLog:
2008-03-12 Maxime van Noppen <yabo(a)lrde.epita.fr>
Improve verbatim C++ handling
* pp-cxx/CxxExp.str: Handle more Cxx constructors.
* pp-cxx/CxxStm.str: Fix the double semicolon problem
when inserting verbatim C++.
* pp-cxx/CxxDecl.str: Remove a FIXME comment.
* scoolt/Exp.str: Improve verbatim C++ handling.
pp-cxx/CxxDecl.str | 2 --
pp-cxx/CxxExp.str | 33 +++++++++++++++++++++------------
pp-cxx/CxxStm.str | 12 +++++++++++-
scoolt/Decl.str | 1 +
scoolt/Exp.str | 10 +++++++++-
5 files changed, 42 insertions(+), 16 deletions(-)
Index: trunk/src/pp-cxx/CxxFun.str
===================================================================
Index: trunk/src/pp-cxx/CxxExp.str
===================================================================
--- trunk/src/pp-cxx/CxxExp.str (revision 51)
+++ trunk/src/pp-cxx/CxxExp.str (revision 52)
@@ -4,8 +4,14 @@
rules
- CxxExpToAbox:
- CxxInt(i) -> S(i)
+ CxxArgListToStr:
+ [ e | [h|tail] ] -> <concat-strings> [ e, ", ",
<CxxArgListToStr> [h|tail] ]
+
+ CxxArgListToStr:
+ [e | []] -> e
+
+ CxxArgListToStr:
+ [] -> ""
CxxExpToStr:
CxxInt(i) -> i
@@ -14,18 +20,21 @@
CxxSum(e1, e2) -> <concat-strings> [<CxxExpToStr> e1, " + ",
<CxxExpToStr> e2]
CxxExpToStr:
+ CxxKeyword(idf, exp) -> <concat-strings> [idf, " ",
<CxxExpToStr> exp]
+
+ CxxExpToStr:
+ CxxAffect(idf, exp) -> <concat-strings> [idf, " = ",
<CxxExpToStr> exp]
+
+ CxxExpToStr:
+ CxxFunCall(idf, args) -> <concat-strings> [ idf, "(",
<CxxArgListToStr> args, ")" ]
+
+ CxxExpToStr:
+ CxxProgram(exp) -> exp
+
+ CxxExpToStr:
x -> x
where <is-string> x
- /*
- * Handle the CxxKeyword ctor.
- * TODO: Generalize the type of exp.
- */
CxxExpToAbox:
- CxxKeyword(idf, exp) -> S(<concat-strings> [idf, " ",
<CxxExpToStr> exp, ";"])
+ x -> S(<CxxExpToStr> x)
- CxxExpToAbox:
- CxxAffect(idf, exp) -> S(<concat-strings> [idf, " = ",
<CxxExpToStr> exp, ";"])
-
- CxxExpToAbox:
- x -> S(x)
Index: trunk/src/pp-cxx/CxxStm.str
===================================================================
--- trunk/src/pp-cxx/CxxStm.str (revision 51)
+++ trunk/src/pp-cxx/CxxStm.str (revision 52)
@@ -5,4 +5,14 @@
rules
CxxStmToAbox:
- CxxExpStm(e) -> <CxxExpToAbox> e
+ CxxExpStm(e) -> H hs=0 [ ~<CxxExpToAbox> e ~<Semicolon> e]
+
+ // Don't add an extra ';' to verbatim C++ that we insert.
+ // As said on
https://trac.lrde.org/scool/wiki/SCOOL/Specs/Misc the C++ inserted
+ // must be valid and so contain an ending ';'
+ Semicolon:
+ _#([_, CxxProgram(exp)]) -> S("")
+
+ Semicolon:
+ _#([_, _]) -> S(";")
+
Index: trunk/src/pp-cxx/CxxDecl.str
===================================================================
--- trunk/src/pp-cxx/CxxDecl.str (revision 51)
+++ trunk/src/pp-cxx/CxxDecl.str (revision 52)
@@ -45,8 +45,6 @@
CxxComment(txt) ->
H hs=1 [ "//" ~S(txt) ]
-// FIXME: MERGE!!!
-
CxxBodyToAbox:
CxxPublic(b) -> V is=2 [ "public:" V [ ~*<map(CxxTopLevelToAbox)> b
] ]
Index: trunk/src/scoolt/Exp.str
===================================================================
--- trunk/src/scoolt/Exp.str (revision 51)
+++ trunk/src/scoolt/Exp.str (revision 52)
@@ -8,6 +8,9 @@
Int(i) -> CxxInt(i)
ExpToCxx:
+ String(s) -> <un-double-quote> s
+
+ ExpToCxx:
Var(v) -> v
ExpToCxx:
@@ -18,4 +21,9 @@
where <debug> e
ExpToCxx:
- Cxx(s) -> s
+ Cxx(s) -> CxxProgram(s)
+
+ ExpToCxx:
+ FunCall(name, args) -> CxxFunCall(name, <map (ExpToCxx)> args)
+
+
Index: trunk/src/scoolt/Decl.str
===================================================================
--- trunk/src/scoolt/Decl.str (revision 51)
+++ trunk/src/scoolt/Decl.str (revision 52)
@@ -197,6 +197,7 @@
! (CxxType(t), idf)
end>
+
ArgDefToCxx:
(idf, t) -> (<TypeToConstRefCxx <+ TypeToCxx> t, idf)
//(idf, t) -> (<TypeToCxx; try(CxxTypeToStc(|CxxType(p-idf)))> t, idf)
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ Président de Prologin \_____)