From: Maxime van Noppen <yabo(a)lrde.epita.fr>
To: transformers-patches(a)lrde.epita.fr, olena-patches(a)lrde.epita.fr
Subject: scool r123: Fix the way verbatim C++ is handled
URL:
https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-10-30 Maxime van Noppen <yabo(a)lrde.epita.fr>
Fix the way verbatim C++ is handled.
* pp-cxx/CxxDecl.str: Handle the CxxProgram constructor.
* scl-syn/Lexical.sdf: Fix an ambiguity on layout.
* scl-syn/Statement.sdf: Add verbatim C++ as statements.
* scoolt/Expression.str: Don't un-double-quote strings.
* scoolt/Statement.str: Handle the CxxProgram constructor as a
declaration.
---
pp-cxx/CxxDecl.str | 3 +++
scl-syn/Lexical.sdf | 1 +
scl-syn/Statement.sdf | 4 ++++
scoolt/Expression.str | 3 ++-
scoolt/Statement.str | 7 ++++++-
5 files changed, 16 insertions(+), 2 deletions(-)
Index: branches/scool-ng/src/pp-cxx/CxxDecl.str
===================================================================
--- branches/scool-ng/src/pp-cxx/CxxDecl.str (revision 122)
+++ branches/scool-ng/src/pp-cxx/CxxDecl.str (revision 123)
@@ -57,6 +57,9 @@
CxxComment(txt) ->
H hs=1 [ "//" ~S(txt) ]
+ CxxTopLevelToAbox:
+ CxxProgram(c) -> S(c)
+
CxxBodyToAbox:
CxxPublic(b) -> V is=2 [ "public:" V [ ~*<map(CxxTopLevelToAbox)> b
] ]
Index: branches/scool-ng/src/scoolt/Expression.str
===================================================================
--- branches/scool-ng/src/scoolt/Expression.str (revision 122)
+++ branches/scool-ng/src/scoolt/Expression.str (revision 123)
@@ -25,7 +25,8 @@
<BaseExpressionToCxx> bexp => cxx_bexp
ExpressionToCxx:
- String(str) -> <un-double-quote> str
+ String(str) -> str
+ //String(str) -> <un-double-quote> str
ExpressionToCxx:
Sum(e1, e2) -> CxxSum(cxx_e1, cxx_e2)
Index: branches/scool-ng/src/scoolt/Statement.str
===================================================================
--- branches/scool-ng/src/scoolt/Statement.str (revision 122)
+++ branches/scool-ng/src/scoolt/Statement.str (revision 123)
@@ -2,6 +2,11 @@
imports libstratego-lib Cxx Scool Declaration
+rules
+
+ RawCxx:
+ Cxx(cxx_code) -> CxxProgram(cxx_code)
+
strategies
- StatementToCxx = DeclarationToCxx
+ StatementToCxx = DeclarationToCxx <+ RawCxx
Index: branches/scool-ng/src/scl-syn/Statement.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Statement.sdf (revision 122)
+++ branches/scool-ng/src/scl-syn/Statement.sdf (revision 123)
@@ -9,6 +9,10 @@
Declaration -> Statement
+ Cxx -> CxxStatement
+ CxxStatement -> Statement
+ CxxStatement -> FunctionStatement
+
Expression ";" -> FunctionStatement
{cons("ExpressionStatement")}
SimpleDeclaration -> FunctionStatement
"->" Expression ";" -> FunctionStatement
{cons("ReturnStatement")}
Index: branches/scool-ng/src/scl-syn/Lexical.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Lexical.sdf (revision 122)
+++ branches/scool-ng/src/scl-syn/Lexical.sdf (revision 123)
@@ -63,6 +63,7 @@
Id -/- [A-Za-z0-9\_]
Asterisk -/- [\/]
Slash -/- [\*]
+ RawCxx -/- [\ \t\n]
context-free restrictions
LAYOUT? -/- [\ \t\n]