From: Maxime van Noppen <yabo(a)lrde.epita.fr>
To: transformers-patches(a)lrde.epita.fr, olena-patches(a)lrde.epita.fr
Subject: scool r130: Fix verbatim C++
URL:
https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-11-14 Maxime van Noppen <yabo(a)lrde.epita.fr>
Fix verbatim C++.
* pp-cxx/CxxStm.str: Add a semicolon when verbatim C++ is used as an
* expression.
* scl-syn/Expression.sdf: Verbatim C++ may be an expression.
* scl-syn/Lexical.sdf: Fix regexp.
* scl-syn/Statement.sdf: Add a semicolon after verbatim C++ blocks
* to be coherent with the other statements syntax.
* scoolt/Expression.str: Handle verbatim C++ when used as an expression.
* scoolt/Statement.str: F.
---
pp-cxx/CxxStm.str | 2 +-
scl-syn/Expression.sdf | 2 ++
scl-syn/Lexical.sdf | 2 +-
scl-syn/Statement.sdf | 4 ++--
scoolt/Expression.str | 3 +++
scoolt/Statement.str | 2 +-
6 files changed, 10 insertions(+), 5 deletions(-)
Index: branches/scool-ng/src/pp-cxx/CxxStm.str
===================================================================
--- branches/scool-ng/src/pp-cxx/CxxStm.str (revision 129)
+++ branches/scool-ng/src/pp-cxx/CxxStm.str (revision 130)
@@ -5,7 +5,7 @@
rules
CxxStmToAbox:
- CxxExpStm(e) -> H hs=0 [ ~<CxxExpToAbox> e ~<Semicolon> e]
+ CxxExpStm(e) -> H hs=0 [ ~<CxxExpToAbox> 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
Index: branches/scool-ng/src/scoolt/Expression.str
===================================================================
--- branches/scool-ng/src/scoolt/Expression.str (revision 129)
+++ branches/scool-ng/src/scoolt/Expression.str (revision 130)
@@ -17,6 +17,9 @@
BaseExpressionToCxx:
Integer(int) -> CxxInt(int)
+ BaseExpressionToCxx:
+ Cxx(cxx_code) -> CxxProgram(cxx_code)
+
ExpressionToCxx:
Index: branches/scool-ng/src/scoolt/Statement.str
===================================================================
--- branches/scool-ng/src/scoolt/Statement.str (revision 129)
+++ branches/scool-ng/src/scoolt/Statement.str (revision 130)
@@ -5,7 +5,7 @@
rules
RawCxx:
- Cxx(cxx_code) -> CxxProgram(cxx_code)
+ CxxStatement(Cxx(cxx_code)) -> CxxProgram(cxx_code)
strategies
Index: branches/scool-ng/src/scl-syn/Statement.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Statement.sdf (revision 129)
+++ branches/scool-ng/src/scl-syn/Statement.sdf (revision 130)
@@ -4,15 +4,15 @@
Lexical Declaration Expression
exports
- sorts Statement FunctionStatement
+ sorts Statement FunctionStatement CxxStatement
context-free syntax
Declaration -> Statement
- Cxx -> CxxStatement
CxxStatement -> Statement
CxxStatement -> FunctionStatement
+ Cxx ";" -> CxxStatement {cons("CxxStatement")}
Expression ";" -> FunctionStatement
{cons("ExpressionStatement")}
SimpleDeclaration -> FunctionStatement
"->" Expression ";" -> FunctionStatement
{cons("ReturnStatement")}
Index: branches/scool-ng/src/scl-syn/Expression.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Expression.sdf (revision 129)
+++ branches/scool-ng/src/scl-syn/Expression.sdf (revision 130)
@@ -7,6 +7,8 @@
sorts Expression StaticExpression StaticFunctionCall
context-free syntax
+ Cxx -> Expression
+ Cxx -> StaticExpression
Id -> Expression {cons("Identifier")}
Integer -> Expression {cons("Integer")}
Index: branches/scool-ng/src/scl-syn/Lexical.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Lexical.sdf (revision 129)
+++ branches/scool-ng/src/scl-syn/Lexical.sdf (revision 130)
@@ -12,7 +12,7 @@
[A-Za-z][A-Za-z0-9\_]* -> Id
[0-9]+ -> Integer {cons("Integer")}
"\"" [A-Za-z0-9]* "\"" ->
String {cons("String")}
- ~[\ ]~[\]\|]*~[\ ] -> RawCxx
+ ~[\]\|]* -> RawCxx
"//" ~[\n]* [\n] -> LAYOUT
[\ \t\n] -> LAYOUT