aurelia-svn Mailing List for Aurelia (Page 2)
Status: Alpha
Brought to you by:
valentindavid
You can subscribe to this list here.
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(8) |
Jul
(30) |
Aug
(5) |
Sep
(6) |
Oct
(13) |
Nov
(2) |
Dec
(5) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2011 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
|
From: <val...@us...> - 2010-10-05 21:13:30
|
Revision: 136
http://aurelia.svn.sourceforge.net/aurelia/?rev=136&view=rev
Author: valentindavid
Date: 2010-10-05 21:13:23 +0000 (Tue, 05 Oct 2010)
Log Message:
-----------
2010-10-05 Valentin David <val...@ii...>
Use max_shared_ptr for generic terms. Now shared_object is only
used in the LL stack.
* src/terms/constructor.hh,
* src/terms/term.hh:
Use max_shared_ptr.
* src/strategies/traversals/all.hh:
Update.
* demos/03-threads.cc: Remove type traits from depracted interface.
* demos/11-pair_of_int.cc: Remove (deprecated).
* demos/Makefile.am: Update.
Modified Paths:
--------------
trunk/ChangeLog
trunk/demos/03-threads.cc
trunk/demos/Makefile.am
trunk/src/strategies/traversals/all.hh
trunk/src/terms/constructor.hh
trunk/src/terms/term.hh
Removed Paths:
-------------
trunk/demos/11-pair_of_int.cc
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-10-05 21:08:52 UTC (rev 135)
+++ trunk/ChangeLog 2010-10-05 21:13:23 UTC (rev 136)
@@ -1,5 +1,21 @@
2010-10-05 Valentin David <val...@ii...>
+ Use max_shared_ptr for generic terms. Now shared_object is only
+ used in the LL stack.
+
+ * src/terms/constructor.hh,
+ * src/terms/term.hh:
+ Use max_shared_ptr.
+
+ * src/strategies/traversals/all.hh:
+ Update.
+
+ * demos/03-threads.cc: Remove type traits from depracted interface.
+ * demos/11-pair_of_int.cc: Remove (deprecated).
+ * demos/Makefile.am: Update.
+
+2010-10-05 Valentin David <val...@ii...>
+
* doc/stylesheet.css: Add comment about the origins of the CSS file.
* doc/Makefile.am: Fix dependency file generation.
Modified: trunk/demos/03-threads.cc
===================================================================
--- trunk/demos/03-threads.cc 2010-10-05 21:08:52 UTC (rev 135)
+++ trunk/demos/03-threads.cc 2010-10-05 21:13:23 UTC (rev 136)
@@ -27,17 +27,6 @@
typedef Constructor <Main> Cons;
typedef Term<Main> T;
-namespace aurelia {
-template <>
-struct ThreadSafe<T> {
- typedef True res;
-};
-template <>
-struct ThreadSafe<Cons> {
- typedef True res;
-};
-}
-
struct MyThread: public Thread<MyThread> {
Term<Main> term;
Deleted: trunk/demos/11-pair_of_int.cc
===================================================================
--- trunk/demos/11-pair_of_int.cc 2010-10-05 21:08:52 UTC (rev 135)
+++ trunk/demos/11-pair_of_int.cc 2010-10-05 21:13:23 UTC (rev 136)
@@ -1,229 +0,0 @@
-// This file is a part of Aurelia.
-// Copyright (C) 2010 Valentin David
-// Copyright (C) 2010 University of Bergen
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include <strategies/failure.hh>
-#include <sstream>
-#include <strategies/strategies.hh>
-#include <strategies/traversals/topdown.hh>
-#include <strategies/generic/debug.hh>
-#include <terms/baf_read.hh>
-#include <iostream>
-#include <terms/term.hh>
-
-using namespace aurelia;
-
-struct Main {};
-
-struct IntPool {};
-
-namespace aurelia {
-template <>
-struct ChildrenType<IntPool> {
- typedef Main res;
-};
-}
-
-struct IntCore: public TermCore<IntPool> {
-private:
- int value;
-
-public:
- typedef TermCore<IntPool> super;
-
- template <typename Pool>
- IntCore(const TermCore<Pool>& t): super(t) {
- std::stringstream ss(t.constructor().name(), std::ios_base::in);
- ss >> value;
- if (ss.fail())
- throw Failure();
- if (!ss.eof())
- throw Failure();
- }
-
- operator int() const {
- return value;
- }
-};
-
-namespace aurelia {
-template <>
-struct CoreTypeOf<Term<IntPool> > {
- typedef IntCore res;
-};
-}
-
-struct Int: public Term<IntPool> {
-public:
- typedef Term<IntPool> super;
- Int(const super& i): super(i) {}
- Int(const Int& i): super(i) {}
- template <typename Pool>
- Int(const Term<Pool>& i): super(i) {}
- operator int() const {
- return this->get();
- }
-};
-
-namespace aurelia {
- template <>
- struct ListableModel<Int> {
- struct Model {
- typedef Int Type;
- };
- };
-}
-
-struct IntPairPool {};
-
-namespace aurelia {
-template <>
-struct ChildrenType<IntPairPool> {
- typedef Main res;
-};
-}
-
-struct IntPairCore: public TermCore<IntPairPool> {
-private:
- Int a;
- Int b;
-
-public:
- typedef TermCore<IntPairPool> super;
-
- template <typename Pool>
- IntPairCore(const TermCore<Pool>& t): super(t), a(t[0]), b(t[1]) {
- if (t.constructor() != Constructor<Pool>("PairOfInt", 2))
- throw Failure();
- }
-
- const Int& get_a() const {
- return a;
- }
-
- const Int& get_b() const {
- return b;
- }
-
- IntPairCore(const Int& a, const Int& b)
- : super(Constructor<Main>("PairOfInt", 2),
- (a, b)),
- a(a), b(b) {}
-};
-
-namespace aurelia {
-template <>
-struct CoreTypeOf<Term<IntPairPool> > {
- typedef IntPairCore res;
-};
-}
-
-struct IntPair: public Term<IntPairPool> {
-public:
- typedef Term<IntPairPool> super;
- IntPair(const super& i): super(i) {}
- IntPair(const IntPair& i): super(i) {}
- template <typename Pool>
- IntPair(const Term<Pool>& i): super(i) {}
- IntPair(const Int& a, const Int& b): super(IntPairCore(a, b)) {}
-
- const Int& get_a() const {
- return this->get().get_a();
- }
- const Int& get_b() const {
- return this->get().get_b();
- }
-};
-
-template <typename Strat1, typename Strat2>
-struct PairOfIntCong {
-private:
- Strat1 s1;
- Strat2 s2;
-public:
- PairOfIntCong(const Strat1& s1, const Strat2& s2): s1(s1), s2(s2) {}
- IntPair operator()(const IntPair& t) const {
- Int a = s1(t.get_a());
- Int b = s2(t.get_b());
- return IntPair(a, b);
- }
-
- template <typename T>
- IntPair operator()(const T& t) const {
- IntPair input(t);
- Int a = s1(input.get_a());
- Int b = s2(input.get_b());
- return IntPair(a, b);
- }
-};
-
-template <typename Strat1, typename Strat2>
-PairOfIntCong<Strat1, Strat2> PairOfInt(const Strat1& s1, const Strat2& s2) {
- return PairOfIntCong<Strat1, Strat2>(s1, s2);
-}
-
-template <typename Strat>
-Term<IntPairPool> all_prim(const Strat& s, const Term<IntPairPool>& term) {
- return (PairOfInt(s,s))(term);
-}
-
-struct Acc {
-private:
- int* i;
- bool master;
-
-public:
- Acc(const Acc& other): i(other.i), master(false) {}
- Acc(): i(new int(0)), master(true) {}
- ~Acc() { if (master) delete i; }
- Int operator()(const Int& t) const {
- *i += t;
- return t;
- }
-
- template <typename T>
- Int operator()(const T& t) const {
- Int input(t);
- *i += input;
- return input;
- }
-
- operator int() const {
- return *i;
- }
-};
-
-int main() {
- typedef Constructor <Main> Cons;
- typedef Term<Main> T;
-
- try {
- Cons PairOfIntC("PairOfInt", 2);
- Cons a("42", 0);
- Cons b("51", 0);
- IntPair d = PairOfIntC[a,b];
- std::cout << d << std::endl;
- std::cout << (int)d.get_a() + (int)d.get_b() << std::endl;
- PairOfInt(debug("a: "), debug("b: "))(d);
- Acc acc;
- (topdown(try_(where(acc))))(d);
- std::cout << acc << std::endl;
- } catch (Failure) {
- std::cerr << "Failure." << std::endl;
- return 1;
- }
- return 0;
-}
Modified: trunk/demos/Makefile.am
===================================================================
--- trunk/demos/Makefile.am 2010-10-05 21:08:52 UTC (rev 135)
+++ trunk/demos/Makefile.am 2010-10-05 21:13:23 UTC (rev 136)
@@ -26,7 +26,6 @@
06-patterns \
07-strategies \
10-int \
- 11-pair_of_int \
12-maps \
13-constructors-with-typed-terms
@@ -50,7 +49,6 @@
06_patterns_SOURCES=06-patterns.cc
07_strategies_SOURCES=07-strategies.cc
10_int_SOURCES=10-int.cc
-11_pair_of_int_SOURCES=11-pair_of_int.cc
12_maps_SOURCES=12-maps.cc
13_constructors_with_typed_terms_SOURCES=13-constructors-with-typed-terms.cc
Modified: trunk/src/strategies/traversals/all.hh
===================================================================
--- trunk/src/strategies/traversals/all.hh 2010-10-05 21:08:52 UTC (rev 135)
+++ trunk/src/strategies/traversals/all.hh 2010-10-05 21:13:23 UTC (rev 136)
@@ -24,20 +24,19 @@
template <typename Strat, typename T>
Term<T> all_prim(const Strat& s, const Term<T>& term) {
- typedef Term<typename ChildrenType<T>::res> Ch;
if (term.constructor().arity()) {
bool changed = false;
unsigned i = 0;
- Ch *list = NULL;
+ Term<T> *list = NULL;
try {
- list = (Ch*)malloc(term.constructor().arity()
+ list = (Term<T>*)malloc(term.constructor()->arity()
*sizeof(Term<T>));
if (list == NULL)
throw Failure();
for (;
i < term.constructor().arity();
++i) {
- new (list+i) Ch(s(term[i]));
+ new (list+i) Term<T>(s(term[i]));
changed = changed || diff_no_conv(list[i], term[i]);
}
}
@@ -45,18 +44,18 @@
if (list == NULL)
throw ;
for (unsigned j = 0; j < i; ++j) {
- (list+j)->~Ch();
+ (list+j)->~Term<T>();
}
free(list);
throw ;
}
if (changed)
- return Ch(term.constructor(), list);
+ return Term<T>(term.constructor(), list);
else {
for (unsigned j = 0;
j < term.constructor().arity();
++j)
- (list+j)->~Ch();
+ (list+j)->~Term<T>();
free(list);
return term;
}
Modified: trunk/src/terms/constructor.hh
===================================================================
--- trunk/src/terms/constructor.hh 2010-10-05 21:08:52 UTC (rev 135)
+++ trunk/src/terms/constructor.hh 2010-10-05 21:13:23 UTC (rev 136)
@@ -17,10 +17,11 @@
#ifndef __CONSTRUCTOR_HH
# define __CONSTRUCTOR_HH
-# include "shared_object.hh"
# include <string>
# include "../lists/list_concept.hh"
# include "../lists/listable.hh"
+# include "../max_shared/max_shared_ptr.hh"
+# include "../memory/pool_allocator.hh"
namespace aurelia {
@@ -89,16 +90,21 @@
}
ConstructorCore() {}
- void swap(ConstructorCore* other) {
- std::swap(_name, other->_name);
- unsigned h = _hash;
- _hash = other->_hash;
- other->_hash = h;
- h = _arity;
- _arity = other->_arity;
- other->_arity = h;
+ ConstructorCore(ConstructorCore&& other) {
+ *this = std::move(other);
}
+ ConstructorCore& operator=(const ConstructorCore& other) {
+ return *this = std::move(other);
+ }
+
+ ConstructorCore& operator=(ConstructorCore&& other) {
+ std::swap(_name, other._name);
+ std::swap(_arity, other._arity);
+ std::swap(_hash, other._hash);
+ return *this;
+ }
+
ConstructorCore(const ConstructorCore& o)
: _name(o._name), _arity(o._arity), _hash(o._hash) {
}
@@ -122,52 +128,45 @@
}
};
-template <typename Pool>
-struct Constructor;
+ template <typename Pool>
+struct Constructor: public max_shared_ptr<ConstructorCore, member_hash<ConstructorCore>, std::equal_to<ConstructorCore>, pool_allocator<ConstructorCore> > {
+ typedef max_shared_ptr<ConstructorCore, member_hash<ConstructorCore>, std::equal_to<ConstructorCore>, pool_allocator<ConstructorCore> > super;
-template <typename Pool>
-struct CoreTypeOf<Constructor<Pool> > {
- typedef ConstructorCore res;
-};
-
-template <typename Pool>
-struct Constructor: public SharedObject<Constructor<Pool> > {
- typedef SharedObject<Constructor<Pool> > super;
-
public:
- Constructor(const NoBuild& n): super(n) {
+ Constructor(): super() {
}
Constructor(const Constructor& other): super(other) {
}
- template <typename OtherPool>
+ template <typename OtherPool,
+ typename =
+ typename
+ std::enable_if<!std::is_same<Pool, OtherPool>::value>::type>
Constructor(const Constructor<OtherPool>& other)
- : super(other.get()) {
+ : super(other) {
}
Constructor(const std::string& n, unsigned a)
- : super(ConstructorCore(n, a)) {
+ : super(n, a) {
}
Constructor(const std::string& n)
- : super(ConstructorCore(n, 0)) {
+ : super(n, 0) {
}
unsigned arity() const {
- return this->get().arity();
+ return (*this)->arity();
}
const std::string& name() const {
- return this->get().name();
+ return (*this)->name();
}
- unsigned hash() const {
- return this->get().hash();
- }
+ unsigned hash() const {
+ return (*this)->hash();
+ }
- Constructor(): super(NoBuild()) {}
-
static Constructor AS_INT;
static Constructor AS_REAL;
static Constructor AS_BLOB;
Modified: trunk/src/terms/term.hh
===================================================================
--- trunk/src/terms/term.hh 2010-10-05 21:08:52 UTC (rev 135)
+++ trunk/src/terms/term.hh 2010-10-05 21:13:23 UTC (rev 136)
@@ -21,248 +21,239 @@
#ifndef __TERM_HH
# define __TERM_HH
-# include "shared_object.hh"
# include "constructor.hh"
# include <cassert>
# include <cstdlib>
# include "../strategies/failure.hh"
# include "../lists/listable.hh"
+# include "../max_shared/max_shared_ptr.hh"
+# include "../memory/pool_allocator.hh"
namespace aurelia {
-template <typename Pool>
-struct Term;
+ template <typename Pool>
+ struct Term;
-//! \brief Type traits for selecting type of children
-template <typename T>
-struct ChildrenType {
- typedef T res;
-};
+ template <typename Pool>
+ struct TermCore {
+ private:
+ Constructor<Pool> _constructor;
+ const Term<Pool>* children;
+ unsigned _hash;
-template <typename Pool>
-struct TermCore {
- typedef Term<typename ChildrenType<Pool>::res> ChType;
- typedef typename ChildrenType<Pool>::res ChPool;
-private:
- Constructor<Pool> _constructor;
- ChType *children;
- unsigned _hash;
+ public:
+ ~TermCore() {
+ if (children != NULL) {
+ for (unsigned i = 0; i < _constructor->arity(); ++i)
+ (children+i)->~Term();
+ free((void*)children);
+ }
+ }
-public:
- ~TermCore() {
- if (children != NULL) {
- for (unsigned i = 0; i < _constructor.arity(); ++i)
- (children+i)->~Term();
- free(children);
+ TermCore() {
+ children = NULL;
}
- }
- TermCore() {
- children = NULL;
- }
+ private:
+ void copy(const ListNil&, Term<Pool>*) {
+ }
- void swap(TermCore *other) {
- _constructor.swap(other->_constructor);
- ChType *a = children;
- children = other->children;
- other->children = a;
- unsigned h = _hash;
- _hash = other->_hash;
- other->_hash = h;
- }
+ template <typename T, typename M = typename aurelia::ListModel<T>::Model,
+ typename = typename std::enable_if<!std::is_same<void, typename M::Head>::value>::type>
+ void copy(const T& l, Term<Pool>* list) {
+ new (list+(unsigned)M::size-1) Term<Pool>(head(l));
+ copy(tail(l), list);
+ }
-private:
- void copy(const ListNil&, ChType*) {
- }
+ public:
- template <typename T, typename M = typename aurelia::ListModel<T>::Model,
- typename = typename std::enable_if<!std::is_same<void, typename M::Head>::value>::type>
- void copy(const T& l, ChType* list) {
- new (list+(unsigned)M::size-1) ChType(head(l));
- copy(tail(l), list);
- }
+ template <typename OtherPool,
+ typename =
+ typename
+ std::enable_if<!std::is_same<Pool, OtherPool>::value>::type>
+ TermCore(const Term<OtherPool>& other): _constructor(other->constructor()) {
+ Term<Pool>* tc = NULL;
+ _hash = _constructor->hash();
+ if (_constructor->arity() != 0) {
+ tc = (Term<Pool>*)malloc(_constructor->arity()*sizeof(Term<Pool>));
+ for (unsigned i = 0; i < _constructor->arity(); ++i) {
+ new (tc+i) Term<Pool>((*other)[i]);
+ _hash ^= tc[i]->hash();
+ _hash = (_hash << 11) | (_hash >> 21);
+ }
+ }
+ children = tc;
+ }
-public:
-
- //!FIXME: check that all types in the list are ChType
- template <typename L,
- typename M = typename ListModel<L>::Model>
- TermCore(const Constructor<Pool>& c, const L& ch)
- : _constructor(c) {
- if (c.arity() != M::size) {
- children = NULL;
- throw Failure();
+ template <typename L,
+ typename M = typename ListModel<L>::Model>
+ TermCore(const Constructor<Pool>& c, const L& ch):
+ _constructor(c), children(NULL)
+ {
+ if (c->arity() != M::size) {
+ throw Failure();
+ }
+ _hash = c->hash();
+ Term<Pool>* tc = NULL;
+ if (M::size != 0)
+ tc = (Term<Pool>*)malloc((unsigned)M::size*sizeof(Term<Pool>));
+ copy(ch, tc);
+ children = tc;
+ for (unsigned i = 0; i < c->arity(); ++i) {
+ _hash ^= children[i]->hash();
+ _hash = (_hash << 11) | (_hash >> 21);
+ }
}
- _hash = c.hash();
- if (M::size != 0)
- children = (ChType*)malloc((unsigned)M::size*sizeof(ChType));
- else
- children = NULL;
- copy(ch, children);
- for (unsigned i = 0; i < c.arity(); ++i) {
- _hash ^= children[i].hash();
+
+ TermCore(const Constructor<Pool>& c, const Term<Pool>& ch)
+ : _constructor(c) {
+ if (c->arity() != 1) {
+ children = NULL;
+ throw Failure();
+ }
+ _hash = c.hash();
+ Term<Pool>* tc = (Term<Pool>*)malloc(sizeof(Term<Pool>));
+ new (tc) Term<Pool>(ch);
+ _hash ^= tc[0]->hash();
_hash = (_hash << 11) | (_hash >> 21);
+ children = tc;
}
- }
- TermCore(const Constructor<Pool>& c, const ChType& ch)
- : _constructor(c) {
- if (c.arity() != 1) {
- children = NULL;
- throw Failure();
+ TermCore(const Constructor<Pool>& c, const Term<Pool>* ch)
+ : _constructor(c) {
+ _hash = c->hash();
+ if (c->arity() != 0)
+ children = ch;
+ else
+ children = NULL;
+ for (unsigned i = 0; i < c->arity(); ++i) {
+ _hash ^= children[i]->hash();
+ _hash = (_hash << 11) | (_hash >> 21);
+ }
}
- _hash = c.hash();
- children = (ChType*)malloc(sizeof(ChType));
- new (children) ChType(ch);
- for (unsigned i = 0; i < c.arity(); ++i) {
- _hash ^= children[i].hash();
- _hash = (_hash << 11) | (_hash >> 21);
+
+ TermCore(TermCore&& other): _constructor(other._constructor),
+ children(NULL),
+ _hash(other._hash)
+ {
+ std::swap(children, other.children);
}
- }
- TermCore(const Constructor<Pool>& c, ChType* ch)
- : _constructor(c) {
- _hash = c.hash();
- if (c.arity() != 0)
- children = ch;
- else
- children = NULL;
- for (unsigned i = 0; i < c.arity(); ++i) {
- _hash ^= children[i].hash();
- _hash = (_hash << 11) | (_hash >> 21);
+ TermCore(const TermCore& other)
+ : _constructor(other._constructor) {
+ _hash = other._hash;
+ Term<Pool>* tc = NULL;
+ if (_constructor->arity() != 0) {
+ tc = (Term<Pool>*)malloc(_constructor->arity()*sizeof(Term<Pool>));
+ for (unsigned i = 0; i < _constructor->arity(); ++i) {
+ new (tc+i) Term<Pool>(other.children[i]);
+ }
+ }
+ children = tc;
}
- }
- TermCore(const TermCore& other)
- : _constructor(other.constructor()) {
- _hash = other._hash;
- children = other.children;
- const_cast<TermCore*>(&other)->children = NULL;
- }
+ TermCore& operator=(const TermCore& other) {
+ return (*this) = TermCore(other);
+ }
- template <typename OtherPool>
- TermCore(const TermCore<OtherPool>& other)
- : _constructor(other.constructor()) {
- _hash = _constructor.hash();
- if (_constructor.arity() != 0) {
- children = (ChType*)malloc(_constructor.arity()*sizeof(ChType));
+ TermCore& operator=(TermCore&& other) {
+ std::swap(_constructor, other._constructor);
+ std::swap(children, other.children);
+ std::swap(_hash, other._hash);
+ return *this;
}
- else
- children = NULL;
- for (unsigned i = 0; i < _constructor.arity(); ++i) {
- new (children+i) ChType(other[i]);
- _hash ^= children[i].hash();
- _hash = (_hash << 11) | (_hash >> 21);
+
+ unsigned hash() const {
+ return _hash;
}
- }
- unsigned hash() const {
- return _hash;
- }
-
- bool operator==(const TermCore& other) const {
- if (_constructor != other._constructor)
- return false;
- for (unsigned i = 0; i < _constructor.arity(); ++i)
- if (children[i] != other.children[i])
+ bool operator==(const TermCore& other) const {
+ if (_constructor != other._constructor)
return false;
- return true;
- }
+ for (unsigned i = 0; i < _constructor->arity(); ++i)
+ if (children[i] != other.children[i])
+ return false;
+ return true;
+ }
- const ChType& operator[](unsigned n) const {
- if (n >= _constructor.arity())
- throw Failure();
- return children[n];
- }
+ const Term<Pool>& operator[](unsigned n) const {
+ if (n >= _constructor->arity())
+ throw Failure();
+ return children[n];
+ }
- const Constructor<Pool>& constructor() const {
- return _constructor;
- }
-};
+ const Constructor<Pool>& constructor() const {
+ return _constructor;
+ }
+ };
-template <typename Pool>
-struct CoreTypeOf<Term<Pool> > {
- typedef TermCore<Pool> res;
-};
+ template <typename Pool>
+ struct Term: public max_shared_ptr<TermCore<Pool>, member_hash<TermCore<Pool> >, std::equal_to<TermCore<Pool> >, pool_allocator<TermCore<Pool> > > {
+ public:
+ typedef max_shared_ptr<TermCore<Pool>, member_hash<TermCore<Pool> >, std::equal_to<TermCore<Pool> >, pool_allocator<TermCore<Pool> > > super;
-//! \brief Generic shared terms
-template <typename Pool>
-struct Term: public SharedObject<Term<Pool> > {
-public:
- typedef SharedObject<Term<Pool> > super;
- typedef Term<typename ChildrenType<Pool>::res> ChType;
- typedef typename ChildrenType<Pool>::res ChPool;
+ Term(const Term& other): super((const super&)(other)) {
+ }
- Term(const Term& other): super(other) {
- }
+ Term(): super() {
+ }
- explicit Term(): super(NoBuild()) {
- }
+ template <typename OtherPool,
+ typename =
+ typename
+ std::enable_if<!std::is_same<Pool, OtherPool>::value>::type>
+ bool operator==(const Term<OtherPool>& other) const {
+ return *this == Term(other);
+ }
- template <typename OtherPool>
- bool operator==(const Term<OtherPool>& other) const {
- return *this == Term(other);
- }
+ bool operator==(const Term& other) const {
+ return this->super::operator==(other);
+ }
- Term& operator=(const Term& other) {
- return super::operator=(other);
- }
+ Term& operator=(const Term& other) {
+ this->super::operator=(other);
+ return *this;
+ }
- bool operator==(const Term& other) const {
- return (super(*this) == super(other));
- }
+ Term& operator=(Term&& other) {
+ this->super::operator=(other);
+ return *this;
+ }
- template <typename OtherPool>
- Term(const Term<OtherPool>& other)
- : super(NoBuild()) {
- typename CoreTypeOf<Term<Pool> >::res tmp(other.get());
- new (static_cast<super*>(this)) super(tmp);
- }
+ template <typename OtherPool,
+ typename =
+ typename
+ std::enable_if<!std::is_same<Pool, OtherPool>::value>::type>
+ Term(const Term<OtherPool>& other): super(other) {}
- template <typename L,
- typename M = typename ListModel<L>::Model>
- Term(const Constructor<Pool>& c, const L&l)
- : super(NoBuild()) {
- typename CoreTypeOf<Term<Pool> >::res tmp(c, l);
- new (static_cast<super*>(this)) super(tmp);
- }
+ template <typename L,
+ typename M = typename ListModel<L>::Model>
+ Term(const Constructor<Pool>& c, const L&l): super(c, l) {
+ }
- Term(const Constructor<Pool>& c, const ChType&l)
- : super(NoBuild()) {
- typename CoreTypeOf<Term<Pool> >::res tmp(c, l);
- new (static_cast<super*>(this)) super(tmp);
- }
+ Term(const Constructor<Pool>& c, const Term<Pool>&l): super(c, l) {
+ }
- Term(const Constructor<Pool>& c, ChType* l)
- : super(NoBuild()) {
- typename CoreTypeOf<Term<Pool> >::res tmp(c, l);
- new (static_cast<super*>(this)) super(tmp);
- }
+ Term(const Constructor<Pool>& c, const Term<Pool>* l): super(c, l) {
+ }
- Term(const Constructor<Pool>& c)
- : super(NoBuild()) {
- new (this) Term(c, ListNil());
- }
+ Term(const Constructor<Pool>& c): super(c, ListNil()) {}
- Constructor<Pool> constructor() const {
- return this->get().constructor();
- }
+ Constructor<Pool> constructor() const {
+ return (*this)->constructor();
+ }
- const ChType& operator[](unsigned i) const {
- return this->get()[i];
- }
+ const Term<Pool>& operator[](unsigned i) const {
+ return (**this)[i];
+ }
- operator ListCons<ChType, ListNil>() const {
- return ListCons<ChType, ListNil>()(*this, ListNil());
- }
+ operator ListCons<Term<Pool>, ListNil>() const {
+ return ListCons<Term<Pool>, ListNil>()(*this, ListNil());
+ }
- unsigned hash() const {
- return this->get().hash();
- }
-
-protected:
- Term(const typename CoreTypeOf<Term<Pool> >::res& core): super(core) {
- }
+ unsigned hash() const {
+ return (*this)->hash();
+ }
};
template <typename Stream, typename Pool>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-10-05 21:08:58
|
Revision: 135
http://aurelia.svn.sourceforge.net/aurelia/?rev=135&view=rev
Author: valentindavid
Date: 2010-10-05 21:08:52 +0000 (Tue, 05 Oct 2010)
Log Message:
-----------
2010-10-05 Valentin David <val...@ii...>
* doc/stylesheet.css: Add comment about the origins of the CSS file.
* doc/Makefile.am: Fix dependency file generation.
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/Makefile.am
trunk/doc/stylesheet.css
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-10-05 21:07:06 UTC (rev 134)
+++ trunk/ChangeLog 2010-10-05 21:08:52 UTC (rev 135)
@@ -1,5 +1,11 @@
2010-10-05 Valentin David <val...@ii...>
+ * doc/stylesheet.css: Add comment about the origins of the CSS file.
+
+ * doc/Makefile.am: Fix dependency file generation.
+
+2010-10-05 Valentin David <val...@ii...>
+
Add new implementation of maximal sharing as something
looking more like C++ smart pointers. The implementation is
thread-safe and lock-free (if possible by hardware) on copy
Modified: trunk/doc/Makefile.am
===================================================================
--- trunk/doc/Makefile.am 2010-10-05 21:07:06 UTC (rev 134)
+++ trunk/doc/Makefile.am 2010-10-05 21:08:52 UTC (rev 135)
@@ -47,7 +47,8 @@
echo '[0;33m'"Doxygen reported warnings. Please check $(subdir)/doxygen.log."'[m' 2>&1; \
fi; \
echo '' >>$(DEPDIR)/doc.Tdeps; \
- mv -f $(DEPDIR)/doc.Tdeps $(DEPDIR)/doc.deps; \
+ $(SED) 'p;1!{;s/^ \(.*\) \\$$/\1:\n/;H;};$${;x;p;};d' $(DEPDIR)/doc.Tdeps >$(DEPDIR)/doc.deps; \
+ rm -f $(DEPDIR)/doc.Tdeps; \
rm -rf html; \
mv -f output.tmp/html . ; \
rm -rf output.tmp ; \
Modified: trunk/doc/stylesheet.css
===================================================================
--- trunk/doc/stylesheet.css 2010-10-05 21:07:06 UTC (rev 134)
+++ trunk/doc/stylesheet.css 2010-10-05 21:08:52 UTC (rev 135)
@@ -1,3 +1,10 @@
+/*
+ * This stylesheet comes from project Doxygen. It has been modified for
+ * project Aurelia's purpose.
+ *
+ */
+
+
.navigation {
width: 15%;
float: left;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-10-05 21:07:12
|
Revision: 134
http://aurelia.svn.sourceforge.net/aurelia/?rev=134&view=rev
Author: valentindavid
Date: 2010-10-05 21:07:06 +0000 (Tue, 05 Oct 2010)
Log Message:
-----------
2010-10-05 Valentin David <val...@ii...>
Add new implementation of maximal sharing as something
looking more like C++ smart pointers. The implementation is
thread-safe and lock-free (if possible by hardware) on copy
and destruction. However, there is still locking when constructing
or collecting.
* src/max_shared/deref.hh:
New. Provide a functor with automatic dereference on all arguments
from whatever functor given as parameter.
* src/max_shared/max_shared_ptr.hh:
New. The implementation.
* src/max_shared/Makefile.am:
New.
* src/hash/mhash.hh: New. Provide a hash functor for all types
having a hash method. Fall back on std::swap otherwise.
* src/hash/Makefile.am: New.
* src/type_traits/is_same_ellipsis.hh,
* src/type_traits/has_member_hash.hh,
* src/type_traits/has_constructor.hh:
New.
* src/type_traits/Makefile.am (type_traits_HEADERS): Update.
* configure.ac (AC_CONFIG_FILES): Update.
* src/Makefile.am (SUBDIRS): Update.
Modified Paths:
--------------
trunk/ChangeLog
trunk/configure.ac
trunk/src/Makefile.am
trunk/src/type_traits/Makefile.am
Added Paths:
-----------
trunk/src/hash/
trunk/src/hash/Makefile.am
trunk/src/hash/mhash.hh
trunk/src/max_shared/
trunk/src/max_shared/Makefile.am
trunk/src/max_shared/deref.hh
trunk/src/max_shared/max_shared_ptr.hh
trunk/src/type_traits/has_constructor.hh
trunk/src/type_traits/has_member_hash.hh
trunk/src/type_traits/is_same_ellipsis.hh
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-10-05 20:59:15 UTC (rev 133)
+++ trunk/ChangeLog 2010-10-05 21:07:06 UTC (rev 134)
@@ -1,5 +1,38 @@
2010-10-05 Valentin David <val...@ii...>
+ Add new implementation of maximal sharing as something
+ looking more like C++ smart pointers. The implementation is
+ thread-safe and lock-free (if possible by hardware) on copy
+ and destruction. However, there is still locking when constructing
+ or collecting.
+
+ * src/max_shared/deref.hh:
+ New. Provide a functor with automatic dereference on all arguments
+ from whatever functor given as parameter.
+
+ * src/max_shared/max_shared_ptr.hh:
+ New. The implementation.
+
+ * src/max_shared/Makefile.am:
+ New.
+
+ * src/hash/mhash.hh: New. Provide a hash functor for all types
+ having a hash method. Fall back on std::swap otherwise.
+
+ * src/hash/Makefile.am: New.
+
+ * src/type_traits/is_same_ellipsis.hh,
+ * src/type_traits/has_member_hash.hh,
+ * src/type_traits/has_constructor.hh:
+ New.
+
+ * src/type_traits/Makefile.am (type_traits_HEADERS): Update.
+
+ * configure.ac (AC_CONFIG_FILES): Update.
+ * src/Makefile.am (SUBDIRS): Update.
+
+2010-10-05 Valentin David <val...@ii...>
+
* src/sig/tests/test.cc,
* src/sig/tests/stratego.rtree,
* src/sig/tests/Makefile.am,
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2010-10-05 20:59:15 UTC (rev 133)
+++ trunk/configure.ac 2010-10-05 21:07:06 UTC (rev 134)
@@ -158,6 +158,8 @@
demos-from-rascal/Makefile
demos-from-stratego/Makefile
demos/Makefile
+ src/max_shared/Makefile
+ src/hash/Makefile
src/memory/Makefile
src/memory/tests/Makefile
src/lists/Makefile
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2010-10-05 20:59:15 UTC (rev 133)
+++ trunk/src/Makefile.am 2010-10-05 21:07:06 UTC (rev 134)
@@ -27,6 +27,8 @@
terms \
threads \
box \
+ max_shared \
+ hash \
parser_generator
nodist_aurelia_HEADERS=aurelia-config.hh
Property changes on: trunk/src/hash
___________________________________________________________________
Added: svn:ignore
+ Makefile.in
Makefile
Added: trunk/src/hash/Makefile.am
===================================================================
--- trunk/src/hash/Makefile.am (rev 0)
+++ trunk/src/hash/Makefile.am 2010-10-05 21:07:06 UTC (rev 134)
@@ -0,0 +1,20 @@
+# This file is a part of Aurelia.
+# Copyright (C) 2010 Valentin David
+# Copyright (C) 2010 University of Bergen
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+hashdir=$(aureliadir)/hash
+hash_HEADERS= \
+ mhash.hh
Added: trunk/src/hash/mhash.hh
===================================================================
--- trunk/src/hash/mhash.hh (rev 0)
+++ trunk/src/hash/mhash.hh 2010-10-05 21:07:06 UTC (rev 134)
@@ -0,0 +1,56 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#ifndef __MHASH_HH
+# define __MHASH_HH
+
+# include "../type_traits/has_member_hash.hh"
+
+namespace aurelia {
+
+ /*! \brief Functor calling a hash method as member.
+ */
+ template <typename T>
+ struct member_hash: public std::unary_function<T, size_t> {
+ size_t operator()(const T& t) const {
+ return t.hash();
+ }
+ };
+
+ /*! \brief Helper traits for mhash
+ */
+ template <typename T, bool>
+ struct try_member_hash;
+
+ template <typename T>
+ struct try_member_hash<T, false>: public std::hash<T> {
+ };
+
+ template <typename T>
+ struct try_member_hash<T, true>: public member_hash<T> {
+ };
+
+ /*! \brief Functor calling a hash method as member if present, or the
+ * std::hash functor otherwise.
+ */
+ template <typename T>
+ struct mhash: public try_member_hash<T, type_traits::
+ has_member_hash<T>::value> {
+ };
+
+}
+
+#endif
Property changes on: trunk/src/max_shared
___________________________________________________________________
Added: svn:ignore
+ Makefile.in
Makefile
Added: trunk/src/max_shared/Makefile.am
===================================================================
--- trunk/src/max_shared/Makefile.am (rev 0)
+++ trunk/src/max_shared/Makefile.am 2010-10-05 21:07:06 UTC (rev 134)
@@ -0,0 +1,21 @@
+# This file is a part of Aurelia.
+# Copyright (C) 2010 Valentin David
+# Copyright (C) 2010 University of Bergen
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+max_shareddir=$(aureliadir)/max_shared
+max_shared_HEADERS= \
+ max_shared_ptr.hh \
+ deref.hh
Added: trunk/src/max_shared/deref.hh
===================================================================
--- trunk/src/max_shared/deref.hh (rev 0)
+++ trunk/src/max_shared/deref.hh 2010-10-05 21:07:06 UTC (rev 134)
@@ -0,0 +1,45 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef __DEREF_HH
+# define __DEREF_HH
+
+# include <type_traits>
+
+namespace aurelia {
+
+ template <typename Op>
+ struct deref_op: public Op {
+ private:
+ template <typename... Args>
+ struct Return {
+ typedef decltype(std::declval<const Op>()
+ ((*(std::declval<Args>()))...)) type;
+ };
+
+ public:
+ template <typename... Args>
+ typename Return<Args...>::type
+ operator()(const Args&... args) const
+ {
+ return this->Op::operator()((*args)...);
+ }
+ };
+
+}
+
+#endif
Added: trunk/src/max_shared/max_shared_ptr.hh
===================================================================
--- trunk/src/max_shared/max_shared_ptr.hh (rev 0)
+++ trunk/src/max_shared/max_shared_ptr.hh 2010-10-05 21:07:06 UTC (rev 134)
@@ -0,0 +1,187 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef __MAX_SHARED_PTR_HH
+# define __MAX_SHARED_PTR_HH
+
+# include <unordered_set>
+# include <memory>
+# include <mutex>
+# include <atomic>
+
+# include "../type_traits/has_constructor.hh"
+# include "../type_traits/is_same_ellipsis.hh"
+# include "deref.hh"
+# include "../hash/mhash.hh"
+
+namespace aurelia {
+
+ /*! \brief Provides a maximally shared allocated pointer.
+ *
+ */
+ template <typename T, typename Hash = mhash<T>,
+ typename EqnFunc = std::equal_to<T>,
+ typename Alloc = std::allocator<T>,
+ typename Lock = std::mutex>
+ struct max_shared_ptr {
+ private:
+ struct Ptr {
+ public:
+ std::atomic<long>& count() const {
+ return const_cast<Ptr*>(this)->_count;
+ }
+
+ private:
+ T core;
+ std::atomic<long> _count;
+
+ explicit Ptr(T&& core): core(std::move(core)), _count() {
+ _count.store(0);
+ }
+
+ public:
+ const T& operator*() const {
+ return core;
+ }
+
+ const T* get() const {
+ return &core;
+ }
+
+ Ptr(const Ptr& other): core(other.core), _count() {
+ _count.store(0);
+ }
+
+ Ptr(Ptr&& other): core(std::move(other.core)), _count() {
+ _count.store(0);
+ }
+
+ Ptr& operator=(Ptr&& other) {
+ std::swap(core, other.core);
+ return *this;
+ }
+
+ static const Ptr* create(T&& core) {
+ Ptr tmp(std::move(core));
+ lock().lock();
+ std::pair<typename set_t::iterator, bool> r =
+ set().insert(std::move(tmp));
+ const Ptr& ret = (*r.first);
+ ret.count()++;
+ lock().unlock();
+ return &ret;
+ }
+
+ void swap(Ptr& other) {
+ std::swap(core, other.core);
+ }
+ };
+
+ typedef std::unordered_set<Ptr, deref_op<Hash>,
+ deref_op<EqnFunc>, deref_op<Alloc> > set_t;
+
+ const Ptr *_ptr;
+
+ static Lock& lock() {
+ static Lock _lock;
+ return _lock;
+ }
+
+ static set_t& set() {
+ static set_t _set;
+ return _set;
+ }
+
+ public:
+ ~max_shared_ptr() {
+ if (_ptr == NULL)
+ return ;
+ if (0 == --(_ptr->count())) {
+ lock().lock();
+ if (_ptr->count().load() != 0) {
+ lock().unlock();
+ _ptr = NULL;
+ return ;
+ }
+ typename set_t::iterator i = set().find(*_ptr);
+ Ptr tmp(std::move(*const_cast<Ptr*>(_ptr)));
+ set().erase(i);
+ lock().unlock();
+ }
+ _ptr = NULL;
+ }
+
+ max_shared_ptr(T&& core): _ptr(Ptr::create(std::move(core))) {
+ }
+
+ max_shared_ptr(const max_shared_ptr& other): _ptr(other._ptr) {
+ if (_ptr != NULL)
+ _ptr->count()++;
+ }
+
+ max_shared_ptr(max_shared_ptr&& other): _ptr(other._ptr) {
+ other._ptr = NULL;
+ }
+
+ max_shared_ptr& operator=(max_shared_ptr&& other) {
+ std::swap(_ptr, other._ptr);
+ return *this;
+ }
+
+ max_shared_ptr& operator=(const max_shared_ptr& other) {
+ return *this = max_shared_ptr(other);
+ }
+
+ template <typename... Args,
+ typename =
+ typename std::enable_if<!type_traits::
+ is_same_ellipsis<max_shared_ptr,
+ Args...>::
+ value>::type,
+ typename =
+ typename std::enable_if<type_traits::
+ has_constructor<T, Args...>::value>::type>
+ max_shared_ptr(Args... args...): _ptr(Ptr::create(T(args...))) {
+ }
+
+ max_shared_ptr(): _ptr(NULL) {
+ }
+
+ bool operator==(const max_shared_ptr& other) const {
+ return _ptr == other._ptr;
+ }
+
+ bool operator!=(const max_shared_ptr& other) const {
+ return _ptr != other._ptr;
+ }
+
+ const T* get() const {
+ return _ptr->get();
+ }
+
+ const T* operator->() const {
+ return get();
+ }
+
+ const T& operator*() const {
+ return *get();
+ }
+ };
+
+}
+
+#endif
Modified: trunk/src/type_traits/Makefile.am
===================================================================
--- trunk/src/type_traits/Makefile.am 2010-10-05 20:59:15 UTC (rev 133)
+++ trunk/src/type_traits/Makefile.am 2010-10-05 21:07:06 UTC (rev 134)
@@ -19,6 +19,9 @@
is_callable_with.hh \
overloading_priority.hh \
has_model.hh \
- itself.hh
+ itself.hh \
+ has_constructor.hh \
+ has_member_hash.hh \
+ is_same_ellipsis.hh
type_traitsdir=$(includedir)/type_traits
Added: trunk/src/type_traits/has_constructor.hh
===================================================================
--- trunk/src/type_traits/has_constructor.hh (rev 0)
+++ trunk/src/type_traits/has_constructor.hh 2010-10-05 21:07:06 UTC (rev 134)
@@ -0,0 +1,48 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#ifndef __HAS_CONSTRUCTOR_HH
+# define __HAS_CONSTRUCTOR_HH
+
+# include "itself.hh"
+# include "overloading_priority.hh"
+# include <type_traits>
+
+namespace aurelia {
+ namespace type_traits {
+
+ template <typename T, typename... Args,
+ typename = typename
+ itself<decltype(T(std::declval<Args>()...))>::type>
+ std::true_type has_constructor_helper(try_first, T, Args...);
+
+ template <typename T, typename... Args>
+ std::false_type has_constructor_helper(try_second, T, Args...);
+
+ /*! \brief Tells if a type has a constructor with arguments Args...
+ */
+ template <typename T, typename... Args>
+ struct has_constructor:
+ public itself<decltype(has_constructor_helper(try_first(),
+ std::declval<T>(),
+ std::declval<Args>()...))>
+ ::type
+ {
+ };
+ }
+}
+
+#endif
Added: trunk/src/type_traits/has_member_hash.hh
===================================================================
--- trunk/src/type_traits/has_member_hash.hh (rev 0)
+++ trunk/src/type_traits/has_member_hash.hh 2010-10-05 21:07:06 UTC (rev 134)
@@ -0,0 +1,56 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#ifndef __HAS_MEMBER_HASH_HH
+# define __HAS_MEMBER_HASH_HH
+
+# include <type_traits>
+# include "itself.hh"
+# include "overloading_priority.hh"
+
+namespace aurelia {
+ namespace type_traits {
+
+ /*! \brief Helper for hash_member_hash
+ */
+ template <typename T,
+ typename = decltype(std::declval<const T>().hash())>
+ std::true_type has_member_hash_helper(try_first, T) {
+ return 0;
+ }
+
+ /*! \brief Helper for hash_member_hash
+ */
+ template <typename T>
+ std::false_type has_member_hash_helper(try_second, T) {
+ return 0;
+ }
+
+ /*! \brief Type traits telling wether a type has a hash method.
+ */
+ template <typename T>
+ struct has_member_hash {
+ typedef
+ typename itself<
+ decltype(has_member_hash_helper(try_first(),
+ std::declval<const T>()))>::type type;
+ enum { value = type::value };
+ };
+
+ }
+}
+
+#endif
Added: trunk/src/type_traits/is_same_ellipsis.hh
===================================================================
--- trunk/src/type_traits/is_same_ellipsis.hh (rev 0)
+++ trunk/src/type_traits/is_same_ellipsis.hh 2010-10-05 21:07:06 UTC (rev 134)
@@ -0,0 +1,40 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#ifndef __IS_SAME_ELLIPSIS_HH
+# define __IS_SAME_ELLIPSIS_HH
+
+# include <type_traits>
+
+namespace aurelia {
+ namespace type_traits {
+
+ /*! \brief Tells if a the same as the first of a packed type.
+ */
+ template <typename T, typename...>
+ struct is_same_ellipsis
+ {
+ };
+
+ template <typename T, typename Arg, typename... Args>
+ struct is_same_ellipsis<T, Arg, Args...>:
+ public std::is_same<T, Arg>
+ {
+ };
+ }
+}
+
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-10-05 20:59:21
|
Revision: 133
http://aurelia.svn.sourceforge.net/aurelia/?rev=133&view=rev
Author: valentindavid
Date: 2010-10-05 20:59:15 +0000 (Tue, 05 Oct 2010)
Log Message:
-----------
2010-10-05 Valentin David <val...@ii...>
* src/sig/tests/test.cc,
* src/sig/tests/stratego.rtree,
* src/sig/tests/Makefile.am,
* src/sig/sig.cc,
* src/sig/Makefile.am:
Remove as code is deprecated.
* src/Makefile.am (SUBDIRS): Update.
* configure.ac (AC_CONFIG_FILES): Update.
Modified Paths:
--------------
trunk/ChangeLog
trunk/configure.ac
trunk/src/Makefile.am
Removed Paths:
-------------
trunk/src/sig/
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-10-05 20:53:56 UTC (rev 132)
+++ trunk/ChangeLog 2010-10-05 20:59:15 UTC (rev 133)
@@ -1,5 +1,17 @@
2010-10-05 Valentin David <val...@ii...>
+ * src/sig/tests/test.cc,
+ * src/sig/tests/stratego.rtree,
+ * src/sig/tests/Makefile.am,
+ * src/sig/sig.cc,
+ * src/sig/Makefile.am:
+ Remove as code is deprecated.
+
+ * src/Makefile.am (SUBDIRS): Update.
+ * configure.ac (AC_CONFIG_FILES): Update.
+
+2010-10-05 Valentin David <val...@ii...>
+
* src/patterns/variable.hh: Use auto_ptr instead of DelayedConstr.
* src/patterns/pattern.hh: Update includes.
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2010-10-05 20:53:56 UTC (rev 132)
+++ trunk/configure.ac 2010-10-05 20:59:15 UTC (rev 133)
@@ -103,8 +103,6 @@
AC_SUBST([CSF], ["$MISSING PARSER_GEN"])
])
-AC_SUBST([SIG], ['$(top_builddir)/src/sig/sig'])
-
if test "x$RELEASE" = xyes
then
PACKAGE_FULLVERSION=${PACKAGE_VERSION}
@@ -170,8 +168,6 @@
src/patterns/Makefile
src/llstack/Makefile
src/llstack/tests/Makefile
- src/sig/Makefile
- src/sig/tests/Makefile
src/threads/Makefile
src/Makefile
src/relations/Makefile
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2010-10-05 20:53:56 UTC (rev 132)
+++ trunk/src/Makefile.am 2010-10-05 20:59:15 UTC (rev 133)
@@ -27,7 +27,6 @@
terms \
threads \
box \
- sig \
parser_generator
nodist_aurelia_HEADERS=aurelia-config.hh
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-10-05 20:54:03
|
Revision: 132
http://aurelia.svn.sourceforge.net/aurelia/?rev=132&view=rev
Author: valentindavid
Date: 2010-10-05 20:53:56 +0000 (Tue, 05 Oct 2010)
Log Message:
-----------
2010-10-05 Valentin David <val...@ii...>
* src/patterns/variable.hh: Use auto_ptr instead of DelayedConstr.
* src/patterns/pattern.hh: Update includes.
* src/patterns/delayed_constr.hh: Remove.
* src/patterns/Makefile.am: Update.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/patterns/Makefile.am
trunk/src/patterns/pattern.hh
trunk/src/patterns/variable.hh
Removed Paths:
-------------
trunk/src/patterns/delayed_constr.hh
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-09-05 00:43:40 UTC (rev 131)
+++ trunk/ChangeLog 2010-10-05 20:53:56 UTC (rev 132)
@@ -1,3 +1,12 @@
+2010-10-05 Valentin David <val...@ii...>
+
+ * src/patterns/variable.hh: Use auto_ptr instead of DelayedConstr.
+
+ * src/patterns/pattern.hh: Update includes.
+
+ * src/patterns/delayed_constr.hh: Remove.
+ * src/patterns/Makefile.am: Update.
+
2010-09-05 Valentin David <val...@ii...>
* examples: Remove.
Modified: trunk/src/patterns/Makefile.am
===================================================================
--- trunk/src/patterns/Makefile.am 2010-09-05 00:43:40 UTC (rev 131)
+++ trunk/src/patterns/Makefile.am 2010-10-05 20:53:56 UTC (rev 132)
@@ -17,7 +17,6 @@
patternsdir=$(aureliadir)/patterns
patterns_HEADERS= \
- delayed_constr.hh \
pattern.hh \
pair.hh \
term_pattern.hh \
Deleted: trunk/src/patterns/delayed_constr.hh
===================================================================
--- trunk/src/patterns/delayed_constr.hh 2010-09-05 00:43:40 UTC (rev 131)
+++ trunk/src/patterns/delayed_constr.hh 2010-10-05 20:53:56 UTC (rev 132)
@@ -1,86 +0,0 @@
-// This file is a part of Aurelia.
-// Copyright (C) 2010 Valentin David
-// Copyright (C) 2010 University of Bergen
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#ifndef __DELAYED_CONSTR_HH
-# define __DELAYED_CONSTR_HH
-
-namespace aurelia {
-
-#ifndef NDEBUG
-struct Uninitialized {
- Uninitialized(void*) {}
-};
-#endif
-
-#pragma GCC diagnostic ignored "-Wstrict-aliasing"
-
-template <typename T>
-struct DelayedConstr {
-private:
- char data[sizeof(T)]
- __attribute__ ((aligned (__alignof__(T))));
- bool init;
-public:
- DelayedConstr(): init(false) {}
- ~DelayedConstr() {
- if (init)
- ((T*)data)->~T();
- }
-
- bool has_value() const {
- return init;
- }
-
- void reset () {
- this->~DelayedConstr();
- new (this) DelayedConstr();
- }
-
- void build(const T& o) {
- if (init)
- ((T*)data)->~T();
- new ((void*)data) T(o);
- init = true;
- }
-
- void build() {
- if (init)
- ((T*)data)->~T();
- new ((void*)data) T();
- init = true;
- }
-
- T& o() {
-#ifndef NDEBUG
- if (!init)
- throw Uninitialized(data);
-#endif
- return *(T*)(data);
- }
-
- const T& o() const {
-#ifndef NDEBUG
- if (!init)
- throw Uninitialized(data);
-#endif
- return *(const T*)(data);
- }
-};
-
-}
-
-#endif
-
Modified: trunk/src/patterns/pattern.hh
===================================================================
--- trunk/src/patterns/pattern.hh 2010-09-05 00:43:40 UTC (rev 131)
+++ trunk/src/patterns/pattern.hh 2010-10-05 20:53:56 UTC (rev 132)
@@ -18,7 +18,6 @@
# define __PATTERN_HH
# include <cassert>
-# include "delayed_constr.hh"
# include "../terms/constructor.hh"
# include "../terms/term.hh"
# include "../strategies/failure.hh"
Modified: trunk/src/patterns/variable.hh
===================================================================
--- trunk/src/patterns/variable.hh 2010-09-05 00:43:40 UTC (rev 131)
+++ trunk/src/patterns/variable.hh 2010-10-05 20:53:56 UTC (rev 132)
@@ -27,24 +27,23 @@
template <typename T>
struct Variable {
private:
- std::shared_ptr<std::stack<DelayedConstr<T> > > value;
+ std::shared_ptr<std::stack<std::auto_ptr<T> > > value;
public:
- Variable(): value(new std::stack<DelayedConstr<T> >()) {
- value->push(DelayedConstr<T>());
+ Variable(): value(new std::stack<std::auto_ptr<T> >()) {
+ value->push(std::auto_ptr<T>(NULL));
}
Variable(const Variable& v): value(v.value) {
}
- Variable(const T& v): value(new std::stack<DelayedConstr<T> >()) {
- value->push(DelayedConstr<T>());
- value->top().build(v);
+ Variable(const T& v): value(new std::stack<std::auto_ptr<T> >()) {
+ value->push(std::auto_ptr<T>(new T(v)));
}
void push() const {
- value->push(DelayedConstr<T>());
+ value->push(std::auto_ptr<T>(NULL));
}
void pop() const {
@@ -52,27 +51,28 @@
}
bool has_value() const {
- return value->top().has_value();
+ return value->top().get() != NULL;
}
const T& operator*() const {
- if (!value->top().has_value())
+ if (!has_value())
throw Failure();
- return value->top().o();
+ return *(value->top());
}
const T& operator=(const T& c) {
- if (value->top().has_value()) {
- if (c != value->top().o())
+ if (has_value()) {
+ if (c != *(value->top()))
throw Failure();
- return value->top().o();
+ return *(value->top());
}
- value->top().build(c);
- return value->top().o();
+ value->top().reset(new T(c));
+ return *(value->top());
}
void reset() const {
- value->top().reset();
+ value->top().release();
+ value->top().reset(NULL);
}
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-09-05 00:43:47
|
Revision: 131
http://aurelia.svn.sourceforge.net/aurelia/?rev=131&view=rev
Author: valentindavid
Date: 2010-09-05 00:43:40 +0000 (Sun, 05 Sep 2010)
Log Message:
-----------
2010-09-05 Valentin David <val...@ii...>
* configure.ac: Check for svn revision.
* Makefile.am (EXTRA_DIST): Add missing files.
Modified Paths:
--------------
examples/til/ChangeLog
examples/til/Makefile.am
examples/til/configure.ac
Property Changed:
----------------
examples/til/
Property changes on: examples/til
___________________________________________________________________
Modified: svn:ignore
- Makefile
Makefile.in
.deps
TIL.hh
tilc
aclocal.m4
autom4te.cache
config.log
config.status
configure
+ Makefile
Makefile.in
.deps
TIL.hh
tilc
aclocal.m4
autom4te.cache
config.log
config.status
configure
svnrev
Modified: examples/til/ChangeLog
===================================================================
--- examples/til/ChangeLog 2010-09-05 00:21:41 UTC (rev 130)
+++ examples/til/ChangeLog 2010-09-05 00:43:40 UTC (rev 131)
@@ -1,4 +1,9 @@
2010-09-05 Valentin David <val...@ii...>
+ * configure.ac: Check for svn revision.
+ * Makefile.am (EXTRA_DIST): Add missing files.
+
+2010-09-05 Valentin David <val...@ii...>
+
Initial package. See Aurlia's ChangeLog for previous history of
files.
Modified: examples/til/Makefile.am
===================================================================
--- examples/til/Makefile.am 2010-09-05 00:21:41 UTC (rev 130)
+++ examples/til/Makefile.am 2010-09-05 00:43:40 UTC (rev 131)
@@ -18,3 +18,8 @@
SUBDIRS=src tests
ACLOCAL_AMFLAGS=-I config
+
+EXTRA_DIST= \
+ amlib/lang/csf.pm \
+ amlib/am/csf.am \
+ svnrev
Modified: examples/til/configure.ac
===================================================================
--- examples/til/configure.ac 2010-09-05 00:21:41 UTC (rev 130)
+++ examples/til/configure.ac 2010-09-05 00:43:40 UTC (rev 131)
@@ -47,6 +47,18 @@
AC_SUBST([aurelia_CPPFLAGS],["$aurelia_CFLAGS"])
aurelia_CFLAGS=""
+AC_ARG_VAR([SVN], [svn command])
+
+if test -f $srcdir/svnrev; then
+ svnrev=`cat $srcdir/svnrev`
+else
+ AC_CHECK_PROGS([SVN], [svn], [
+ AC_MSG_ERROR([svn is mssing!])
+ ])
+ svnrev=`$SVN info 2>/dev/null | sed "/Revision: /{;s///;q;};d"`
+ AS_ECHO([$svnrev]) >$srcdir/svnrev 2>/dev/null
+fi
+
if test "x$RELEASE" = xyes
then
PACKAGE_FULLVERSION=${PACKAGE_VERSION}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-09-05 00:21:49
|
Revision: 130
http://aurelia.svn.sourceforge.net/aurelia/?rev=130&view=rev
Author: valentindavid
Date: 2010-09-05 00:21:41 +0000 (Sun, 05 Sep 2010)
Log Message:
-----------
Extract TIL example from package.
Modified Paths:
--------------
examples/til/tests/Makefile.am
trunk/ChangeLog
trunk/Makefile.am
trunk/bootstrap
trunk/configure.ac
trunk/src/lists/Makefile.am
Added Paths:
-----------
examples/
examples/til/ChangeLog
examples/til/Makefile.am
examples/til/bootstrap
examples/til/config/
examples/til/config/cxx.m4
examples/til/configure.ac
examples/til/src/
examples/til/src/Makefile.am
examples/til/src/TIL.cc
examples/til/src/TIL.csf
examples/til/src/TIL_main.cc
Removed Paths:
-------------
examples/Makefile.am
examples/til/Makefile.am
examples/til/TIL.cc
examples/til/TIL.csf
examples/til/TIL_main.cc
trunk/examples/
Property Changed:
----------------
examples/til/
Deleted: examples/Makefile.am
===================================================================
--- trunk/examples/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
+++ examples/Makefile.am 2010-09-05 00:21:41 UTC (rev 130)
@@ -1,18 +0,0 @@
-# This file is a part of Aurelia.
-# Copyright (C) 2010 Valentin David
-# Copyright (C) 2010 University of Bergen
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-SUBDIRS=til
Property changes on: examples/til
___________________________________________________________________
Modified: svn:ignore
- Makefile
Makefile.in
.deps
TIL.hh
tilc
+ Makefile
Makefile.in
.deps
TIL.hh
tilc
aclocal.m4
autom4te.cache
config.log
config.status
configure
Added: svn:externals
+ amlib -r 129 https://svn.aurelia.cx/svnroot/aurelia/trunk/amlib
Added: examples/til/ChangeLog
===================================================================
--- examples/til/ChangeLog (rev 0)
+++ examples/til/ChangeLog 2010-09-05 00:21:41 UTC (rev 130)
@@ -0,0 +1,4 @@
+2010-09-05 Valentin David <val...@ii...>
+
+ Initial package. See Aurlia's ChangeLog for previous history of
+ files.
Deleted: examples/til/Makefile.am
===================================================================
--- trunk/examples/til/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
+++ examples/til/Makefile.am 2010-09-05 00:21:41 UTC (rev 130)
@@ -1,26 +0,0 @@
-# This file is a part of Aurelia.
-# Copyright (C) 2010 Valentin David
-# Copyright (C) 2010 University of Bergen
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-include $(top_srcdir)/config/local_parser_gen.mk
-
-check_PROGRAMS=tilc
-tilc_SOURCES=TIL_main.cc TIL.cc TIL.csf
-
-TIL.hh: $(CSF)
-
-CLEANFILES=TIL.hh
-SUBDIRS=tests
Added: examples/til/Makefile.am
===================================================================
--- examples/til/Makefile.am (rev 0)
+++ examples/til/Makefile.am 2010-09-05 00:21:41 UTC (rev 130)
@@ -0,0 +1,20 @@
+# This file is a part of Aurelia.
+# Copyright (C) 2010 Valentin David
+# Copyright (C) 2010 University of Bergen
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+SUBDIRS=src tests
+
+ACLOCAL_AMFLAGS=-I config
Deleted: examples/til/TIL.cc
===================================================================
--- trunk/examples/til/TIL.cc 2010-09-04 23:12:03 UTC (rev 129)
+++ examples/til/TIL.cc 2010-09-05 00:21:41 UTC (rev 130)
@@ -1,110 +0,0 @@
-// This file is a part of Aurelia.
-// Copyright (C) 2010 Valentin David
-// Copyright (C) 2010 University of Bergen
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include <sstream>
-#include <iostream>
-#include <fstream>
-#include "llstack/queue.hh"
-#include "llstack/node.hh"
-#include "streams/buf_stream.hh"
-#include "llstack/label.hh"
-#include "llstack/node.hpp"
-#include "terms/term.hh"
-
-using namespace aurelia;
-using namespace llstack;
-struct Main {};
-typedef Term<Main> T;
-typedef Constructor<Main> C;
-
-frame pop_void(const frame& f) {
- return f.as<ret_frame<VoidReturn> >().parent;
-}
-
-#include "TIL.hh"
-
-bool found;
-T result;
-
-struct Start {
- void operator()(R_t&, const frame& f, stream& s, const node&) const {
- if (s.eof()) {
- std::cout << "Found!" << std::endl;
- ret_frame<T> rf0 = f.as<ret_frame<T> >();
- if (found) {
- assert(result == rf0.t);
- }
- else
- result = rf0.t;
- found = true;
- }
- }
-};
-
-struct End {
- void operator()(R_t&, const frame&, stream&, const node&) const {
- }
-};
-
-bool main_loop(stream& s, const stream& end) {
- found = false;
- R_t R;
- if (s.eof()) {
- if (!is_empty_first(Program_0_0))
- { error(); }
- }
- else if (!is_first(s, Program_0_0)) {
- { error(); }
- }
- node u1 = node::boundary(Start(), end);
- node u0 = node::boundary(End(), end);
- u1.parents().insert(u0);
- Program start;
- start(R, empty_frame(), s, u1);
- // int lastpos = -1;
- try {
- while (true) {
- descriptor d = R.pop();
- s = d.s;
- //if (lastpos < s.get_pos()) {
- //lastpos = s.get_pos();
- //std::stringstream ss;
- //ss << "graph." << s.get_pos();
- //std::ofstream out(ss.str());
- //std::cerr << lastpos << std::endl;
- //node::printnodes(out);
- //}
- d.L.call(R, d.f, d.s, d.n);
- }
- } catch (R_t::Eof) {
- }
-
- node::clear();
- return found;
-}
-
-T parse_TIL(std::istream& in) {
- buf_stream bs(in);
- stream s = bs.begin();
- if (main_loop(s, bs.end())) {
- std::cerr << result << std::endl;
- T ret = result;
- result.~T();
- return ret;
- }
- throw Failure();
-}
Deleted: examples/til/TIL.csf
===================================================================
--- trunk/examples/til/TIL.csf 2010-09-04 23:12:03 UTC (rev 129)
+++ examples/til/TIL.csf 2010-09-05 00:21:41 UTC (rev 130)
@@ -1,270 +0,0 @@
-//Programs
-Program ::= LAYOUT? Stat* LAYOUT?
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(C("Program", 1), (rf0.t)); $
-
-Stat+ ::= Stat LAYOUT? Stat*
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C::AS_LIST, (rf1.t, rf0.t)); $
-Stat* ::= Stat+
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(rf0.t); $
- | $ T ret(C::AS_EMPTY_LIST); $
-
-//LAYOUT
-LAYOUT? ::= LAYOUT+ |
- $ if (!s.eof()) {
- switch (*s) {
- case ' ':
- case '\r':
- case '\n':
- case '\t':
- return ;
- case '/':
- {
- buf_stream_iterator next = s;
- ++next;
- if (!next.eof()) {
- if (*next == '/')
- return ;
- }
- }
- }
- }
- VoidReturn ret;
- $ |
- $ if (!s.eof()) {
- switch (*s) {
- case ' ':
- case '\r':
- case '\n':
- case '\t':
- return ;
- case '/':
- {
- buf_stream_iterator next = s;
- ++next;
- if (!next.eof()) {
- if (*next == '/')
- return ;
- }
- }
- }
- }
- VoidReturn ret;
- $
-
-LAYOUT+ ::= LAYOUT LAYOUT?
-LAYOUT ::=
- " " | "\n" | "\r" | "\t"
- | "//" Line
-Line ::= "\n" | [^\n] Line
-
-//Literals
-
-Alpha ::= [A-Z]|[a-z]
-Num ::= [0-9]
-AlphaNum ::= Alpha | Num
-StrChar ::= [^\"\\\n] | "\\" [\"\\n]
-
-AlphaNum+ ::= AlphaNum AlphaNum*
-AlphaNum* ::= AlphaNum+ |
-
-Num* ::= Num+ |
-Num+ ::= Num Num*
-StrChar* ::= StrChar StrChar* |
-
-Id ::= $ ret_frame<stream> next_frame(f, s); $
- Alpha AlphaNum*
- $ if (!s.eof()) {
- if (((*s) >= '0') && (*s) <= '9')
- return ;
- if (((*s) >= 'A') && (*s) <= 'Z')
- return ;
- if (((*s) >= 'a') && (*s) <= 'z')
- return ;
- }
- ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
- T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
- $
-
-Int ::= $ ret_frame<stream> next_frame(f, s); $
- Num+
- $ if (!s.eof()) {
- if (((*s) >= '0') && (*s) <= '9')
- return ;
- }
- ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
- T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
- $
-
-String ::= $ ret_frame<stream> next_frame(f, s); $ "\"" StrChar* "\""
- $ ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
- T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
- $
-
-//Expressions
-
-AtomExp ::= "true" $ T ret(C("True")); $
- | "false" $ T ret(C("True")); $
- | Id
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(C("Var", 1), rf0.t); $
- |
- Int
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(C("Int", 1), rf0.t); $
- | String
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(C("String", 1), rf0.t); $
- | "(" LAYOUT? $ frame next_frame(f); $Exp LAYOUT? ")"
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(rf0.t); $
- | Id LAYOUT? "(" LAYOUT? Exp* LAYOUT? ")"
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("FunCall", 2), (rf1.t, rf0.t)); $
-
-ModExp ::= AtomExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(rf0.t); $
- | AtomExp LAYOUT? "%" LAYOUT? AtomExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("Mod", 2), (rf1.t, rf0.t)); $
-
-
-MulExp ::= ModExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(rf0.t); $
- | MulExp LAYOUT? "*" LAYOUT? ModExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("Mul", 2), (rf1.t, rf0.t)); $
- | MulExp LAYOUT? "/" LAYOUT? ModExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("Div", 2), (rf1.t, rf0.t)); $
-
-
-AddExp ::= MulExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(rf0.t); $
- | AddExp LAYOUT? "+" LAYOUT? MulExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("Add", 2), (rf1.t, rf0.t)); $
- | AddExp LAYOUT? "-" LAYOUT? MulExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("Sub", 2), (rf1.t, rf0.t)); $
-
-CompExp ::= AddExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(rf0.t); $
- | AddExp LAYOUT? "<" LAYOUT? AddExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("Lt", 2), (rf1.t, rf0.t)); $
- | AddExp LAYOUT? ">" LAYOUT? AddExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("Gt", 2), (rf1.t, rf0.t)); $
- | AddExp LAYOUT? "<=" LAYOUT? AddExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("Leq", 2), (rf1.t, rf0.t)); $
- | AddExp LAYOUT? ">=" LAYOUT? AddExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("Geq", 2), (rf1.t, rf0.t)); $
- | AddExp LAYOUT? "=" LAYOUT? AddExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("Equ", 2), (rf1.t, rf0.t)); $
- | AddExp LAYOUT? "!=" LAYOUT? AddExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("Neq", 2), (rf1.t, rf0.t)); $
-
-
-AndExp ::= CompExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(rf0.t); $
- | AndExp LAYOUT? $ frame next_frame(f); $"&" LAYOUT? CompExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("And", 2), (rf1.t, rf0.t)); $
-
-OrExp ::= AndExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(rf0.t); $
- | OrExp LAYOUT? "|" LAYOUT? AndExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("Or", 2), (rf1.t, rf0.t)); $
-
-Exp ::= OrExp
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(rf0.t); $
-
-//Statements
-
-Stat ::= "var" LAYOUT? Id LAYOUT? ";"
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(C("Declaration", 1), (rf0.t)); $
- | "var" LAYOUT? Id LAYOUT? ":" LAYOUT? Type LAYOUT? ";"
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("DeclarationTyped", 2), (rf1.t, rf0.t)); $
- | Id LAYOUT? ":=" LAYOUT? Exp LAYOUT? ";"
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("Assign", 2), (rf1.t, rf0.t)); $
- | "begin" LAYOUT? Stat* LAYOUT? "end"
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(C("Block", 1), (rf0.t)); $
- | "if" LAYOUT? Exp LAYOUT? "then" LAYOUT? Stat* LAYOUT? "end"
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("IfThen", 2), (rf1.t, rf0.t)); $
- | "if" LAYOUT? Exp LAYOUT? "then" LAYOUT? Stat* LAYOUT? "else" LAYOUT? Stat* LAYOUT? "end"
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- ret_frame<T> rf2 = rf1.parent.as<ret_frame<T> >();
- T ret(C("IfElse", 3), (rf2.t, rf1.t, rf0.t)); $
- | "while" LAYOUT? Exp LAYOUT? "do" LAYOUT? Stat* LAYOUT? "end"
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("While", 2), (rf1.t, rf0.t)); $
- | "for" LAYOUT? Id LAYOUT? ":=" LAYOUT? Exp LAYOUT? "to" LAYOUT? Exp LAYOUT? "do" LAYOUT? Stat LAYOUT? "end"
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- ret_frame<T> rf2 = rf1.parent.as<ret_frame<T> >();
- ret_frame<T> rf3 = rf2.parent.as<ret_frame<T> >();
- T ret(C("For", 4), (rf3.t, rf2.t, rf1.t, rf0.t)); $
- | Id LAYOUT? "(" LAYOUT? Exp* LAYOUT? ")" LAYOUT? ";"
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C("ProcCall", 2), (rf1.t, rf0.t)); $
-
-//Types
-Type ::= Id
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(C("TypeName", 1), (rf0.t)); $
-
-//Calls
-
-ExpL ::= "," LAYOUT? Exp+
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(rf0.t); $
- | $ T ret(C::AS_EMPTY_LIST); $
-Exp+ ::= Exp LAYOUT? ExpL
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- T ret(C::AS_LIST, (rf1.t, rf0.t)); $
-Exp* ::= Exp+
- $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
- T ret(rf0.t); $
- | $ T ret(C::AS_EMPTY_LIST); $
Deleted: examples/til/TIL_main.cc
===================================================================
--- trunk/examples/til/TIL_main.cc 2010-09-04 23:12:03 UTC (rev 129)
+++ examples/til/TIL_main.cc 2010-09-05 00:21:41 UTC (rev 130)
@@ -1,23 +0,0 @@
-#include <fstream>
-#include "terms/term.hh"
-
-using namespace aurelia;
-struct Main {};
-typedef Term<Main> T;
-
-T parse_TIL(std::istream& in);
-int main(int argc, char* argv[])
-{
- if (argc != 2)
- return 1;
- try {
- std::ifstream in(argv[1]);
- std::cerr << parse_TIL(in) << std::endl;
- } catch (Failure) {
- std::cerr << "Rewriting failed." << std::endl;
-
- return 1;
- }
-
- return 0;
-}
Added: examples/til/bootstrap
===================================================================
--- examples/til/bootstrap (rev 0)
+++ examples/til/bootstrap 2010-09-05 00:21:41 UTC (rev 130)
@@ -0,0 +1,4 @@
+#! /bin/bash -e
+
+export AUTOMAKE="'${AUTOMAKE:-automake}' --libdir=:amlib"
+autoreconf -f -v -i
Property changes on: examples/til/bootstrap
___________________________________________________________________
Added: svn:executable
+ *
Property changes on: examples/til/config
___________________________________________________________________
Added: svn:ignore
+ config.guess
config.h
config.h.in
config.h.in~
config.sub
depcomp
install-sh
ltmain.sh
lt~obsolete.m4
ltoptions.m4
ltsugar.m4
ltversion.m4
libtool.m4
missing
Added: examples/til/config/cxx.m4
===================================================================
--- examples/til/config/cxx.m4 (rev 0)
+++ examples/til/config/cxx.m4 2010-09-05 00:21:41 UTC (rev 130)
@@ -0,0 +1,160 @@
+dnl This file is a part of Aurelia.
+dnl Copyright (C) 2010 Valentin David
+dnl Copyright (C) 2010 University of Bergen
+dnl
+dnl This program is free software: you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation, either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AC_DEFUN([NOTCXX0X], [
+ AC_MSG_ERROR([$1. Is $CXX a C++0x compiler?])
+])
+
+AC_DEFUN([NOTCXX03], [
+ AC_MSG_ERROR([$1. Is $CXX standard compliant?])
+])
+
+AC_DEFUN([CHECK_CXX0X_HEADER], [
+ AC_LANG_PUSH([C++])
+ AC_CHECK_HEADER([$1],[],[
+ NOTCXX0X([Header $1 set is missing])
+ ])
+ AC_LANG_POP
+])
+
+AC_DEFUN([CHECK_CXX03_HEADER], [
+ AC_LANG_PUSH([C++])
+ AC_CHECK_HEADER([$1],[],[
+ NOTCXX03([Header $1 is missing])
+ ])
+ AC_LANG_POP
+])
+
+AC_DEFUN([CHECK_CXX0X_HEADERS], [
+ AH_CHECK_HEADERS([$1])
+ m4_map_args_w([$1],[CHECK_CXX0X_HEADER(],[)])
+])
+
+AC_DEFUN([CHECK_CXX03_HEADERS], [
+ AH_CHECK_HEADERS([$1])
+ m4_map_args_w([$1],[CHECK_CXX03_HEADER(],[)])
+])
+
+AC_DEFUN([CXX0X_FUNCTION],[
+AC_MSG_CHECKING([whether std::function exists])
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <functional>
+struct Fun {
+ int operator()(int) const {
+ return 0;
+ }
+};
+int test() {
+ std::function<int(int)> f = Fun();
+ return f(0);
+}
+]])],[AC_MSG_RESULT([yes])],[dnl
+ AC_MSG_RESULT([no])
+ NOTCXX0X([std::function is missing])
+])
+AC_LANG_POP
+])
+
+AC_DEFUN([CXX0X_LAMBDAS],[
+AC_MSG_CHECKING([whether the compiler supports lambda expressions])
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int test(int n) {
+ return [] (int n) { return n; }(n);
+}
+]])],[AC_MSG_RESULT([yes])],[dnl
+ AC_MSG_RESULT([no])
+ NOTCXX0X([Lambda expression are not supported])
+])
+AC_LANG_POP
+])
+
+AC_DEFUN([CXX0X_TYPED_ENUMS],[
+AC_MSG_CHECKING([whether enums can be typed])
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+enum foo : unsigned { bar = 0 };
+]])],[AC_MSG_RESULT([yes])],[dnl
+ AC_MSG_RESULT([no])
+ NOTCXX0X([Enumerations cannot be typed])
+])
+AC_LANG_POP
+])
+
+AC_DEFUN([CXX0X_AUTO],[
+AC_MSG_CHECKING([whether keyword auto can be used as a type])
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+int foo() {
+ auto i = 0;
+ return i;
+}
+]])],[AC_MSG_RESULT([yes])],[dnl
+ AC_MSG_RESULT([no])
+ NOTCXX0X([Keyword auto is not usable])
+])
+AC_LANG_POP
+])
+
+AC_DEFUN([CXX0X_DECLTYPE],[
+AC_MSG_CHECKING([whether keyword decltype is supported])
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+static int t;
+decltype(t) foo() {
+ return 0;
+}
+]])],[AC_MSG_RESULT([yes])],[dnl
+ AC_MSG_RESULT([no])
+ NOTCXX0X([Keyword decltype is not supported])
+])
+AC_LANG_POP
+])
+
+AC_DEFUN([CXX0X_FLAG],[
+AC_MSG_CHECKING([whether the C++ compiler accepts -std=c++0x.])
+AC_LANG_PUSH([C++])
+oldCPPFLAGS="$CPPFLAGS"
+CPPFLAGS="-std=c++0x $CPPFLAGS"
+AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([[]])],
+ [EXTRACPPFLAGS="-std=c++0x"
+ AC_MSG_RESULT([yes])],
+ [EXTRACPPFLAGS=""
+ AC_MSG_RESULT([no])])
+CPPFLAGS="$EXTRACPPFLAGS $oldCPPFLAGS"
+AC_LANG_POP
+])
+
+AC_DEFUN([CXX_WALL],[
+if ! test "$ac_test_CXXFLAGS" = set; then
+ AC_LANG_PUSH([C++])
+ oldCXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -W -Wall"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[],[CXXFLAGS="$oldCXXFLAGS"])
+ AC_LANG_POP
+fi
+])
+
+AC_DEFUN([CXX_WERROR],[
+if ! test "$ac_test_CXXFLAGS" = set; then
+ AC_LANG_PUSH([C++])
+ oldCXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -Werror"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[],[CXXFLAGS="$oldCXXFLAGS"])
+ AC_LANG_POP
+fi
+])
Added: examples/til/configure.ac
===================================================================
--- examples/til/configure.ac (rev 0)
+++ examples/til/configure.ac 2010-09-05 00:21:41 UTC (rev 130)
@@ -0,0 +1,80 @@
+# This file is a part of Aurelia.
+# Copyright (C) 2010 Valentin David
+# Copyright (C) 2010 University of Bergen
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AC_PREREQ([2.67])
+
+AC_INIT([aurelia-til], [0.1],dnl
+[aur...@li...],dnl
+[aurelia-til],dnl
+[http://aurelia.cx/]dnl
+)
+RELEASE=no
+
+AC_CONFIG_AUX_DIR([config])
+AC_CONFIG_MACRO_DIR([config])
+AC_CONFIG_HEADERS([config/config.h])
+
+AM_INIT_AUTOMAKE([1.11a foreign dist-bzip2 tar-pax color-tests parallel-tests])
+AM_SILENT_RULES([yes])
+
+AC_LANG_CPLUSPLUS
+AC_PROG_CXX
+if ! test "$ac_test_CXXFLAGS" = set; then
+ CXXFLAGS=`echo "$CXXFLAGS" | sed "s/-O2/-O3/g"`
+fi
+CXX_WALL
+dnl CXX_WERROR
+
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+
+
+PKG_CHECK_MODULES([aurelia], [aurelia])
+AC_SUBST([aurelia_CPPFLAGS],["$aurelia_CFLAGS"])
+aurelia_CFLAGS=""
+
+if test "x$RELEASE" = xyes
+then
+ PACKAGE_FULLVERSION=${PACKAGE_VERSION}
+else
+ PACKAGE_FULLVERSION=${PACKAGE_VERSION}-pre$svnrev
+ VERSION=${PACKAGE_FULLVERSION}
+fi
+
+AC_SUBST([PACKAGE_FULLVERSION])
+
+AC_ARG_VAR([VALGRIND], [set valgrind path for testing])
+
+AC_CHECK_PROGS([VALGRIND], [valgrind])
+AM_CONDITIONAL([HAVE_VALGRIND], [test -n "$VALGRIND"])
+
+AC_ARG_VAR([CSF], [set path to the parser_generator])
+AC_CHECK_PROGS([CSF], [parser_gen], [dnl
+ AC_MSG_ERROR([parser_gen is missing!])
+])
+
+DISTCHECK_CONFIGURE_FLAGS=`echo "$ac_configure_args" | sed "s/'--enable-bootstrap'//g;s/'--prefix=[[^']]*'//g;s/'--[[^-]]*dir=[[^']]*'//g"`
+
+AC_SUBST([DISTCHECK_CONFIGURE_FLAGS])
+
+AC_CONFIG_FILES([
+ Makefile
+ src/Makefile
+ tests/Makefile
+])
+
+AC_OUTPUT
Property changes on: examples/til/src
___________________________________________________________________
Added: svn:ignore
+ tilc
Makefile
Makefile.in
.deps
TIL.hh
Copied: examples/til/src/Makefile.am (from rev 129, trunk/examples/til/Makefile.am)
===================================================================
--- examples/til/src/Makefile.am (rev 0)
+++ examples/til/src/Makefile.am 2010-09-05 00:21:41 UTC (rev 130)
@@ -0,0 +1,22 @@
+# This file is a part of Aurelia.
+# Copyright (C) 2010 Valentin David
+# Copyright (C) 2010 University of Bergen
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+tilc_LDADD=$(aurelia_LIBS)
+tilc_CPPFLAGS=$(aurelia_CPPFLAGS)
+
+bin_PROGRAMS=tilc
+tilc_SOURCES=TIL_main.cc TIL.cc TIL.csf
Copied: examples/til/src/TIL.cc (from rev 129, trunk/examples/til/TIL.cc)
===================================================================
--- examples/til/src/TIL.cc (rev 0)
+++ examples/til/src/TIL.cc 2010-09-05 00:21:41 UTC (rev 130)
@@ -0,0 +1,110 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include <sstream>
+#include <iostream>
+#include <fstream>
+#include "llstack/queue.hh"
+#include "llstack/node.hh"
+#include "streams/buf_stream.hh"
+#include "llstack/label.hh"
+#include "llstack/node.hpp"
+#include "terms/term.hh"
+
+using namespace aurelia;
+using namespace llstack;
+struct Main {};
+typedef Term<Main> T;
+typedef Constructor<Main> C;
+
+frame pop_void(const frame& f) {
+ return f.as<ret_frame<VoidReturn> >().parent;
+}
+
+#include "TIL.hh"
+
+bool found;
+T result;
+
+struct Start {
+ void operator()(R_t&, const frame& f, stream& s, const node&) const {
+ if (s.eof()) {
+ std::cout << "Found!" << std::endl;
+ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ if (found) {
+ assert(result == rf0.t);
+ }
+ else
+ result = rf0.t;
+ found = true;
+ }
+ }
+};
+
+struct End {
+ void operator()(R_t&, const frame&, stream&, const node&) const {
+ }
+};
+
+bool main_loop(stream& s, const stream& end) {
+ found = false;
+ R_t R;
+ if (s.eof()) {
+ if (!is_empty_first(Program_0_0))
+ { error(); }
+ }
+ else if (!is_first(s, Program_0_0)) {
+ { error(); }
+ }
+ node u1 = node::boundary(Start(), end);
+ node u0 = node::boundary(End(), end);
+ u1.parents().insert(u0);
+ Program start;
+ start(R, empty_frame(), s, u1);
+ // int lastpos = -1;
+ try {
+ while (true) {
+ descriptor d = R.pop();
+ s = d.s;
+ //if (lastpos < s.get_pos()) {
+ //lastpos = s.get_pos();
+ //std::stringstream ss;
+ //ss << "graph." << s.get_pos();
+ //std::ofstream out(ss.str());
+ //std::cerr << lastpos << std::endl;
+ //node::printnodes(out);
+ //}
+ d.L.call(R, d.f, d.s, d.n);
+ }
+ } catch (R_t::Eof) {
+ }
+
+ node::clear();
+ return found;
+}
+
+T parse_TIL(std::istream& in) {
+ buf_stream bs(in);
+ stream s = bs.begin();
+ if (main_loop(s, bs.end())) {
+ std::cerr << result << std::endl;
+ T ret = result;
+ result.~T();
+ return ret;
+ }
+ throw Failure();
+}
Copied: examples/til/src/TIL.csf (from rev 129, trunk/examples/til/TIL.csf)
===================================================================
--- examples/til/src/TIL.csf (rev 0)
+++ examples/til/src/TIL.csf 2010-09-05 00:21:41 UTC (rev 130)
@@ -0,0 +1,270 @@
+//Programs
+Program ::= LAYOUT? Stat* LAYOUT?
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("Program", 1), (rf0.t)); $
+
+Stat+ ::= Stat LAYOUT? Stat*
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C::AS_LIST, (rf1.t, rf0.t)); $
+Stat* ::= Stat+
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | $ T ret(C::AS_EMPTY_LIST); $
+
+//LAYOUT
+LAYOUT? ::= LAYOUT+ |
+ $ if (!s.eof()) {
+ switch (*s) {
+ case ' ':
+ case '\r':
+ case '\n':
+ case '\t':
+ return ;
+ case '/':
+ {
+ buf_stream_iterator next = s;
+ ++next;
+ if (!next.eof()) {
+ if (*next == '/')
+ return ;
+ }
+ }
+ }
+ }
+ VoidReturn ret;
+ $ |
+ $ if (!s.eof()) {
+ switch (*s) {
+ case ' ':
+ case '\r':
+ case '\n':
+ case '\t':
+ return ;
+ case '/':
+ {
+ buf_stream_iterator next = s;
+ ++next;
+ if (!next.eof()) {
+ if (*next == '/')
+ return ;
+ }
+ }
+ }
+ }
+ VoidReturn ret;
+ $
+
+LAYOUT+ ::= LAYOUT LAYOUT?
+LAYOUT ::=
+ " " | "\n" | "\r" | "\t"
+ | "//" Line
+Line ::= "\n" | [^\n] Line
+
+//Literals
+
+Alpha ::= [A-Z]|[a-z]
+Num ::= [0-9]
+AlphaNum ::= Alpha | Num
+StrChar ::= [^\"\\\n] | "\\" [\"\\n]
+
+AlphaNum+ ::= AlphaNum AlphaNum*
+AlphaNum* ::= AlphaNum+ |
+
+Num* ::= Num+ |
+Num+ ::= Num Num*
+StrChar* ::= StrChar StrChar* |
+
+Id ::= $ ret_frame<stream> next_frame(f, s); $
+ Alpha AlphaNum*
+ $ if (!s.eof()) {
+ if (((*s) >= '0') && (*s) <= '9')
+ return ;
+ if (((*s) >= 'A') && (*s) <= 'Z')
+ return ;
+ if (((*s) >= 'a') && (*s) <= 'z')
+ return ;
+ }
+ ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
+ T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
+ $
+
+Int ::= $ ret_frame<stream> next_frame(f, s); $
+ Num+
+ $ if (!s.eof()) {
+ if (((*s) >= '0') && (*s) <= '9')
+ return ;
+ }
+ ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
+ T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
+ $
+
+String ::= $ ret_frame<stream> next_frame(f, s); $ "\"" StrChar* "\""
+ $ ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
+ T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
+ $
+
+//Expressions
+
+AtomExp ::= "true" $ T ret(C("True")); $
+ | "false" $ T ret(C("True")); $
+ | Id
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("Var", 1), rf0.t); $
+ |
+ Int
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("Int", 1), rf0.t); $
+ | String
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("String", 1), rf0.t); $
+ | "(" LAYOUT? $ frame next_frame(f); $Exp LAYOUT? ")"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | Id LAYOUT? "(" LAYOUT? Exp* LAYOUT? ")"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("FunCall", 2), (rf1.t, rf0.t)); $
+
+ModExp ::= AtomExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | AtomExp LAYOUT? "%" LAYOUT? AtomExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Mod", 2), (rf1.t, rf0.t)); $
+
+
+MulExp ::= ModExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | MulExp LAYOUT? "*" LAYOUT? ModExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Mul", 2), (rf1.t, rf0.t)); $
+ | MulExp LAYOUT? "/" LAYOUT? ModExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Div", 2), (rf1.t, rf0.t)); $
+
+
+AddExp ::= MulExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | AddExp LAYOUT? "+" LAYOUT? MulExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Add", 2), (rf1.t, rf0.t)); $
+ | AddExp LAYOUT? "-" LAYOUT? MulExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Sub", 2), (rf1.t, rf0.t)); $
+
+CompExp ::= AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | AddExp LAYOUT? "<" LAYOUT? AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Lt", 2), (rf1.t, rf0.t)); $
+ | AddExp LAYOUT? ">" LAYOUT? AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Gt", 2), (rf1.t, rf0.t)); $
+ | AddExp LAYOUT? "<=" LAYOUT? AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Leq", 2), (rf1.t, rf0.t)); $
+ | AddExp LAYOUT? ">=" LAYOUT? AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Geq", 2), (rf1.t, rf0.t)); $
+ | AddExp LAYOUT? "=" LAYOUT? AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Equ", 2), (rf1.t, rf0.t)); $
+ | AddExp LAYOUT? "!=" LAYOUT? AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Neq", 2), (rf1.t, rf0.t)); $
+
+
+AndExp ::= CompExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | AndExp LAYOUT? $ frame next_frame(f); $"&" LAYOUT? CompExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("And", 2), (rf1.t, rf0.t)); $
+
+OrExp ::= AndExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | OrExp LAYOUT? "|" LAYOUT? AndExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Or", 2), (rf1.t, rf0.t)); $
+
+Exp ::= OrExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+
+//Statements
+
+Stat ::= "var" LAYOUT? Id LAYOUT? ";"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("Declaration", 1), (rf0.t)); $
+ | "var" LAYOUT? Id LAYOUT? ":" LAYOUT? Type LAYOUT? ";"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("DeclarationTyped", 2), (rf1.t, rf0.t)); $
+ | Id LAYOUT? ":=" LAYOUT? Exp LAYOUT? ";"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Assign", 2), (rf1.t, rf0.t)); $
+ | "begin" LAYOUT? Stat* LAYOUT? "end"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("Block", 1), (rf0.t)); $
+ | "if" LAYOUT? Exp LAYOUT? "then" LAYOUT? Stat* LAYOUT? "end"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("IfThen", 2), (rf1.t, rf0.t)); $
+ | "if" LAYOUT? Exp LAYOUT? "then" LAYOUT? Stat* LAYOUT? "else" LAYOUT? Stat* LAYOUT? "end"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ ret_frame<T> rf2 = rf1.parent.as<ret_frame<T> >();
+ T ret(C("IfElse", 3), (rf2.t, rf1.t, rf0.t)); $
+ | "while" LAYOUT? Exp LAYOUT? "do" LAYOUT? Stat* LAYOUT? "end"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("While", 2), (rf1.t, rf0.t)); $
+ | "for" LAYOUT? Id LAYOUT? ":=" LAYOUT? Exp LAYOUT? "to" LAYOUT? Exp LAYOUT? "do" LAYOUT? Stat LAYOUT? "end"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ ret_frame<T> rf2 = rf1.parent.as<ret_frame<T> >();
+ ret_frame<T> rf3 = rf2.parent.as<ret_frame<T> >();
+ T ret(C("For", 4), (rf3.t, rf2.t, rf1.t, rf0.t)); $
+ | Id LAYOUT? "(" LAYOUT? Exp* LAYOUT? ")" LAYOUT? ";"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("ProcCall", 2), (rf1.t, rf0.t)); $
+
+//Types
+Type ::= Id
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("TypeName", 1), (rf0.t)); $
+
+//Calls
+
+ExpL ::= "," LAYOUT? Exp+
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | $ T ret(C::AS_EMPTY_LIST); $
+Exp+ ::= Exp LAYOUT? ExpL
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C::AS_LIST, (rf1.t, rf0.t)); $
+Exp* ::= Exp+
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | $ T ret(C::AS_EMPTY_LIST); $
Copied: examples/til/src/TIL_main.cc (from rev 129, trunk/examples/til/TIL_main.cc)
===================================================================
--- examples/til/src/TIL_main.cc (rev 0)
+++ examples/til/src/TIL_main.cc 2010-09-05 00:21:41 UTC (rev 130)
@@ -0,0 +1,23 @@
+#include <fstream>
+#include "terms/term.hh"
+
+using namespace aurelia;
+struct Main {};
+typedef Term<Main> T;
+
+T parse_TIL(std::istream& in);
+int main(int argc, char* argv[])
+{
+ if (argc != 2)
+ return 1;
+ try {
+ std::ifstream in(argv[1]);
+ std::cerr << parse_TIL(in) << std::endl;
+ } catch (Failure) {
+ std::cerr << "Rewriting failed." << std::endl;
+
+ return 1;
+ }
+
+ return 0;
+}
Modified: examples/til/tests/Makefile.am
===================================================================
--- trunk/examples/til/tests/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
+++ examples/til/tests/Makefile.am 2010-09-05 00:21:41 UTC (rev 130)
@@ -24,13 +24,15 @@
EXTRA_DIST=$(TESTS)
-../tilc:
- @cd .. && $(MAKE) $(AM_MAKEFLAGS) tilc
+$(TILC):
+ @cd ../src && $(MAKE) $(AM_MAKEFLAGS) tilc
-$(TEST_LOGS): ../tilc
+$(TEST_LOGS): $(TILC)
+TILC=../src/tilc
+
if HAVE_VALGRIND
-TESTS_ENVIRONMENT=ulimit -s 8192; $(VALGRIND) --leak-check=full --show-reachable=yes --error-exitcode=1 >/dev/null -- ../tilc
+TESTS_ENVIRONMENT=ulimit -s 8192; $(VALGRIND) --leak-check=full --show-reachable=yes --error-exitcode=1 >/dev/null -- $(TILC)
else
-TESTS_ENVIRONMENT=../tilc
+TESTS_ENVIRONMENT=$(TILC)
endif
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-09-04 23:12:03 UTC (rev 129)
+++ trunk/ChangeLog 2010-09-05 00:21:41 UTC (rev 130)
@@ -1,5 +1,12 @@
2010-09-05 Valentin David <val...@ii...>
+ * examples: Remove.
+ * configure.ac, Makefile.am: Update.
+
+ * src/lists/Makefile.am: Fix installation directory.
+
+2010-09-05 Valentin David <val...@ii...>
+
Add full Automake integration of Aurelia. Simplify the makefiles.
* amlib/lang/csf.pm, amlib/lang/sig.pm,
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
+++ trunk/Makefile.am 2010-09-05 00:21:41 UTC (rev 130)
@@ -15,8 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-SUBDIRS=src demos demos-from-rascal demos-from-stratego doc \
- examples
+SUBDIRS=src demos demos-from-rascal demos-from-stratego doc
+
ACLOCAL_AMFLAGS=-I config
EXTRA_DIST=benchmarks/aurelia.cc \
Modified: trunk/bootstrap
===================================================================
--- trunk/bootstrap 2010-09-04 23:12:03 UTC (rev 129)
+++ trunk/bootstrap 2010-09-05 00:21:41 UTC (rev 130)
@@ -1,4 +1,4 @@
#! /bin/bash -e
-export AUTOMAKE="'${AUTOMAKE:automake}' --libdir=:amlib"
+export AUTOMAKE="'${AUTOMAKE:-automake}' --libdir=:amlib"
autoreconf -f -v -i
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2010-09-04 23:12:03 UTC (rev 129)
+++ trunk/configure.ac 2010-09-05 00:21:41 UTC (rev 130)
@@ -181,9 +181,6 @@
src/streams/tests/Makefile
src/box/Makefile
src/box/tests/Makefile
- examples/Makefile
- examples/til/Makefile
- examples/til/tests/Makefile
aurelia.pc
doc/Makefile
doc/Doxyfile
Modified: trunk/src/lists/Makefile.am
===================================================================
--- trunk/src/lists/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
+++ trunk/src/lists/Makefile.am 2010-09-05 00:21:41 UTC (rev 130)
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-listsdir=$(aureliadir)/patterns
+listsdir=$(aureliadir)/lists
lists_HEADERS= \
listable.hh \
list_concept.hh \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-09-04 23:12:11
|
Revision: 129
http://aurelia.svn.sourceforge.net/aurelia/?rev=129&view=rev
Author: valentindavid
Date: 2010-09-04 23:12:03 +0000 (Sat, 04 Sep 2010)
Log Message:
-----------
2010-09-05 Valentin David <val...@ii...>
Add full Automake integration of Aurelia. Simplify the makefiles.
* amlib/lang/csf.pm, amlib/lang/sig.pm,
* amlib/am/csf.am, amlib/am/sig.am:
New. Hooks to Automake for Aurelia. Needs a patched Automake.
* Makefile.am (EXTRA_DIST): New.
* src/sig/Makefile.am,
* src/box/tests/Makefile.am,
* src/llstack/tests/Makefile.am,
* src/lists/tests/Makefile.am,
* src/memory/tests/Makefile.am,
* src/streams/tests/Makefile.am:
Use AM_CPPFLAGS.
* src/sig/tests/Makefile.am,
* src/parser_generator/tests/Makefile.am,
* src/parser_generator/Makefile.am,
* examples/til/Makefile.am:
Simplify using fully Automake.
* aurelia.pc.in: Fix version.
* configure.ac: Update. Set AM_CPPFLAGS.
* config/local_parser_gen.mk: New. Required where the current
parser generator is needed (i.e. unit tests).
* config/aurelia.mk: Remove.
* bootstrap: Add amlib to libdirs for Automake.
* examples/til/tests/Makefile.am: Fix a dependency.
Modified Paths:
--------------
trunk/ChangeLog
trunk/Makefile.am
trunk/aurelia.pc.in
trunk/bootstrap
trunk/configure.ac
trunk/examples/til/Makefile.am
trunk/examples/til/tests/Makefile.am
trunk/src/box/tests/Makefile.am
trunk/src/lists/tests/Makefile.am
trunk/src/llstack/tests/Makefile.am
trunk/src/memory/tests/Makefile.am
trunk/src/parser_generator/Makefile.am
trunk/src/parser_generator/tests/Makefile.am
trunk/src/sig/Makefile.am
trunk/src/sig/tests/Makefile.am
trunk/src/streams/tests/Makefile.am
Added Paths:
-----------
trunk/amlib/
trunk/amlib/am/
trunk/amlib/am/csf.am
trunk/amlib/am/sig.am
trunk/amlib/lang/
trunk/amlib/lang/csf.pm
trunk/amlib/lang/sig.pm
trunk/automake.patch
trunk/config/local_parser_gen.mk
Removed Paths:
-------------
trunk/config/aurelia.mk
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/ChangeLog 2010-09-04 23:12:03 UTC (rev 129)
@@ -1,3 +1,40 @@
+2010-09-05 Valentin David <val...@ii...>
+
+ Add full Automake integration of Aurelia. Simplify the makefiles.
+
+ * amlib/lang/csf.pm, amlib/lang/sig.pm,
+ * amlib/am/csf.am, amlib/am/sig.am:
+ New. Hooks to Automake for Aurelia. Needs a patched Automake.
+
+ * Makefile.am (EXTRA_DIST): New.
+
+ * src/sig/Makefile.am,
+ * src/box/tests/Makefile.am,
+ * src/llstack/tests/Makefile.am,
+ * src/lists/tests/Makefile.am,
+ * src/memory/tests/Makefile.am,
+ * src/streams/tests/Makefile.am:
+ Use AM_CPPFLAGS.
+
+ * src/sig/tests/Makefile.am,
+ * src/parser_generator/tests/Makefile.am,
+ * src/parser_generator/Makefile.am,
+ * examples/til/Makefile.am:
+ Simplify using fully Automake.
+
+ * aurelia.pc.in: Fix version.
+
+ * configure.ac: Update. Set AM_CPPFLAGS.
+
+ * config/local_parser_gen.mk: New. Required where the current
+ parser generator is needed (i.e. unit tests).
+
+ * config/aurelia.mk: Remove.
+
+ * bootstrap: Add amlib to libdirs for Automake.
+
+ * examples/til/tests/Makefile.am: Fix a dependency.
+
2010-09-01 Valentin David <val...@ii...>
Add a parser for TIL benchmark programming language.
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -19,10 +19,15 @@
examples
ACLOCAL_AMFLAGS=-I config
-EXTRA_DIST=benchmarks/aurelia.cc \
- benchmarks/aterm-c.c \
- benchmarks/aterm_java.java \
- svnrev
+EXTRA_DIST=benchmarks/aurelia.cc \
+ benchmarks/aterm-c.c \
+ benchmarks/aterm_java.java \
+ svnrev \
+ amlib/lang/sig.pm \
+ amlib/lang/csf.pm \
+ amlib/am/sig.am \
+ amlib/am/csf.am \
+ automake.patch
pkgconfigdir=$(libdir)/pkgconfig
pkgconfig_DATA=aurelia.pc
Added: trunk/amlib/am/csf.am
===================================================================
--- trunk/amlib/am/csf.am (rev 0)
+++ trunk/amlib/am/csf.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -0,0 +1,4 @@
+?GENERIC?%EXT%%DERIVED-EXT%:
+?!GENERIC?%OBJ%: %SOURCE%
+?GENERIC? %VERBOSE%%COMPILE% <%SOURCE% >%OBJ%
+?!GENERIC? %VERBOSE%%COMPILE% <`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% >%OBJ%
Added: trunk/amlib/am/sig.am
===================================================================
--- trunk/amlib/am/sig.am (rev 0)
+++ trunk/amlib/am/sig.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -0,0 +1,4 @@
+?GENERIC?%EXT%%DERIVED-EXT%:
+?!GENERIC?%OBJ%: %SOURCE%
+?GENERIC? %VERBOSE%%COMPILE% <%SOURCE% >%OBJ%
+?!GENERIC? %VERBOSE%%COMPILE% <`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% >%OBJ%
Added: trunk/amlib/lang/csf.pm
===================================================================
--- trunk/amlib/lang/csf.pm (rev 0)
+++ trunk/amlib/lang/csf.pm 2010-09-04 23:12:03 UTC (rev 129)
@@ -0,0 +1,24 @@
+use strict;
+
+sub csf_hook
+{
+ my ($self, $aggregate, $output, $input) = @_;
+ add_clean($output, MAINTAINER_CLEAN);
+ my $base = $output;
+ $base =~s/\.[^.]*$//;
+ pretty_print_rule ("$base.cc: $output", "\t", "");
+}
+
+register_language(
+ 'name' => "csf",
+ 'Name' => 'Cool Syntax Formalism',
+ 'config_vars' => ['CSF'],
+ 'compiler' => 'CSFCOMPILE',
+ 'compile' => '$(CSF) $(CSFFLAGS)',
+ 'extensions' => ['.csf'],
+ 'output_extensions' => sub { return ('.hh',); },
+ 'flags' => ['CSFFLAGS'],
+ 'ccer' => 'CSF',
+ 'rule_file' => 'csf',
+ '_finish' => sub {},
+ '_target_hook' => \&csf_hook);
Added: trunk/amlib/lang/sig.pm
===================================================================
--- trunk/amlib/lang/sig.pm (rev 0)
+++ trunk/amlib/lang/sig.pm 2010-09-04 23:12:03 UTC (rev 129)
@@ -0,0 +1,21 @@
+use strict;
+
+sub sig_hook
+{
+ my ($self, $aggregate, $output, $input) = @_;
+ add_clean($output, MAINTAINER_CLEAN);
+}
+
+register_language(
+ 'name' => "sig",
+ 'Name' => 'Signature generator',
+ 'config_vars' => ['SIG'],
+ 'compiler' => 'SIGCOMPILE',
+ 'compile' => '$(SIG) $(SIGFLAGS)',
+ 'extensions' => ['.rtree'],
+ 'output_extensions' => sub { return ('.hh',); },
+ 'flags' => ['SIGFLAGS'],
+ 'ccer' => 'SIG',
+ 'rule_file' => 'sig',
+ '_finish' => sub {},
+ '_target_hook' => \&sig_hook);
Modified: trunk/aurelia.pc.in
===================================================================
--- trunk/aurelia.pc.in 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/aurelia.pc.in 2010-09-04 23:12:03 UTC (rev 129)
@@ -3,7 +3,7 @@
aureliadir=@aureliadir@
Name: Aurelia
-Version: 0.1
+Version: @PACKAGE_FULLVERSION@
Description: Aurelia - Program transformation environment
Cflags: -I${aureliadir} @EXTRACPPFLAGS@
Libs: @LIBS@
Added: trunk/automake.patch
===================================================================
--- trunk/automake.patch (rev 0)
+++ trunk/automake.patch 2010-09-04 23:12:03 UTC (rev 129)
@@ -0,0 +1,572 @@
+diff --git a/automake.in b/automake.in
+index c0c5289..887aba7 100644
+--- a/automake.in
++++ b/automake.in
+@@ -107,7 +107,14 @@ struct (# Short name of the language (c, f77...).
+
+ # If TRUE, nodist_ sources will be compiled using specific rules
+ # (i.e. not inference rules). The default is FALSE.
+- 'nodist_specific' => "\$");
++ 'nodist_specific' => "\$",
++
++ # This subroutine follows a simple formula: Return value is
++ # LANG_SUBDIR if the resulting object file should be in a
++ # subdir if the source file is, LANG_PROCESS if file is to
++ # be dealt with, LANG_IGNORE otherwise.
++ # Arguments are ($DIRECTORY, $BASE, $EXT)
++ 'rewrite' => "\$");
+
+
+ sub finish ($)
+@@ -298,6 +305,9 @@ use constant QUEUE_STRING => "string";
+ ## Variables related to the options. ##
+ ## ---------------------------------- ##
+
++# Contains directories where library files are.
++my @userlibdir = ();
++
+ # TRUE if we should always generate Makefile.in.
+ my $force_generation = 1;
+
+@@ -744,7 +754,8 @@ register_language ('name' => 'c',
+ 'compile_flag' => '-c',
+ 'libtool_tag' => 'CC',
+ 'extensions' => ['.c'],
+- '_finish' => \&lang_c_finish);
++ '_finish' => \&lang_c_finish,
++ 'rewrite' => \&lang_c_rewrite);
+
+ # C++.
+ register_language ('name' => 'cxx',
+@@ -809,7 +820,8 @@ register_language ('name' => 'header',
+ # No output.
+ 'output_extensions' => sub { return () },
+ # Nothing to do.
+- '_finish' => sub { });
++ '_finish' => sub { },
++ 'rewrite' => sub { return LANG_IGNORE; });
+
+ # Vala
+ register_language ('name' => 'vala',
+@@ -1045,7 +1057,8 @@ register_language ('name' => 'java',
+ 'lder' => 'GCJLD',
+ 'ld' => '$(GCJ)',
+ 'pure' => 1,
+- 'extensions' => ['.java', '.class', '.zip', '.jar']);
++ 'extensions' => ['.java', '.class', '.zip', '.jar'],
++ 'rewrite' => sub { return LANG_SUBDIR; });
+
+ ################################################################
+
+@@ -1858,17 +1871,15 @@ sub handle_single_transform ($$$$$%)
+ }
+ }
+
+- # Note: computed subr call. The language rewrite function
+- # should return one of the LANG_* constants. It could
+- # also return a list whose first value is such a constant
+- # and whose second value is a new source extension which
+- # should be applied. This means this particular language
+- # generates another source file which we must then process
+- # further.
+- my $subr = \&{'lang_' . $lang->name . '_rewrite'};
+- my ($r, $source_extension)
+- = &$subr ($directory, $base, $extension,
++ # The language rewrite function should return one of the
++ # LANG_* constants.
++ my $r
++ = &{$lang->rewrite} ($directory, $base, $extension,
+ $nonansi_obj, $have_per_exec_flags, $var);
++
++ my $output_extension
++ = (&{$lang->output_extensions} ($extension))[0];
++
+ # Skip this entry if we were asked not to process it.
+ next if $r == LANG_IGNORE;
+
+@@ -1876,9 +1887,9 @@ sub handle_single_transform ($$$$$%)
+ $linker = $lang->linker;
+
+ my $this_obj_ext;
+- if (defined $source_extension)
++ if ($output_extension ne '.$(OBJEXT)')
+ {
+- $this_obj_ext = $source_extension;
++ $this_obj_ext = $output_extension;
+ $derived_source = 1;
+ }
+ elsif ($lang->ansi)
+@@ -2056,10 +2067,19 @@ sub handle_single_transform ($$$$$%)
+ $lang->target_hook ($aggregate, $object, $full, %transform);
+ }
+
++ # Transform .o or $o file into .P file (for automatic
++ # dependency code).
++ if ($lang && $lang->autodep ne 'no')
++ {
++ my $depfile = $object;
++ $depfile =~ s/\.([^.]*)$/.P$1/;
++ $depfile =~ s/\$\(OBJEXT\)$/o/;
++ $dep_files{dirname ($depfile) . '/$(DEPDIR)/'
++ . basename ($depfile)} = 1;
++ }
++
+ if ($derived_source)
+ {
+- prog_error ($lang->name . " has automatic dependency tracking")
+- if $lang->autodep ne 'no';
+ # Make sure this new source file is handled next. That will
+ # make it appear to be at the right place in the list.
+ unshift (@files, $object);
+@@ -2120,16 +2140,6 @@ sub handle_single_transform ($$$$$%)
+ if scalar @dep_list > 0;
+ }
+
+- # Transform .o or $o file into .P file (for automatic
+- # dependency code).
+- if ($lang && $lang->autodep ne 'no')
+- {
+- my $depfile = $object;
+- $depfile =~ s/\.([^.]*)$/.P$1/;
+- $depfile =~ s/\$\(OBJEXT\)$/o/;
+- $dep_files{dirname ($depfile) . '/$(DEPDIR)/'
+- . basename ($depfile)} = 1;
+- }
+ }
+
+ return @result;
+@@ -2555,7 +2565,7 @@ sub handle_compile ()
+ }
+
+ my ($coms, $vars, $rules) =
+- &file_contents_internal (1, "$libdir/am/compile.am",
++ &file_contents_internal (1, libfile ("am/compile.am"),
+ new Automake::Location,
+ ('DEFAULT_INCLUDES' => $default_includes,
+ 'MOSTLYRMS' => join ("\n", @mostly_rms),
+@@ -4266,7 +4276,9 @@ sub handle_configure ($$$@)
+ @configuredeps);
+
+ my $automake_options = '--' . (global_option 'cygnus' ? 'cygnus' : $strictness_name)
+- . (global_option 'no-dependencies' ? ' --ignore-deps' : '');
++ . (global_option 'no-dependencies' ? ' --ignore-deps' : '')
++ . (exists $userlibdir[0] ?
++ ' --libdir=' . join(':', @userlibdir) : '');
+
+ $output_rules .= file_contents
+ ('configure',
+@@ -5726,16 +5738,9 @@ sub check_gnits_standards
+ #
+ # Functions to handle files of each language.
+
+-# Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
+-# simple formula: Return value is LANG_SUBDIR if the resulting object
+-# file should be in a subdir if the source file is, LANG_PROCESS if
+-# file is to be dealt with, LANG_IGNORE otherwise.
+-
+ # Much of the actual processing is handled in
+ # handle_single_transform. These functions exist so that
+ # auxiliary information can be recorded for a later cleanup pass.
+-# Note that the calls to these functions are computed, so don't bother
+-# searching for their precise names in the source.
+
+ # This is just a convenience function that can be used to determine
+ # when a subdir object should be used.
+@@ -5799,128 +5804,6 @@ sub lang_c_rewrite
+ return $r;
+ }
+
+-# Rewrite a single C++ source file.
+-sub lang_cxx_rewrite
+-{
+- return &lang_sub_obj;
+-}
+-
+-# Rewrite a single header file.
+-sub lang_header_rewrite
+-{
+- # Header files are simply ignored.
+- return LANG_IGNORE;
+-}
+-
+-# Rewrite a single Vala source file.
+-sub lang_vala_rewrite
+-{
+- my ($directory, $base, $ext) = @_;
+-
+- (my $newext = $ext) =~ s/vala$/c/;
+- return (LANG_SUBDIR, $newext);
+-}
+-
+-# Rewrite a single yacc file.
+-sub lang_yacc_rewrite
+-{
+- my ($directory, $base, $ext) = @_;
+-
+- my $r = &lang_sub_obj;
+- (my $newext = $ext) =~ tr/y/c/;
+- return ($r, $newext);
+-}
+-
+-# Rewrite a single yacc++ file.
+-sub lang_yaccxx_rewrite
+-{
+- my ($directory, $base, $ext) = @_;
+-
+- my $r = &lang_sub_obj;
+- (my $newext = $ext) =~ tr/y/c/;
+- return ($r, $newext);
+-}
+-
+-# Rewrite a single lex file.
+-sub lang_lex_rewrite
+-{
+- my ($directory, $base, $ext) = @_;
+-
+- my $r = &lang_sub_obj;
+- (my $newext = $ext) =~ tr/l/c/;
+- return ($r, $newext);
+-}
+-
+-# Rewrite a single lex++ file.
+-sub lang_lexxx_rewrite
+-{
+- my ($directory, $base, $ext) = @_;
+-
+- my $r = &lang_sub_obj;
+- (my $newext = $ext) =~ tr/l/c/;
+- return ($r, $newext);
+-}
+-
+-# Rewrite a single assembly file.
+-sub lang_asm_rewrite
+-{
+- return &lang_sub_obj;
+-}
+-
+-# Rewrite a single preprocessed assembly file.
+-sub lang_cppasm_rewrite
+-{
+- return &lang_sub_obj;
+-}
+-
+-# Rewrite a single Fortran 77 file.
+-sub lang_f77_rewrite
+-{
+- return &lang_sub_obj;
+-}
+-
+-# Rewrite a single Fortran file.
+-sub lang_fc_rewrite
+-{
+- return &lang_sub_obj;
+-}
+-
+-# Rewrite a single preprocessed Fortran file.
+-sub lang_ppfc_rewrite
+-{
+- return &lang_sub_obj;
+-}
+-
+-# Rewrite a single preprocessed Fortran 77 file.
+-sub lang_ppf77_rewrite
+-{
+- return &lang_sub_obj;
+-}
+-
+-# Rewrite a single ratfor file.
+-sub lang_ratfor_rewrite
+-{
+- return &lang_sub_obj;
+-}
+-
+-# Rewrite a single Objective C file.
+-sub lang_objc_rewrite
+-{
+- return &lang_sub_obj;
+-}
+-
+-# Rewrite a single Unified Parallel C file.
+-sub lang_upc_rewrite
+-{
+- return &lang_sub_obj;
+-}
+-
+-# Rewrite a single Java file.
+-sub lang_java_rewrite
+-{
+- return LANG_SUBDIR;
+-}
+-
+ # The lang_X_finish functions are called after all source file
+ # processing is done. Each should handle defining rules for the
+ # language, etc. A finish function is only called if a source file of
+@@ -6288,6 +6171,8 @@ sub register_language (%)
+ unless defined $option{'output_extensions'};
+ $option{'nodist_specific'} = 0
+ unless defined $option{'nodist_specific'};
++ $option{'rewrite'} = \&lang_sub_obj
++ unless defined $option{'rewrite'};
+
+ my $lang = new Language (%option);
+
+@@ -6351,6 +6236,11 @@ sub pretty_print_rule
+ }
+
+
++sub add_clean ($$) {
++ my ($file, $mode) = @_;
++ $clean_files{$file} = $mode;
++}
++
+ ################################################################
+
+
+@@ -6969,7 +6859,7 @@ sub define_standard_variables
+ {
+ my $saved_output_vars = $output_vars;
+ my ($comments, undef, $rules) =
+- file_contents_internal (1, "$libdir/am/header-vars.am",
++ file_contents_internal (1, libfile ("am/header-vars.am"),
+ new Automake::Location);
+
+ foreach my $var (sort keys %configure_vars)
+@@ -7187,7 +7077,22 @@ sub make_paragraphs ($%)
+ return @res;
+ }
+
+-
++# libfile ($FILE)
++# ---------------
++# Look for $FILE in the library directories. Returns the first path
++# found. If not found, returns a path from the library directory with
++# highest priority.
++sub libfile ($)
++{
++ my ($f) = @_;
++ foreach (@userlibdir) {
++ return "$_/$f"
++ if -r "$_/$f";
++ }
++ return $userlibdir[0] . "/" . $f
++ if exists $userlibdir[0];
++ return $libdir . "/" . $f;
++}
+
+ # ($COMMENT, $VARIABLES, $RULES)
+ # &file_contents_internal ($IS_AM, $FILE, $WHERE, [%TRANSFORM])
+@@ -7246,7 +7151,7 @@ sub file_contents_internal ($$$%)
+ {
+ if ($cond != FALSE)
+ {
+- my $file = ($is_am ? "$libdir/am/" : '') . $1;
++ my $file = ($is_am ? libfile ("am/".$1) : $1);
+ $where->push_context ("`$file' included from here");
+ # N-ary `.=' fails.
+ my ($com, $vars, $rules)
+@@ -7391,7 +7296,7 @@ sub file_contents ($$%)
+ {
+ my ($basename, $where, %transform) = @_;
+ my ($comments, $variables, $rules) =
+- file_contents_internal (1, "$libdir/am/$basename.am", $where,
++ file_contents_internal (1, libfile ("am/$basename.am"), $where,
+ %transform);
+ return "$comments$variables$rules";
+ }
+@@ -7864,7 +7769,7 @@ sub require_file_internal ($$$@)
+ my $message = "required file `$fullfile' not found";
+ if ($add_missing)
+ {
+- if (-f "$libdir/$file")
++ if (-f libfile ("$file") )
+ {
+ $suppress = 1;
+
+@@ -7888,14 +7793,14 @@ sub require_file_internal ($$$@)
+ unlink ($fullfile) if -f $fullfile;
+ if ($symlink_exists && ! $copy_missing)
+ {
+- if (! symlink ("$libdir/$file", $fullfile)
++ if (! symlink (libfile ("$file"), $fullfile)
+ || ! -e $fullfile)
+ {
+ $suppress = 0;
+ $trailer = "; error while making link: $!";
+ }
+ }
+- elsif (system ('cp', "$libdir/$file", $fullfile))
++ elsif (system ('cp', libfile ("$file"), $fullfile))
+ {
+ $suppress = 0;
+ $trailer = "\n error while copying";
+@@ -7923,7 +7828,7 @@ sub require_file_internal ($$$@)
+ else
+ {
+ $trailer = "\n `automake --add-missing' can install `$file'"
+- if -f "$libdir/$file";
++ if -f libfile ("$file");
+ }
+
+ # If --force-missing was specified, and we have
+@@ -8458,7 +8363,9 @@ sub parse_arguments ()
+ my $cli_where = new Automake::Location;
+ my %cli_options =
+ (
+- 'libdir=s' => \$libdir,
++ 'libdir=s' => sub { push @userlibdir,
++ (map { ($_ eq '') ? "$libdir" : $_ }
++ split (':', $_[1])); },
+ 'gnu' => sub { set_strictness ('gnu'); },
+ 'gnits' => sub { set_strictness ('gnits'); },
+ 'cygnus' => sub { set_global_option ('cygnus', $cli_where); },
+@@ -8724,6 +8631,31 @@ sub handle_makefiles_threaded ($)
+ }
+ }
+
++# load_languages ()
++# -----------------
++# Load Perl files for each .pm files in all libdir/lang.
++sub load_languages
++{
++ foreach (@userlibdir) {
++ my $dir = $_;
++ if (-d "$dir/lang") {
++ opendir(LANG_DIR, "$dir/lang") || next;
++ my @files=readdir(LANG_DIR);
++ foreach (@files) {
++ if (-r "$dir/lang/$_" && $_ =~ /\.pm$/) {
++ unless (do "$dir/lang/$_") {
++ msg 'error', "$dir/lang/$_", "couldn't do: $!"
++ if ($! ne '');
++ msg 'error', "$dir/lang/$_", "couldn't parse: $@"
++ if ($@ ne '');
++ }
++ }
++ }
++ closedir(LANG_DIR);
++ }
++ }
++}
++
+ ################################################################
+
+ # Parse the WARNINGS environment variable.
+@@ -8732,6 +8664,8 @@ parse_WARNINGS;
+ # Parse command line.
+ parse_arguments;
+
++load_languages;
++
+ $configure_ac = require_configure_ac;
+
+ # Do configure.ac scan only once.
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index d86b03b..0eb85c0 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -774,6 +774,7 @@ unused.test \
+ upc.test \
+ upc2.test \
+ upc3.test \
++user_def_lang.test \
+ vala.test \
+ vala1.test \
+ vala2.test \
+diff --git a/tests/Makefile.in b/tests/Makefile.in
+index 77ec888..bf22206 100644
+--- a/tests/Makefile.in
++++ b/tests/Makefile.in
+@@ -985,6 +985,7 @@ unused.test \
+ upc.test \
+ upc2.test \
+ upc3.test \
++user_def_lang.test \
+ vala.test \
+ vala1.test \
+ vala2.test \
+diff --git a/tests/user_def_lang.test b/tests/user_def_lang.test
+new file mode 100755
+index 0000000..9b015da
+--- /dev/null
++++ b/tests/user_def_lang.test
+@@ -0,0 +1,80 @@
++. ./defs || Exit 1
++
++set -e
++
++cat > configure.in << 'END'
++AC_INIT
++AM_INIT_AUTOMAKE(nonesuch, nonesuch)
++AC_PROG_CC
++AC_SUBST([FOO], "foo")
++AC_OUTPUT(Makefile)
++END
++
++cat > Makefile.am <<'END'
++bin_PROGRAMS = bar
++bar_SOURCES = bar.foo
++END
++
++mkdir -p lib/am
++cat > lib/am/foo.am <<'END'
++?GENERIC?%EXT%%DERIVED-EXT%:
++?!GENERIC?%OBJ%: %SOURCE%
++?GENERIC? %VERBOSE%%COMPILE% <%SOURCE% >%OBJ%
++?GENERIC? %SILENT%echo %OBJ%: somefile >%DEPBASE%.Po
++?!GENERIC? %VERBOSE%%COMPILE% <`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% >%OBJ%
++?!GENERIC??SUBDIROBJ? %SILENT%depbase=`echo %OBJ% | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
++?!GENERIC??SUBDIROBJ? echo %OBJ%: somefile >%DEPBASE%.Po
++?!GENERIC??!SUBDIROBJ? %SILENT%echo %OBJ%: somefile >%DEPBASE%.Po
++END
++
++mkdir -p lib/lang
++cat > lib/lang/foo.pm <<'END'
++register_language (# Short name of the language (c, f77...).
++ 'name' => "foo",
++ # Nice name of the language (C, Fortran 77...).
++ 'Name' => "Foo",
++ # List of configure variables which must be defined.
++ 'config_vars' => ['FOO'],
++ 'autodep' => 'FOO',
++
++ # Name of the compiling variable (COMPILE).
++ 'compiler' => "FOOCOMPILE",
++ # Content of the compiling variable.
++ 'compile' => '$(FOO) $(FOOFLAGS)',
++ # Flag to require compilation without linking (-c).
++ 'extensions' => ['.foo'],
++ # A subroutine to compute a list of possible extensions of
++ # the product given the input extensions.
++ # (defaults to a subroutine which returns ('.$(OBJEXT)', '.lo'))
++ 'output_extensions' => sub { return ('.c',); },
++ # A list of flag variables used in 'compile'.
++ # (defaults to [])
++ 'flags' => ["FOOFLAGS"],
++
++ # The file to use when generating rules for this language.
++ # The default is 'depend2'.
++ 'rule_file' => "foo",
++
++ # Name of the compiler variable (CC).
++ 'ccer' => "FOO",
++
++ '_finish' => sub {},
++
++ # This is a subroutine which is called whenever we finally
++ # determine the context in which a source file will be
++ # compiled.
++
++ '_target_hook' => sub {
++ my ($self, $aggregate, $output, $input, %transform) = @_;
++ $clean_files{$output} = MAINTAINER_CLEAN;
++ },
++
++ # If TRUE, nodist_ sources will be compiled using specific rules
++ # (i.e. not inference rules). The default is FALSE.
++ 'nodist_specific' => 1);
++END
++
++$ACLOCAL
++$AUTOMAKE -a --libdir=:`pwd`/lib
++
++grep 'bar.c' Makefile.in
Modified: trunk/bootstrap
===================================================================
--- trunk/bootstrap 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/bootstrap 2010-09-04 23:12:03 UTC (rev 129)
@@ -1,3 +1,4 @@
#! /bin/bash -e
+export AUTOMAKE="'${AUTOMAKE:automake}' --libdir=:amlib"
autoreconf -f -v -i
Deleted: trunk/config/aurelia.mk
===================================================================
--- trunk/config/aurelia.mk 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/config/aurelia.mk 2010-09-04 23:12:03 UTC (rev 129)
@@ -1,67 +0,0 @@
-# This file is a part of Aurelia.
-# Copyright (C) 2010 Valentin David
-# Copyright (C) 2010 University of Bergen
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-AM_PARSER_GEN=$(top_builddir)/src/parser_generator/parser_gen
-AM_SIG=$(top_builddir)/src/sig/sig
-
-AM_V_PARSER_GEN = $(AM_V_PARSER_GEN_$(V))
-AM_V_PARSER_GEN_ = $(AM_V_PARSER_GEN_$(AM_DEFAULT_VERBOSITY))
-AM_V_PARSER_GEN_0 = @echo PARSER_GEN $@;
-
-AM_V_SIG = $(AM_V_SIG_$(V))
-AM_V_SIG_ = $(AM_V_SIG_$(AM_DEFAULT_VERBOSITY))
-AM_V_SIG_0 = @echo SIG $@;
-
-$(AM_PARSER_GEN):
- @cd $(top_builddir)/src/parser_generator && \
- $(MAKE) $(AM_MAKEFLAGS) parser_gen
-
-
-$(AM_SIG):
- @cd $(top_builddir)/src/sig && \
- $(MAKE) $(AM_MAKEFLAGS) sig
-
-.csf.hh:
- $(AM_V_PARSER_GEN)for f in $(EXTRA_DIST) dummy; do \
- if test $$f = $@; then \
- parser_gen=$(PARSER_GEN); \
- fi; \
- done; \
- if test -z "$$parser_gen"; then \
- parser_gen=$(AM_PARSER_GEN); \
- test -x $(AM_PARSER_GEN) || \
- $(MAKE) $(AM_MAKEFLAGS) $(AM_PARSER_GEN); \
- echo "$<: $$parser_gen" >$(DEPDIR)/`echo $@ | sed "s/\./_/g"`.dep; \
- fi; \
- if $$parser_gen <$< >$@.tmp; then \
- mv -f $@.tmp $@; \
- else \
- rm -f $@.tmp; \
- exit 1; \
- fi
-
-.rtree.hh:
- $(AM_V_SIG)test -x $(AM_SIG) || $(MAKE) $(AM_MAKEFLAGS) $(AM_SIG); \
- echo "$<: $(AM_SIG)" >$(DEPDIR)/`echo $@ | sed "s/\./_/g"`.dep; \
- if $(AM_SIG) <$< >$@.tmp; then \
- mv -f $@.tmp $@; \
- else \
- rm -f $@.tmp; \
- exit 1; \
- fi
-
-SUFFIXES=.csf .rtree
Added: trunk/config/local_parser_gen.mk
===================================================================
--- trunk/config/local_parser_gen.mk (rev 0)
+++ trunk/config/local_parser_gen.mk 2010-09-04 23:12:03 UTC (rev 129)
@@ -0,0 +1,22 @@
+# This file is a part of Aurelia.
+# Copyright (C) 2010 Valentin David
+# Copyright (C) 2010 University of Bergen
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+CSF=$(top_builddir)/src/parser_generator/parser_gen
+
+$(CSF):
+ @cd `echo $(CSF) | sed 's,/[^/]*$$,,'` && \
+ $(MAKE) $(AM_MAKEFLAGS) `echo $(CSF) | sed 's,.*/,,g'`
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/configure.ac 2010-09-04 23:12:03 UTC (rev 129)
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-AC_PREREQ([2.65])
+AC_PREREQ([2.67])
AC_INIT([aurelia], [0.1],dnl
[aur...@li...],dnl
@@ -28,7 +28,7 @@
AC_CONFIG_MACRO_DIR([config])
AC_CONFIG_HEADERS([config/config.h src/aurelia-config.hh])
-AM_INIT_AUTOMAKE([1.11 foreign dist-bzip2 tar-pax color-tests parallel-tests])
+AM_INIT_AUTOMAKE([1.11a foreign dist-bzip2 tar-pax color-tests parallel-tests])
AM_SILENT_RULES([yes])
AC_LANG_CPLUSPLUS
@@ -74,6 +74,7 @@
AC_CHECK_HEADERS([cxxabi.h])
AC_SUBST([EXTRACPPFLAGS])
+AC_SUBST([AM_CPPFLAGS], ['-I$(top_srcdir)/src -I$(top_builddir)/src '"$EXTRACPPFLAGS"])
AC_ARG_ENABLE([bootstrap],[AS_HELP_STRING([--enable-bootstrap],dnl
[bootstrap when checked out from SVN.])],[dnl
@@ -86,6 +87,7 @@
])
AC_CHECK_PROGS([PARSER_GEN], [parser_gen], [dnl
AC_MSG_ERROR([parser_gen not found. Please set variable PARSER_GEN.])])
+ AC_SUBST([CSF], ["$PARSER_GEN"])
AC_CHECK_PROGS([DOXYGEN], [doxygen], [dnl
AC_MSG_ERROR([doxygen not found. Please set variable DOXYGEN.])])
BOOTSTRAP=true
@@ -98,8 +100,11 @@
fi
],[BOOTSTRAP=false
svnrev=`cat $srcdir/svnrev`
+ AC_SUBST([CSF], ["$MISSING PARSER_GEN"])
])
+AC_SUBST([SIG], ['$(top_builddir)/src/sig/sig'])
+
if test "x$RELEASE" = xyes
then
PACKAGE_FULLVERSION=${PACKAGE_VERSION}
@@ -150,8 +155,6 @@
test -f doc/$DOCDEPDIR/doc.deps || echo '# Dummy' >doc/$DOCDEPDIR/doc.deps
], [DOCDEPDIR=$DEPDIR])
-AC_SUBST([INCDEP], ['include ./$(DEPDIR)/'])
-
AC_CONFIG_FILES([
Makefile
demos-from-rascal/Makefile
Modified: trunk/examples/til/Makefile.am
===================================================================
--- trunk/examples/til/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/examples/til/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -15,19 +15,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-include $(top_srcdir)/config/aurelia.mk
-@INCDEP@TIL_hh.dep
+include $(top_srcdir)/config/local_parser_gen.mk
-tilc_CPPFLAGS=-I$(top_builddir)/src -I$(top_srcdir)/src $(EXTRACPPFLAGS)
-
check_PROGRAMS=tilc
-tilc_SOURCES=TIL_main.cc TIL.cc
-nodist_tilc_SOURCES=TIL.hh
+tilc_SOURCES=TIL_main.cc TIL.cc TIL.csf
-$(tilc_OBJECTS): TIL.hh
+TIL.hh: $(CSF)
-EXTRA_DIST=TIL.csf
-
CLEANFILES=TIL.hh
-
SUBDIRS=tests
Modified: trunk/examples/til/tests/Makefile.am
===================================================================
--- trunk/examples/til/tests/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/examples/til/tests/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -22,13 +22,13 @@
proc-01.til \
exp-01.til
-nodist_check_SCRIPTS=../tilc
-
EXTRA_DIST=$(TESTS)
../tilc:
@cd .. && $(MAKE) $(AM_MAKEFLAGS) tilc
+$(TEST_LOGS): ../tilc
+
if HAVE_VALGRIND
TESTS_ENVIRONMENT=ulimit -s 8192; $(VALGRIND) --leak-check=full --show-reachable=yes --error-exitcode=1 >/dev/null -- ../tilc
else
Modified: trunk/src/box/tests/Makefile.am
===================================================================
--- trunk/src/box/tests/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/src/box/tests/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -15,11 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-AM_CPPFLAGS= \
- -I$(top_srcdir)/src \
- -I$(top_builddir)/src \
- $(EXTRACPPFLAGS)
-
check_PROGRAMS=box_test
box_test_SOURCES=box_test.cc
Modified: trunk/src/lists/tests/Makefile.am
===================================================================
--- trunk/src/lists/tests/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/src/lists/tests/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -15,11 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-AM_CPPFLAGS= \
- -I$(top_srcdir)/src \
- -I$(top_builddir)/src \
- $(EXTRACPPFLAGS)
-
check_PROGRAMS=test_listable
test_listable_SOURCES=test_listable.cc
Modified: trunk/src/llstack/tests/Makefile.am
===================================================================
--- trunk/src/llstack/tests/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/src/llstack/tests/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -15,13 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-AM_CPPFLAGS= \
- -I$(top_srcdir)/src \
- -DSRCDIR="\"$(srcdir)\"" \
- $(EXTRACPPFLAGS)
-
check_PROGRAMS=example
+example_CPPFLAGS=-DSRCDIR='"$(srcdir)"' $(AM_CPPFLAGS)
example_SOURCES=example.cc example.hh
TESTS=example
Modified: trunk/src/memory/tests/Makefile.am
===================================================================
--- trunk/src/memory/tests/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/src/memory/tests/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -15,11 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-AM_CPPFLAGS= \
- -I$(top_srcdir)/src \
- -I$(top_builddir)/src \
- $(EXTRACPPFLAGS)
-
check_PROGRAMS=test_pool test_pool_no_valgrind test_pool_no_thread
test_pool_SOURCES=test_pool.cc
Modified: trunk/src/parser_generator/Makefile.am
===================================================================
--- trunk/src/parser_generator/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/src/parser_generator/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -15,26 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-include $(top_srcdir)/config/aurelia.mk
-
-parser_gen_bootstrap_CPPFLAGS=-I$(srcdir)/.. $(EXTRACPPFLAGS)
-parser_gen_CPPFLAGS=-I$(srcdir)/.. $(EXTRACPPFLAGS)
-
bin_PROGRAMS=parser_gen
-parser_gen_SOURCES=parser_gen_main.cc parser_gen.cc syntax.cc
+parser_gen_SOURCES=parser_gen_main.cc parser_gen.cc syntax.cc syntax.csf
-EXTRA_DIST=syntax.hh syntax.csf
-CLEANFILES=
-
-if BOOTSTRAP
-CLEANFILES+=syntax.hh
-nodist_parser_gen_SOURCES=syntax.hh
-$(parser_gen_OBJECTS): syntax.hh
-
-else
-
-parser_gen_SOURCES+=syntax.hh
-
-endif
-
SUBDIRS=tests
Modified: trunk/src/parser_generator/tests/Makefile.am
===================================================================
--- trunk/src/parser_generator/tests/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/src/parser_generator/tests/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -15,18 +15,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-include $(top_srcdir)/config/aurelia.mk
-@INCDEP@gamma_2_hh.dep
+include $(top_srcdir)/config/local_parser_gen.mk
-gamma_2_CPPFLAGS=-I. -I$(srcdir)/../.. $(EXTRACPPFLAGS) -DSRCDIR=\"$(srcdir)\"
+gamma_2_CPPFLAGS=-DSRCDIR=\"$(srcdir)\" $(AM_CPPFLAGS)
check_PROGRAMS=gamma_2
TESTS=gamma_2
-gamma_2_SOURCES=gamma_2.cc
-nodist_gamma_2_SOURCES=gamma_2.hh
+gamma_2.hh: $(CSF)
-EXTRA_DIST=gamma_2.csf input.txt
-CLEANFILES=gamma_2.hh
+gamma_2_SOURCES=gamma_2.cc gamma_2.csf
-$(gamma_2_OBJECTS): gamma_2.hh
+CLEANFILES=gamma_2.hh
+EXTRA_DIST=input.txt
Modified: trunk/src/sig/Makefile.am
===================================================================
--- trunk/src/sig/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/src/sig/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -17,8 +17,5 @@
SUBDIRS=tests
-sig_CPPFLAGS=-I$(srcdir)/.. -I.. $(EXTRACPPFLAGS)
-
bin_PROGRAMS=sig
-
sig_SOURCES=sig.cc
Modified: trunk/src/sig/tests/Makefile.am
===================================================================
--- trunk/src/sig/tests/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/src/sig/tests/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -15,24 +15,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-include $(top_srcdir)/config/aurelia.mk
-@INCDEP@stratego_hh.dep
-
-test_CPPFLAGS=-I$(top_srcdir)/src -I.. -DSRCDIR="\"$(srcdir)\"" \
- $(EXTRACPPFLAGS)
-
check_PROGRAMS=test
-test_SOURCES=test.cc
+test_CPPFLAGS=-DSRCDIR="\"$(srcdir)\"" $(AM_CPPFLAGS)
+test_SOURCES=test.cc stratego.rtree
nodist_test_SOURCES=stratego.hh
-$(test_OBJECTS): stratego.hh
-
TESTS=test
-CLEANFILES=stratego.hh
-EXTRA_DIST=stratego.rtree
+$(test_OBJECTS): stratego.hh
+CLEANFILES=stratego.hh
if HAVE_VALGRIND
TESTS_ENVIRONMENT=ulimit -s 8192; $(VALGRIND) --leak-check=full --show-reachable=yes --error-exitcode=1 >/dev/null --
endif
Modified: trunk/src/streams/tests/Makefile.am
===================================================================
--- trunk/src/streams/tests/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
+++ trunk/src/streams/tests/Makefile.am 2010-09-04 23:12:03 UTC (rev 129)
@@ -15,14 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-AM_CPPFLAGS= \
- -I$(top_srcdir)/src \
- -I$(top_builddir)/src \
- -DSRCDIR="\"$(srcdir)\"" \
- $(EXTRACPPFLAGS)
+test_buf_stream_CPPFLAGS=-DSRCDIR="\"$(srcdir)\"" $(AM_CPPFLAGS)
check_PROGRAMS=test_buf_stream
-
test_buf_stream_SOURCES=test_buf_stream.cc
TESTS=test_buf_stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-09-01 19:41:15
|
Revision: 128
http://aurelia.svn.sourceforge.net/aurelia/?rev=128&view=rev
Author: valentindavid
Date: 2010-09-01 19:41:08 +0000 (Wed, 01 Sep 2010)
Log Message:
-----------
2010-09-01 Valentin David <val...@ii...>
Add a parser for TIL benchmark programming language.
* examples/til/TIL_main.cc,
* examples/til/TIL.csf,
* examples/til/tests/func-01.til,
* examples/til/tests/exp-01.til,
* examples/til/tests/proc-01.til,
* examples/til/tests/Makefile.am,
* examples/til/tests/decl-01.til,
* examples/til/tests/decl-02.til,
* examples/til/Makefile.am,
* examples/til/TIL.cc,
* examples/Makefile.am:
New.
* configure.ac,
* Makefile.am:
Update.
Modified Paths:
--------------
trunk/ChangeLog
trunk/Makefile.am
trunk/configure.ac
Added Paths:
-----------
trunk/examples/
trunk/examples/Makefile.am
trunk/examples/til/
trunk/examples/til/Makefile.am
trunk/examples/til/TIL.cc
trunk/examples/til/TIL.csf
trunk/examples/til/TIL_main.cc
trunk/examples/til/tests/
trunk/examples/til/tests/Makefile.am
trunk/examples/til/tests/decl-01.til
trunk/examples/til/tests/decl-02.til
trunk/examples/til/tests/exp-01.til
trunk/examples/til/tests/func-01.til
trunk/examples/til/tests/proc-01.til
Removed Paths:
-------------
trunk/demos/08-concrete_syntax.txt
trunk/demos/09-typed_term.txt
trunk/src/parser_generator/force-deps.mk
trunk/src/parser_generator/tests/force-deps.mk
trunk/src/sig/tests/force-dep.mk
Property Changed:
----------------
trunk/demos/
trunk/demos-from-rascal/
trunk/demos-from-stratego/
trunk/doc/
trunk/src/box/tests/
trunk/src/lists/tests/
trunk/src/llstack/tests/
trunk/src/memory/tests/
trunk/src/parser_generator/tests/
trunk/src/sig/tests/
trunk/src/streams/tests/
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-09-01 19:31:08 UTC (rev 127)
+++ trunk/ChangeLog 2010-09-01 19:41:08 UTC (rev 128)
@@ -1,5 +1,26 @@
2010-09-01 Valentin David <val...@ii...>
+ Add a parser for TIL benchmark programming language.
+
+ * examples/til/TIL_main.cc,
+ * examples/til/TIL.csf,
+ * examples/til/tests/func-01.til,
+ * examples/til/tests/exp-01.til,
+ * examples/til/tests/proc-01.til,
+ * examples/til/tests/Makefile.am,
+ * examples/til/tests/decl-01.til,
+ * examples/til/tests/decl-02.til,
+ * examples/til/Makefile.am,
+ * examples/til/TIL.cc,
+ * examples/Makefile.am:
+ New.
+
+ * configure.ac,
+ * Makefile.am:
+ Update.
+
+2010-09-01 Valentin David <val...@ii...>
+
Beautify output of make.
* config/aurelia.mk: New.
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2010-09-01 19:31:08 UTC (rev 127)
+++ trunk/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
@@ -15,7 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-SUBDIRS=src demos demos-from-rascal demos-from-stratego doc
+SUBDIRS=src demos demos-from-rascal demos-from-stratego doc \
+ examples
ACLOCAL_AMFLAGS=-I config
EXTRA_DIST=benchmarks/aurelia.cc \
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2010-09-01 19:31:08 UTC (rev 127)
+++ trunk/configure.ac 2010-09-01 19:41:08 UTC (rev 128)
@@ -178,6 +178,9 @@
src/streams/tests/Makefile
src/box/Makefile
src/box/tests/Makefile
+ examples/Makefile
+ examples/til/Makefile
+ examples/til/tests/Makefile
aurelia.pc
doc/Makefile
doc/Doxyfile
Property changes on: trunk/demos
___________________________________________________________________
Modified: svn:ignore
- input
01-terms.log
02-baf.log
03-threads.log
04-pools.log
05-term-expr.log
06-patterns.log
07-strategies.log
10-int.log
11-pair_of_int.log
12-maps.log
13-constructors-with-typed-terms.log
01-terms.out
02-baf.out
03-threads.out
04-pools.out
05-term-expr.out
06-patterns.out
07-strategies.out
10-int.out
11-pair_of_int.out
12-maps.out
13-constructors-with-typed-terms.out
Makefile.in
.deps
01-terms
02-baf
03-threads
04-pools
07-strategies
10-int
11-pair_of_int
12-maps
13-constructors-with-typed-terms
05-term-expr
06-patterns
Makefile
+ input
01-terms.log
02-baf.log
03-threads.log
04-pools.log
05-term-expr.log
06-patterns.log
07-strategies.log
10-int.log
11-pair_of_int.log
12-maps.log
13-constructors-with-typed-terms.log
01-terms.out
02-baf.out
03-threads.out
04-pools.out
05-term-expr.out
06-patterns.out
07-strategies.out
10-int.out
11-pair_of_int.out
12-maps.out
13-constructors-with-typed-terms.out
Makefile.in
.deps
01-terms
02-baf
03-threads
04-pools
07-strategies
10-int
11-pair_of_int
12-maps
13-constructors-with-typed-terms
05-term-expr
06-patterns
Makefile
01-terms.log
05-term-expr.log
06-patterns.log
07-strategies.log
10-int.log
11-pair_of_int.log
12-maps.log
13-constructors-with-typed-terms.log
test-suite.log
Deleted: trunk/demos/08-concrete_syntax.txt
===================================================================
Deleted: trunk/demos/09-typed_term.txt
===================================================================
Property changes on: trunk/demos-from-rascal
___________________________________________________________________
Modified: svn:ignore
- .deps
01-relations
02-lift
03-java
04-uninit
05-dataflow
06-reaching-defs
Makefile.in
Makefile
+ .deps
01-relations
02-lift
03-java
04-uninit
05-dataflow
06-reaching-defs
Makefile.in
Makefile
01-relations.log
02-lift.log
03-java.log
04-uninit.log
05-dataflow.log
06-reaching-defs.log
test-suite.log
Property changes on: trunk/demos-from-stratego
___________________________________________________________________
Modified: svn:ignore
- .deps
Makefile.in
Makefile
01-constant-folding-rules
+ .deps
Makefile.in
Makefile
01-constant-folding-rules
01-constant-folding-rules.log
test-suite.log
Property changes on: trunk/doc
___________________________________________________________________
Modified: svn:ignore
- html
html.stamp
Doxyfile
Makefile.in
Makefile
header-exp.html
.deps
gendeps.sh
+ html
html.stamp
Doxyfile
Makefile.in
Makefile
header-exp.html
.deps
gendeps.sh
doxygen.log
Property changes on: trunk/examples
___________________________________________________________________
Added: svn:ignore
+ Makefile
Makefile.in
Added: trunk/examples/Makefile.am
===================================================================
--- trunk/examples/Makefile.am (rev 0)
+++ trunk/examples/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
@@ -0,0 +1,18 @@
+# This file is a part of Aurelia.
+# Copyright (C) 2010 Valentin David
+# Copyright (C) 2010 University of Bergen
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+SUBDIRS=til
Property changes on: trunk/examples/til
___________________________________________________________________
Added: svn:ignore
+ Makefile
Makefile.in
.deps
TIL.hh
tilc
Added: trunk/examples/til/Makefile.am
===================================================================
--- trunk/examples/til/Makefile.am (rev 0)
+++ trunk/examples/til/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
@@ -0,0 +1,33 @@
+# This file is a part of Aurelia.
+# Copyright (C) 2010 Valentin David
+# Copyright (C) 2010 University of Bergen
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+include $(top_srcdir)/config/aurelia.mk
+@INCDEP@TIL_hh.dep
+
+tilc_CPPFLAGS=-I$(top_builddir)/src -I$(top_srcdir)/src $(EXTRACPPFLAGS)
+
+check_PROGRAMS=tilc
+tilc_SOURCES=TIL_main.cc TIL.cc
+nodist_tilc_SOURCES=TIL.hh
+
+$(tilc_OBJECTS): TIL.hh
+
+EXTRA_DIST=TIL.csf
+
+CLEANFILES=TIL.hh
+
+SUBDIRS=tests
Added: trunk/examples/til/TIL.cc
===================================================================
--- trunk/examples/til/TIL.cc (rev 0)
+++ trunk/examples/til/TIL.cc 2010-09-01 19:41:08 UTC (rev 128)
@@ -0,0 +1,110 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include <sstream>
+#include <iostream>
+#include <fstream>
+#include "llstack/queue.hh"
+#include "llstack/node.hh"
+#include "streams/buf_stream.hh"
+#include "llstack/label.hh"
+#include "llstack/node.hpp"
+#include "terms/term.hh"
+
+using namespace aurelia;
+using namespace llstack;
+struct Main {};
+typedef Term<Main> T;
+typedef Constructor<Main> C;
+
+frame pop_void(const frame& f) {
+ return f.as<ret_frame<VoidReturn> >().parent;
+}
+
+#include "TIL.hh"
+
+bool found;
+T result;
+
+struct Start {
+ void operator()(R_t&, const frame& f, stream& s, const node&) const {
+ if (s.eof()) {
+ std::cout << "Found!" << std::endl;
+ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ if (found) {
+ assert(result == rf0.t);
+ }
+ else
+ result = rf0.t;
+ found = true;
+ }
+ }
+};
+
+struct End {
+ void operator()(R_t&, const frame&, stream&, const node&) const {
+ }
+};
+
+bool main_loop(stream& s, const stream& end) {
+ found = false;
+ R_t R;
+ if (s.eof()) {
+ if (!is_empty_first(Program_0_0))
+ { error(); }
+ }
+ else if (!is_first(s, Program_0_0)) {
+ { error(); }
+ }
+ node u1 = node::boundary(Start(), end);
+ node u0 = node::boundary(End(), end);
+ u1.parents().insert(u0);
+ Program start;
+ start(R, empty_frame(), s, u1);
+ // int lastpos = -1;
+ try {
+ while (true) {
+ descriptor d = R.pop();
+ s = d.s;
+ //if (lastpos < s.get_pos()) {
+ //lastpos = s.get_pos();
+ //std::stringstream ss;
+ //ss << "graph." << s.get_pos();
+ //std::ofstream out(ss.str());
+ //std::cerr << lastpos << std::endl;
+ //node::printnodes(out);
+ //}
+ d.L.call(R, d.f, d.s, d.n);
+ }
+ } catch (R_t::Eof) {
+ }
+
+ node::clear();
+ return found;
+}
+
+T parse_TIL(std::istream& in) {
+ buf_stream bs(in);
+ stream s = bs.begin();
+ if (main_loop(s, bs.end())) {
+ std::cerr << result << std::endl;
+ T ret = result;
+ result.~T();
+ return ret;
+ }
+ throw Failure();
+}
Added: trunk/examples/til/TIL.csf
===================================================================
--- trunk/examples/til/TIL.csf (rev 0)
+++ trunk/examples/til/TIL.csf 2010-09-01 19:41:08 UTC (rev 128)
@@ -0,0 +1,270 @@
+//Programs
+Program ::= LAYOUT? Stat* LAYOUT?
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("Program", 1), (rf0.t)); $
+
+Stat+ ::= Stat LAYOUT? Stat*
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C::AS_LIST, (rf1.t, rf0.t)); $
+Stat* ::= Stat+
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | $ T ret(C::AS_EMPTY_LIST); $
+
+//LAYOUT
+LAYOUT? ::= LAYOUT+ |
+ $ if (!s.eof()) {
+ switch (*s) {
+ case ' ':
+ case '\r':
+ case '\n':
+ case '\t':
+ return ;
+ case '/':
+ {
+ buf_stream_iterator next = s;
+ ++next;
+ if (!next.eof()) {
+ if (*next == '/')
+ return ;
+ }
+ }
+ }
+ }
+ VoidReturn ret;
+ $ |
+ $ if (!s.eof()) {
+ switch (*s) {
+ case ' ':
+ case '\r':
+ case '\n':
+ case '\t':
+ return ;
+ case '/':
+ {
+ buf_stream_iterator next = s;
+ ++next;
+ if (!next.eof()) {
+ if (*next == '/')
+ return ;
+ }
+ }
+ }
+ }
+ VoidReturn ret;
+ $
+
+LAYOUT+ ::= LAYOUT LAYOUT?
+LAYOUT ::=
+ " " | "\n" | "\r" | "\t"
+ | "//" Line
+Line ::= "\n" | [^\n] Line
+
+//Literals
+
+Alpha ::= [A-Z]|[a-z]
+Num ::= [0-9]
+AlphaNum ::= Alpha | Num
+StrChar ::= [^\"\\\n] | "\\" [\"\\n]
+
+AlphaNum+ ::= AlphaNum AlphaNum*
+AlphaNum* ::= AlphaNum+ |
+
+Num* ::= Num+ |
+Num+ ::= Num Num*
+StrChar* ::= StrChar StrChar* |
+
+Id ::= $ ret_frame<stream> next_frame(f, s); $
+ Alpha AlphaNum*
+ $ if (!s.eof()) {
+ if (((*s) >= '0') && (*s) <= '9')
+ return ;
+ if (((*s) >= 'A') && (*s) <= 'Z')
+ return ;
+ if (((*s) >= 'a') && (*s) <= 'z')
+ return ;
+ }
+ ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
+ T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
+ $
+
+Int ::= $ ret_frame<stream> next_frame(f, s); $
+ Num+
+ $ if (!s.eof()) {
+ if (((*s) >= '0') && (*s) <= '9')
+ return ;
+ }
+ ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
+ T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
+ $
+
+String ::= $ ret_frame<stream> next_frame(f, s); $ "\"" StrChar* "\""
+ $ ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
+ T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
+ $
+
+//Expressions
+
+AtomExp ::= "true" $ T ret(C("True")); $
+ | "false" $ T ret(C("True")); $
+ | Id
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("Var", 1), rf0.t); $
+ |
+ Int
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("Int", 1), rf0.t); $
+ | String
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("String", 1), rf0.t); $
+ | "(" LAYOUT? $ frame next_frame(f); $Exp LAYOUT? ")"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | Id LAYOUT? "(" LAYOUT? Exp* LAYOUT? ")"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("FunCall", 2), (rf1.t, rf0.t)); $
+
+ModExp ::= AtomExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | AtomExp LAYOUT? "%" LAYOUT? AtomExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Mod", 2), (rf1.t, rf0.t)); $
+
+
+MulExp ::= ModExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | MulExp LAYOUT? "*" LAYOUT? ModExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Mul", 2), (rf1.t, rf0.t)); $
+ | MulExp LAYOUT? "/" LAYOUT? ModExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Div", 2), (rf1.t, rf0.t)); $
+
+
+AddExp ::= MulExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | AddExp LAYOUT? "+" LAYOUT? MulExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Add", 2), (rf1.t, rf0.t)); $
+ | AddExp LAYOUT? "-" LAYOUT? MulExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Sub", 2), (rf1.t, rf0.t)); $
+
+CompExp ::= AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | AddExp LAYOUT? "<" LAYOUT? AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Lt", 2), (rf1.t, rf0.t)); $
+ | AddExp LAYOUT? ">" LAYOUT? AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Gt", 2), (rf1.t, rf0.t)); $
+ | AddExp LAYOUT? "<=" LAYOUT? AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Leq", 2), (rf1.t, rf0.t)); $
+ | AddExp LAYOUT? ">=" LAYOUT? AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Geq", 2), (rf1.t, rf0.t)); $
+ | AddExp LAYOUT? "=" LAYOUT? AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Equ", 2), (rf1.t, rf0.t)); $
+ | AddExp LAYOUT? "!=" LAYOUT? AddExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Neq", 2), (rf1.t, rf0.t)); $
+
+
+AndExp ::= CompExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | AndExp LAYOUT? $ frame next_frame(f); $"&" LAYOUT? CompExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("And", 2), (rf1.t, rf0.t)); $
+
+OrExp ::= AndExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | OrExp LAYOUT? "|" LAYOUT? AndExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Or", 2), (rf1.t, rf0.t)); $
+
+Exp ::= OrExp
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+
+//Statements
+
+Stat ::= "var" LAYOUT? Id LAYOUT? ";"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("Declaration", 1), (rf0.t)); $
+ | "var" LAYOUT? Id LAYOUT? ":" LAYOUT? Type LAYOUT? ";"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("DeclarationTyped", 2), (rf1.t, rf0.t)); $
+ | Id LAYOUT? ":=" LAYOUT? Exp LAYOUT? ";"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Assign", 2), (rf1.t, rf0.t)); $
+ | "begin" LAYOUT? Stat* LAYOUT? "end"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("Block", 1), (rf0.t)); $
+ | "if" LAYOUT? Exp LAYOUT? "then" LAYOUT? Stat* LAYOUT? "end"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("IfThen", 2), (rf1.t, rf0.t)); $
+ | "if" LAYOUT? Exp LAYOUT? "then" LAYOUT? Stat* LAYOUT? "else" LAYOUT? Stat* LAYOUT? "end"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ ret_frame<T> rf2 = rf1.parent.as<ret_frame<T> >();
+ T ret(C("IfElse", 3), (rf2.t, rf1.t, rf0.t)); $
+ | "while" LAYOUT? Exp LAYOUT? "do" LAYOUT? Stat* LAYOUT? "end"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("While", 2), (rf1.t, rf0.t)); $
+ | "for" LAYOUT? Id LAYOUT? ":=" LAYOUT? Exp LAYOUT? "to" LAYOUT? Exp LAYOUT? "do" LAYOUT? Stat LAYOUT? "end"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ ret_frame<T> rf2 = rf1.parent.as<ret_frame<T> >();
+ ret_frame<T> rf3 = rf2.parent.as<ret_frame<T> >();
+ T ret(C("For", 4), (rf3.t, rf2.t, rf1.t, rf0.t)); $
+ | Id LAYOUT? "(" LAYOUT? Exp* LAYOUT? ")" LAYOUT? ";"
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("ProcCall", 2), (rf1.t, rf0.t)); $
+
+//Types
+Type ::= Id
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(C("TypeName", 1), (rf0.t)); $
+
+//Calls
+
+ExpL ::= "," LAYOUT? Exp+
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | $ T ret(C::AS_EMPTY_LIST); $
+Exp+ ::= Exp LAYOUT? ExpL
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C::AS_LIST, (rf1.t, rf0.t)); $
+Exp* ::= Exp+
+ $ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret(rf0.t); $
+ | $ T ret(C::AS_EMPTY_LIST); $
Added: trunk/examples/til/TIL_main.cc
===================================================================
--- trunk/examples/til/TIL_main.cc (rev 0)
+++ trunk/examples/til/TIL_main.cc 2010-09-01 19:41:08 UTC (rev 128)
@@ -0,0 +1,23 @@
+#include <fstream>
+#include "terms/term.hh"
+
+using namespace aurelia;
+struct Main {};
+typedef Term<Main> T;
+
+T parse_TIL(std::istream& in);
+int main(int argc, char* argv[])
+{
+ if (argc != 2)
+ return 1;
+ try {
+ std::ifstream in(argv[1]);
+ std::cerr << parse_TIL(in) << std::endl;
+ } catch (Failure) {
+ std::cerr << "Rewriting failed." << std::endl;
+
+ return 1;
+ }
+
+ return 0;
+}
Property changes on: trunk/examples/til/tests
___________________________________________________________________
Added: svn:ignore
+ decl-01.til.log
decl-02.til.log
exp-01.til.log
func-01.til.log
proc-01.til.log
test-suite.log
test.til.log
Makefile
Makefile.in
.deps
Added: trunk/examples/til/tests/Makefile.am
===================================================================
--- trunk/examples/til/tests/Makefile.am (rev 0)
+++ trunk/examples/til/tests/Makefile.am 2010-09-01 19:41:08 UTC (rev 128)
@@ -0,0 +1,36 @@
+# This file is a part of Aurelia.
+# Copyright (C) 2010 Valentin David
+# Copyright (C) 2010 University of Bergen
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+TESTS= \
+ decl-01.til \
+ decl-02.til \
+ func-01.til \
+ proc-01.til \
+ exp-01.til
+
+nodist_check_SCRIPTS=../tilc
+
+EXTRA_DIST=$(TESTS)
+
+../tilc:
+ @cd .. && $(MAKE) $(AM_MAKEFLAGS) tilc
+
+if HAVE_VALGRIND
+TESTS_ENVIRONMENT=ulimit -s 8192; $(VALGRIND) --leak-check=full --show-reachable=yes --error-exitcode=1 >/dev/null -- ../tilc
+else
+TESTS_ENVIRONMENT=../tilc
+endif
Added: trunk/examples/til/tests/decl-01.til
===================================================================
--- trunk/examples/til/tests/decl-01.til (rev 0)
+++ trunk/examples/til/tests/decl-01.til 2010-09-01 19:41:08 UTC (rev 128)
@@ -0,0 +1 @@
+var foo : int;
Added: trunk/examples/til/tests/decl-02.til
===================================================================
--- trunk/examples/til/tests/decl-02.til (rev 0)
+++ trunk/examples/til/tests/decl-02.til 2010-09-01 19:41:08 UTC (rev 128)
@@ -0,0 +1 @@
+var foo;
Added: trunk/examples/til/tests/exp-01.til
===================================================================
--- trunk/examples/til/tests/exp-01.til (rev 0)
+++ trunk/examples/til/tests/exp-01.til 2010-09-01 19:41:08 UTC (rev 128)
@@ -0,0 +1,2 @@
+var x : int;
+x := x * (28 - x);
Added: trunk/examples/til/tests/func-01.til
===================================================================
--- trunk/examples/til/tests/func-01.til (rev 0)
+++ trunk/examples/til/tests/func-01.til 2010-09-01 19:41:08 UTC (rev 128)
@@ -0,0 +1,2 @@
+var n;
+n := string2int(read());
Added: trunk/examples/til/tests/proc-01.til
===================================================================
--- trunk/examples/til/tests/proc-01.til (rev 0)
+++ trunk/examples/til/tests/proc-01.til 2010-09-01 19:41:08 UTC (rev 128)
@@ -0,0 +1,2 @@
+var n : int;
+write(int2string(n));
Property changes on: trunk/src/box/tests
___________________________________________________________________
Modified: svn:ignore
- Makefile
.deps
box_test
Makefile.in
+ Makefile
.deps
box_test
Makefile.in
box_test.log
test-suite.log
Property changes on: trunk/src/lists/tests
___________________________________________________________________
Modified: svn:ignore
- .deps
Makefile.in
Makefile
test_listable
+ .deps
Makefile.in
Makefile
test_listable
test_listable.log
test-suite.log
Property changes on: trunk/src/llstack/tests
___________________________________________________________________
Modified: svn:ignore
- Makefile.in
Makefile
test_buf_stream
.deps
example
+ Makefile.in
Makefile
test_buf_stream
.deps
example
example.log
test-suite.log
Property changes on: trunk/src/memory/tests
___________________________________________________________________
Modified: svn:ignore
- Makefile.in
test_pool
.deps
test_pool_no_valgrind
test_pool_no_thread
Makefile
+ Makefile.in
test_pool
.deps
test_pool_no_valgrind
test_pool_no_thread
Makefile
test_pool.log
test_pool_no_thread.log
test_pool_no_valgrind.log
test-suite.log
Deleted: trunk/src/parser_generator/force-deps.mk
===================================================================
Property changes on: trunk/src/parser_generator/tests
___________________________________________________________________
Modified: svn:ignore
- Makefile
Makefile.in
gamma_2.tree
gamma_2
gamma_2.hh
.deps
+ Makefile
Makefile.in
gamma_2.tree
gamma_2
gamma_2.hh
.deps
gamma_2.log
test-suite.log
Deleted: trunk/src/parser_generator/tests/force-deps.mk
===================================================================
Property changes on: trunk/src/sig/tests
___________________________________________________________________
Modified: svn:ignore
- Makefile
Makefile.in
stratego.hh
.deps
test
+ Makefile
Makefile.in
stratego.hh
.deps
test
test.log
test-suite.log
Deleted: trunk/src/sig/tests/force-dep.mk
===================================================================
Property changes on: trunk/src/streams/tests
___________________________________________________________________
Modified: svn:ignore
- Makefile.in
.deps
Makefile
test_buf_stream
+ Makefile.in
.deps
Makefile
test_buf_stream
test_buf_stream.log
test-suite.log
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-09-01 19:31:16
|
Revision: 127
http://aurelia.svn.sourceforge.net/aurelia/?rev=127&view=rev
Author: valentindavid
Date: 2010-09-01 19:31:08 +0000 (Wed, 01 Sep 2010)
Log Message:
-----------
2010-09-01 Valentin David <val...@ii...>
Beautify output of make.
* config/aurelia.mk: New.
Handle compilation using Aurelia tools.
* src/sig/tests/Makefile.am,
* src/parser_generator/tests/Makefile.am,
* src/parser_generator/Makefile.am:
Use new compilating rules.
* src/sig/tests/force-dep.mk,
* src/parser_generator/tests/force-deps.mk,
* src/parser_generator/force-deps.mk:
Remove.
* src/parser_generator/parser_gen.cc:
Remove information output.
* configure.ac: Change options to automake.
Substitute autoconf variable for dependency include.
* doc/Makefile.am: Put the error output of Doxygen to a log file.
* demos/09-typed_term.txt, demos/08-concrete_syntax.txt:
Remove.
* demos/Makefile.am (EXTRA_DIST): Update.
Modified Paths:
--------------
trunk/ChangeLog
trunk/configure.ac
trunk/demos/08-concrete_syntax.txt
trunk/demos/09-typed_term.txt
trunk/demos/Makefile.am
trunk/doc/Makefile.am
trunk/src/parser_generator/Makefile.am
trunk/src/parser_generator/force-deps.mk
trunk/src/parser_generator/parser_gen.cc
trunk/src/parser_generator/tests/Makefile.am
trunk/src/parser_generator/tests/force-deps.mk
trunk/src/sig/tests/Makefile.am
trunk/src/sig/tests/force-dep.mk
Added Paths:
-----------
trunk/config/aurelia.mk
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-09-01 12:36:23 UTC (rev 126)
+++ trunk/ChangeLog 2010-09-01 19:31:08 UTC (rev 127)
@@ -1,5 +1,34 @@
2010-09-01 Valentin David <val...@ii...>
+ Beautify output of make.
+
+ * config/aurelia.mk: New.
+ Handle compilation using Aurelia tools.
+
+ * src/sig/tests/Makefile.am,
+ * src/parser_generator/tests/Makefile.am,
+ * src/parser_generator/Makefile.am:
+ Use new compilating rules.
+
+ * src/sig/tests/force-dep.mk,
+ * src/parser_generator/tests/force-deps.mk,
+ * src/parser_generator/force-deps.mk:
+ Remove.
+
+ * src/parser_generator/parser_gen.cc:
+ Remove information output.
+
+ * configure.ac: Change options to automake.
+ Substitute autoconf variable for dependency include.
+
+ * doc/Makefile.am: Put the error output of Doxygen to a log file.
+
+ * demos/09-typed_term.txt, demos/08-concrete_syntax.txt:
+ Remove.
+ * demos/Makefile.am (EXTRA_DIST): Update.
+
+2010-09-01 Valentin David <val...@ii...>
+
* src/llstack/node.hpp:
Fix return for void. Set P was not updated in case of void return.
Added: trunk/config/aurelia.mk
===================================================================
--- trunk/config/aurelia.mk (rev 0)
+++ trunk/config/aurelia.mk 2010-09-01 19:31:08 UTC (rev 127)
@@ -0,0 +1,67 @@
+# This file is a part of Aurelia.
+# Copyright (C) 2010 Valentin David
+# Copyright (C) 2010 University of Bergen
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AM_PARSER_GEN=$(top_builddir)/src/parser_generator/parser_gen
+AM_SIG=$(top_builddir)/src/sig/sig
+
+AM_V_PARSER_GEN = $(AM_V_PARSER_GEN_$(V))
+AM_V_PARSER_GEN_ = $(AM_V_PARSER_GEN_$(AM_DEFAULT_VERBOSITY))
+AM_V_PARSER_GEN_0 = @echo PARSER_GEN $@;
+
+AM_V_SIG = $(AM_V_SIG_$(V))
+AM_V_SIG_ = $(AM_V_SIG_$(AM_DEFAULT_VERBOSITY))
+AM_V_SIG_0 = @echo SIG $@;
+
+$(AM_PARSER_GEN):
+ @cd $(top_builddir)/src/parser_generator && \
+ $(MAKE) $(AM_MAKEFLAGS) parser_gen
+
+
+$(AM_SIG):
+ @cd $(top_builddir)/src/sig && \
+ $(MAKE) $(AM_MAKEFLAGS) sig
+
+.csf.hh:
+ $(AM_V_PARSER_GEN)for f in $(EXTRA_DIST) dummy; do \
+ if test $$f = $@; then \
+ parser_gen=$(PARSER_GEN); \
+ fi; \
+ done; \
+ if test -z "$$parser_gen"; then \
+ parser_gen=$(AM_PARSER_GEN); \
+ test -x $(AM_PARSER_GEN) || \
+ $(MAKE) $(AM_MAKEFLAGS) $(AM_PARSER_GEN); \
+ echo "$<: $$parser_gen" >$(DEPDIR)/`echo $@ | sed "s/\./_/g"`.dep; \
+ fi; \
+ if $$parser_gen <$< >$@.tmp; then \
+ mv -f $@.tmp $@; \
+ else \
+ rm -f $@.tmp; \
+ exit 1; \
+ fi
+
+.rtree.hh:
+ $(AM_V_SIG)test -x $(AM_SIG) || $(MAKE) $(AM_MAKEFLAGS) $(AM_SIG); \
+ echo "$<: $(AM_SIG)" >$(DEPDIR)/`echo $@ | sed "s/\./_/g"`.dep; \
+ if $(AM_SIG) <$< >$@.tmp; then \
+ mv -f $@.tmp $@; \
+ else \
+ rm -f $@.tmp; \
+ exit 1; \
+ fi
+
+SUFFIXES=.csf .rtree
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2010-09-01 12:36:23 UTC (rev 126)
+++ trunk/configure.ac 2010-09-01 19:31:08 UTC (rev 127)
@@ -28,7 +28,8 @@
AC_CONFIG_MACRO_DIR([config])
AC_CONFIG_HEADERS([config/config.h src/aurelia-config.hh])
-AM_INIT_AUTOMAKE([1.11 foreign dist-bzip2 tar-pax])
+AM_INIT_AUTOMAKE([1.11 foreign dist-bzip2 tar-pax color-tests parallel-tests])
+AM_SILENT_RULES([yes])
AC_LANG_CPLUSPLUS
AC_PROG_CXX([g++ icpc])
@@ -149,6 +150,8 @@
test -f doc/$DOCDEPDIR/doc.deps || echo '# Dummy' >doc/$DOCDEPDIR/doc.deps
], [DOCDEPDIR=$DEPDIR])
+AC_SUBST([INCDEP], ['include ./$(DEPDIR)/'])
+
AC_CONFIG_FILES([
Makefile
demos-from-rascal/Makefile
Modified: trunk/demos/08-concrete_syntax.txt
===================================================================
--- trunk/demos/08-concrete_syntax.txt 2010-09-01 12:36:23 UTC (rev 126)
+++ trunk/demos/08-concrete_syntax.txt 2010-09-01 19:31:08 UTC (rev 127)
@@ -1,7 +0,0 @@
-T scan_struct(const T& t) {
- V X, N;
-
- ("struct N {"> ~X < "};")(t);
-
- return Struct(*N, scan_members(*X));
-}
Modified: trunk/demos/09-typed_term.txt
===================================================================
--- trunk/demos/09-typed_term.txt 2010-09-01 12:36:23 UTC (rev 126)
+++ trunk/demos/09-typed_term.txt 2010-09-01 19:31:08 UTC (rev 127)
@@ -1,17 +0,0 @@
-StructTerm scan_struct(const ClassDef& t) {
- MembersVar X;
- IdVar N;
-
- ("struct N {"> ~X < "};")(t);
-
- return Struct(*N, scan_members(*X));
-}
-
-template <typename T>
-void isClassDef(const T& t)
-{
- try {
- ClassDef cd(t);
- } catch (Failure) {
- }
-}
Modified: trunk/demos/Makefile.am
===================================================================
--- trunk/demos/Makefile.am 2010-09-01 12:36:23 UTC (rev 126)
+++ trunk/demos/Makefile.am 2010-09-01 19:31:08 UTC (rev 127)
@@ -36,7 +36,7 @@
04-pools
endif
-EXTRA_DIST=input 08-concrete_syntax.txt 09-typed_term.txt
+EXTRA_DIST=input
01_terms_SOURCES=01-terms.cc
02_baf_SOURCES=02-baf.cc
Modified: trunk/doc/Makefile.am
===================================================================
--- trunk/doc/Makefile.am 2010-09-01 12:36:23 UTC (rev 126)
+++ trunk/doc/Makefile.am 2010-09-01 19:31:08 UTC (rev 127)
@@ -28,7 +28,7 @@
if BOOTSTRAP
header-exp.html: header.html
- if test x"$(ONLINE)" = xyes; then \
+ @if test x"$(ONLINE)" = xyes; then \
cp header.html header-exp.html; \
else \
sed "/<!--online only begin-->/{;:l;/<!--online only end-->/d;N;bl;}" \
@@ -38,10 +38,14 @@
html: html.stamp
html.stamp: $(DOCFILES)
- -rm -rf output.tmp
- $(MAKE) $(AM_MAKEFLAGS) Doxyfile gendeps.sh
- echo "html.stamp: \\" >$(DEPDIR)/doc.Tdeps
- if $(DOXYGEN) Doxyfile; then \
+ @-rm -rf output.tmp
+ @$(MAKE) $(AM_MAKEFLAGS) Doxyfile gendeps.sh
+ @echo "html.stamp: \\" >$(DEPDIR)/doc.Tdeps
+ @echo "Building HTML documentation."; \
+ if $(DOXYGEN) Doxyfile &>doxygen.log; then \
+ if grep ": warning:" doxygen.log &>/dev/null; then \
+ echo '[0;33m'"Doxygen reported warnings. Please check $(subdir)/doxygen.log."'[m' 2>&1; \
+ fi; \
echo '' >>$(DEPDIR)/doc.Tdeps; \
mv -f $(DEPDIR)/doc.Tdeps $(DEPDIR)/doc.deps; \
rm -rf html; \
@@ -53,13 +57,13 @@
rm -rf output.tmp; \
exit 1; \
fi
- cp $(srcdir)/bldl-mini.png html
- cp -f $(srcdir)/doxygen.png html
+ @cp $(srcdir)/bldl-mini.png html
+ @cp -f $(srcdir)/doxygen.png html
clean-local:
rm -rf html
-CLEANFILES=html.stamp header-exp.html
+CLEANFILES=html.stamp header-exp.html doxygen.log
else
CLEANFILES=
endif
Modified: trunk/src/parser_generator/Makefile.am
===================================================================
--- trunk/src/parser_generator/Makefile.am 2010-09-01 12:36:23 UTC (rev 126)
+++ trunk/src/parser_generator/Makefile.am 2010-09-01 19:31:08 UTC (rev 127)
@@ -15,42 +15,22 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+include $(top_srcdir)/config/aurelia.mk
+
parser_gen_bootstrap_CPPFLAGS=-I$(srcdir)/.. $(EXTRACPPFLAGS)
parser_gen_CPPFLAGS=-I$(srcdir)/.. $(EXTRACPPFLAGS)
bin_PROGRAMS=parser_gen
parser_gen_SOURCES=parser_gen_main.cc parser_gen.cc syntax.cc
-EXTRA_DIST=syntax.hh syntax.csf force-deps.mk
+EXTRA_DIST=syntax.hh syntax.csf
CLEANFILES=
if BOOTSTRAP
-
-use-local-generator: parser_gen
-use-local-generator: syntax.csf
- if ./parser_gen <$< >syntax.hh.tmp; then \
- mv -f syntax.hh.tmp syntax.hh; \
- else \
- rm -f syntax.hh.tmp; \
- exit 1; \
- fi
-
-syntax.hh: syntax.csf
- if $(PARSER_GEN) <$< >syntax.hh.tmp; then \
- mv -f syntax.hh.tmp syntax.hh; \
- else \
- rm -f syntax.hh.tmp; \
- exit 1; \
- fi
-
-syntax.hh: syntax.csf
-
CLEANFILES+=syntax.hh
-
nodist_parser_gen_SOURCES=syntax.hh
+$(parser_gen_OBJECTS): syntax.hh
--include $(srcdir)/force-deps.mk
-
else
parser_gen_SOURCES+=syntax.hh
Modified: trunk/src/parser_generator/force-deps.mk
===================================================================
--- trunk/src/parser_generator/force-deps.mk 2010-09-01 12:36:23 UTC (rev 126)
+++ trunk/src/parser_generator/force-deps.mk 2010-09-01 19:31:08 UTC (rev 127)
@@ -1,18 +0,0 @@
-# This file is a part of Aurelia.
-# Copyright (C) 2010 Valentin David
-# Copyright (C) 2010 University of Bergen
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-parser_gen-syntax.o: syntax.hh
Modified: trunk/src/parser_generator/parser_gen.cc
===================================================================
--- trunk/src/parser_generator/parser_gen.cc 2010-09-01 12:36:23 UTC (rev 126)
+++ trunk/src/parser_generator/parser_gen.cc 2010-09-01 19:31:08 UTC (rev 127)
@@ -1226,7 +1226,7 @@
void parser_generator(T input)
{
BuildEmpty build_empty;
- std::cerr << "Building \"empty\" prediction table." << std::endl;
+ //std::cerr << "Building \"empty\" prediction table." << std::endl;
repeat(map_one(build_empty))(input);
static C Rule("Rule", 4);
@@ -1235,7 +1235,7 @@
V l, nt, return_type;
std::cout << "enum nonterm {" << std::endl;
- std::cerr << "Printing non-terminal list." << std::endl;
+ //std::cerr << "Printing non-terminal list." << std::endl;
map(scope(nt, scope(l,
~Rule[nt, NoParam, return_type, l]
< !nt
@@ -1249,7 +1249,7 @@
std::cout << "};" << std::endl;
std::cout << "enum state {" << std::endl;
- std::cerr << "Printing states list." << std::endl;
+ //std::cerr << "Printing states list." << std::endl;
map(print_labels)(input);
std::cout << "};" << std::endl;
@@ -1259,7 +1259,7 @@
std::cout << "#include \"llstack/utils.hh\"" << std::endl;
std::cout << "const unsigned char empty_first[] = {";
- std::cerr << "Printing \"empty\" prediction table." << std::endl;
+ //std::cerr << "Printing \"empty\" prediction table." << std::endl;
GetBinEmpty gbe(&build_empty);
map(gbe)(input);
print_bin(std::cout, gbe->get_data().begin(), gbe->get_data().end());
@@ -1267,7 +1267,7 @@
BuildFirst build_first(&build_empty);
- std::cerr << "Building \"first\" prediction table." << std::endl;
+ //std::cerr << "Building \"first\" prediction table." << std::endl;
repeat(map_some(build_first))(input);
// for (BuildFirst::iterator i = build_first->begin();
@@ -1277,16 +1277,16 @@
// }
std::cout << "const unsigned char first[NUM_STATES][32] = {" << std::endl;
- std::cerr << "Printing \"first\" prediction table." << std::endl;
+ //std::cerr << "Printing \"first\" prediction table." << std::endl;
map(print_first(&build_first,&build_empty))(input);
std::cout << "};" << std::endl;
- std::cerr << "Building \"follow\" prediction table." << std::endl;
+ //std::cerr << "Building \"follow\" prediction table." << std::endl;
BuildFollow build_follow(&build_empty, &build_first);
repeat(map_one(build_follow))(input);
std::cout << "const unsigned char follow[NUM_NT][32] = {" << std::endl;
- std::cerr << "Printing \"follow\" prediction table." << std::endl;
+ //std::cerr << "Printing \"follow\" prediction table." << std::endl;
map(scope(nt,
scope(l,
~Rule[nt, NoParam, return_type, l]
@@ -1301,7 +1301,7 @@
)(input);
std::cout << "};" << std::endl;
- std::cerr << "Printing declartions." << std::endl;
+ //std::cerr << "Printing declartions." << std::endl;
map(scope(nt,
scope(l,
~Rule[nt, NoParam, return_type, l]
@@ -1314,6 +1314,6 @@
)
)(input);
- std::cerr << "Printing code." << std::endl;
+ //std::cerr << "Printing code." << std::endl;
map(print_rule(&build_first, &build_empty, &build_follow))(input);
}
Modified: trunk/src/parser_generator/tests/Makefile.am
===================================================================
--- trunk/src/parser_generator/tests/Makefile.am 2010-09-01 12:36:23 UTC (rev 126)
+++ trunk/src/parser_generator/tests/Makefile.am 2010-09-01 19:31:08 UTC (rev 127)
@@ -15,6 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+include $(top_srcdir)/config/aurelia.mk
+@INCDEP@gamma_2_hh.dep
+
gamma_2_CPPFLAGS=-I. -I$(srcdir)/../.. $(EXTRACPPFLAGS) -DSRCDIR=\"$(srcdir)\"
check_PROGRAMS=gamma_2
@@ -23,23 +26,7 @@
gamma_2_SOURCES=gamma_2.cc
nodist_gamma_2_SOURCES=gamma_2.hh
-EXTRA_DIST=gamma_2.csf force-deps.mk input.txt
+EXTRA_DIST=gamma_2.csf input.txt
CLEANFILES=gamma_2.hh
-SUFFIXES=
--include $(srcdir)/force-deps.mk
-
-SUFFIXES+=.csf
-
-gamma_2.hh: ../parser_gen
-
-../parser_gen:
- cd .. && $(MAKE) $(AM_MAKEFLAGS) parser_gen
-
-.csf.hh:
- if ../parser_gen <$< >$@.tmp; then \
- mv -f $@.tmp $@; \
- else \
- rm -f $@.tmp; \
- exit 1; \
- fi
+$(gamma_2_OBJECTS): gamma_2.hh
Modified: trunk/src/parser_generator/tests/force-deps.mk
===================================================================
--- trunk/src/parser_generator/tests/force-deps.mk 2010-09-01 12:36:23 UTC (rev 126)
+++ trunk/src/parser_generator/tests/force-deps.mk 2010-09-01 19:31:08 UTC (rev 127)
@@ -1,18 +0,0 @@
-# This file is a part of Aurelia.
-# Copyright (C) 2010 Valentin David
-# Copyright (C) 2010 University of Bergen
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-gamma_2-gamma_2.o: gamma_2.hh
Modified: trunk/src/sig/tests/Makefile.am
===================================================================
--- trunk/src/sig/tests/Makefile.am 2010-09-01 12:36:23 UTC (rev 126)
+++ trunk/src/sig/tests/Makefile.am 2010-09-01 19:31:08 UTC (rev 127)
@@ -15,6 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+include $(top_srcdir)/config/aurelia.mk
+@INCDEP@stratego_hh.dep
+
test_CPPFLAGS=-I$(top_srcdir)/src -I.. -DSRCDIR="\"$(srcdir)\"" \
$(EXTRACPPFLAGS)
@@ -23,25 +26,12 @@
test_SOURCES=test.cc
nodist_test_SOURCES=stratego.hh
--include $(srcdir)/force-dep.mk
+$(test_OBJECTS): stratego.hh
-stratego.hh: ../sig
-
-../sig:
- cd .. && $(MAKE) $(AM_MAKEFLAGS) sig
-
-stratego.hh: stratego.rtree
- if ../sig <$< >stratego.hh.tmp; then \
- mv -f stratego.hh.tmp stratego.hh; \
- else \
- rm -f stratego.hh.tmp; \
- exit 1; \
- fi
-
TESTS=test
CLEANFILES=stratego.hh
-EXTRA_DIST=stratego.rtree force-dep.mk
+EXTRA_DIST=stratego.rtree
if HAVE_VALGRIND
TESTS_ENVIRONMENT=ulimit -s 8192; $(VALGRIND) --leak-check=full --show-reachable=yes --error-exitcode=1 >/dev/null --
Modified: trunk/src/sig/tests/force-dep.mk
===================================================================
--- trunk/src/sig/tests/force-dep.mk 2010-09-01 12:36:23 UTC (rev 126)
+++ trunk/src/sig/tests/force-dep.mk 2010-09-01 19:31:08 UTC (rev 127)
@@ -1,18 +0,0 @@
-# This file is a part of Aurelia.
-# Copyright (C) 2010 Valentin David
-# Copyright (C) 2010 University of Bergen
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-test-test.o: stratego.hh
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-09-01 12:36:30
|
Revision: 126
http://aurelia.svn.sourceforge.net/aurelia/?rev=126&view=rev
Author: valentindavid
Date: 2010-09-01 12:36:23 +0000 (Wed, 01 Sep 2010)
Log Message:
-----------
2010-09-01 Valentin David <val...@ii...>
* src/llstack/node.hpp:
Fix return for void. Set P was not updated in case of void return.
* src/parser_generator/parser_gen.cc,
* src/parser_generator/syntax.cc:
Comment too verbose debug messages.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/llstack/node.hpp
trunk/src/parser_generator/parser_gen.cc
trunk/src/parser_generator/syntax.cc
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-08-25 13:53:05 UTC (rev 125)
+++ trunk/ChangeLog 2010-09-01 12:36:23 UTC (rev 126)
@@ -1,3 +1,12 @@
+2010-09-01 Valentin David <val...@ii...>
+
+ * src/llstack/node.hpp:
+ Fix return for void. Set P was not updated in case of void return.
+
+ * src/parser_generator/parser_gen.cc,
+ * src/parser_generator/syntax.cc:
+ Comment too verbose debug messages.
+
2010-08-25 Valentin David <val...@ii...>
Use generic lists for terms and patterns.
Modified: trunk/src/llstack/node.hpp
===================================================================
--- trunk/src/llstack/node.hpp 2010-08-25 13:53:05 UTC (rev 125)
+++ trunk/src/llstack/node.hpp 2010-09-01 12:36:23 UTC (rev 126)
@@ -66,6 +66,7 @@
}
void node::pop(R_t& queue, const VoidReturn&, stream& j) {
+ this->P()[j].push_front(get().get_frame());
switch (this->parents().size()) {
case 0:
return ;
Modified: trunk/src/parser_generator/parser_gen.cc
===================================================================
--- trunk/src/parser_generator/parser_gen.cc 2010-08-25 13:53:05 UTC (rev 125)
+++ trunk/src/parser_generator/parser_gen.cc 2010-09-01 12:36:23 UTC (rev 126)
@@ -184,14 +184,35 @@
std::bitset<256> chars;
for (std::string::iterator i = c.begin();
i != c.end(); ++i) {
+ char current = *i;
+ if (current == '\\') {
+ std::string::iterator n = i;
+ ++n;
+ if (n != c.end()) {
+ i = n;
+ switch (*i) {
+ case 'n':
+ current = '\n';
+ break ;
+ case 'r':
+ current = '\r';
+ break ;
+ case 't':
+ current = '\t';
+ break ;
+ default:
+ current = *i;
+ }
+ }
+ }
if (in_range) {
- while (last_c <= (*i)) {
+ while (last_c <= current) {
chars[last_c] = true;
last_c++;
}
has_char = false;
in_range = false;
- } else if ((*i) == '-') {
+ } else if (current == '-') {
if (!has_char) {
last_c = '-';
has_char = true;
@@ -207,7 +228,7 @@
if (has_char) {
chars[last_c] = true;
}
- last_c = *i;
+ last_c = current;
has_char = true;
}
}
@@ -220,9 +241,9 @@
chars[i] = !chars[i];
}
}
- std::cerr << "Found: " << c << " -> ";
- print_bin(std::cerr, chars);
- std::cerr << std::endl;
+ //std::cerr << "Found: " << c << " -> ";
+ //print_bin(std::cerr, chars);
+ //std::cerr << std::endl;
return chars;
}
@@ -523,8 +544,8 @@
V s, attr;
AttrChainElt[attr,String[s]] = t;
cset[(unsigned char)(get_cons_name < undouble_quote < undouble_quote < unescape)(*s)[0]] = true;
- std::cerr << "after set: " << (unsigned char)(get_cons_name < undouble_quote < undouble_quote < unescape)(*s)[0] << " " << cset << std::endl;
- print_bin(std::cerr, cset);
+ //std::cerr << "after set: " << (unsigned char)(get_cons_name < undouble_quote < undouble_quote < unescape)(*s)[0] << " " << cset << std::endl;
+ //print_bin(std::cerr, cset);
return t;
}
catch (Failure) {
@@ -585,6 +606,11 @@
if (c == set[*nt])
throw Failure();
+ //std::cerr << "Was different for: " << *nt << std::endl;
+ //print_bin(std::cerr, c);
+ //std::cerr << " != ";
+ //print_bin(std::cerr, set[*nt]);
+ //std::cerr << std::endl;
set[*nt] = c;
return in;
}
@@ -702,7 +728,7 @@
Rule[nt, NoParam, return_type, l] = in;
char_set_t c;
- std::cerr << "rule: " << in << std::endl;
+ //std::cerr << "rule: " << in << std::endl;
static C Cons = C::AS_LIST;
@@ -729,12 +755,12 @@
< [this, &next, &firstof](const T& t) {
std::bitset<256> s;
if ((*build_empty)[t]) {
- std::cerr << t << " can be empty"
- << std::endl;
+ //std::cerr << t << " can be empty"
+ //<< std::endl;
s = firstof(*next);
}
- else std::cerr << t << " not empty"
- << std::endl;
+ // else std::cerr << t << " not empty"
+ // << std::endl;
return (*build_first)[t] | s;
})
+ (~Cons[AttrChainElt[attr,Class[s]], next]
@@ -772,10 +798,10 @@
if (t != set[*sym]) {
changed = true;
set[*sym] = t;
- std::cerr << "Setting: "
- << set_to_class(set[*sym])
- << " to " << *sym
- << std::endl;
+ // std::cerr << "Setting: "
+ // << set_to_class(set[*sym])
+ // << " to " << *sym
+ // << std::endl;
}
return t;
})
@@ -918,13 +944,13 @@
<<", 0>::res(), f, cu, s);" << std::endl;
++i;
return t;
- })((*l)[1]);
- std::cout << " if (test(s, NT_"<<nt_name<<", "<<nt_name<<"_"
- <<i<<"_0)) {" << std::endl;
- std::cout << " branch<"<<nt_name<<", "<<i<<", 0>::res n;"
- << std::endl;
- std::cout << " return n(R, f, s, cu);" << std::endl;
- std::cout << " }" << std::endl;
+ })(*l);
+ // std::cout << " if (test(s, NT_"<<nt_name<<", "<<nt_name<<"_"
+ // <<i<<"_0)) {" << std::endl;
+ //std::cout << " branch<"<<nt_name<<", "<<i<<", 0>::res n;"
+ // << std::endl;
+ // std::cout << " return n(R, f, s, cu);" << std::endl;
+ // std::cout << " }" << std::endl;
std::cout << " } else {" << std::endl;
i = 0;
@@ -1098,7 +1124,7 @@
V sym, attr;
AttrChainElt[attr, Symbol[sym, NoArg]] = head;
- std::cerr << *sym << " empty? " << (*build_empty)[*sym] << std::endl;
+ //std::cerr << *sym << " empty? " << (*build_empty)[*sym] << std::endl;
last.push_back((*build_empty)[*sym]);
} catch(Failure) {
last.push_back(false);
@@ -1113,7 +1139,7 @@
main->insert(main->end(), last.begin(), last.end());
main->push_back(true);
- std::cerr << "size: " <<main->size() << std::endl;
+ //std::cerr << "size: " <<main->size() << std::endl;
return l;
}
};
@@ -1200,6 +1226,7 @@
void parser_generator(T input)
{
BuildEmpty build_empty;
+ std::cerr << "Building \"empty\" prediction table." << std::endl;
repeat(map_one(build_empty))(input);
static C Rule("Rule", 4);
@@ -1208,6 +1235,7 @@
V l, nt, return_type;
std::cout << "enum nonterm {" << std::endl;
+ std::cerr << "Printing non-terminal list." << std::endl;
map(scope(nt, scope(l,
~Rule[nt, NoParam, return_type, l]
< !nt
@@ -1221,6 +1249,7 @@
std::cout << "};" << std::endl;
std::cout << "enum state {" << std::endl;
+ std::cerr << "Printing states list." << std::endl;
map(print_labels)(input);
std::cout << "};" << std::endl;
@@ -1230,6 +1259,7 @@
std::cout << "#include \"llstack/utils.hh\"" << std::endl;
std::cout << "const unsigned char empty_first[] = {";
+ std::cerr << "Printing \"empty\" prediction table." << std::endl;
GetBinEmpty gbe(&build_empty);
map(gbe)(input);
print_bin(std::cout, gbe->get_data().begin(), gbe->get_data().end());
@@ -1237,22 +1267,26 @@
BuildFirst build_first(&build_empty);
+ std::cerr << "Building \"first\" prediction table." << std::endl;
repeat(map_some(build_first))(input);
- for (BuildFirst::iterator i = build_first->begin();
- i != build_first->end(); ++i) {
- std::cerr << "// " << (*i).first << ":"
- << set_to_class((*i).second) << std::endl;
- }
+ // for (BuildFirst::iterator i = build_first->begin();
+ // i != build_first->end(); ++i) {
+ // std::cerr << "// " << (*i).first << ":"
+ // << set_to_class((*i).second) << std::endl;
+ // }
std::cout << "const unsigned char first[NUM_STATES][32] = {" << std::endl;
+ std::cerr << "Printing \"first\" prediction table." << std::endl;
map(print_first(&build_first,&build_empty))(input);
std::cout << "};" << std::endl;
+ std::cerr << "Building \"follow\" prediction table." << std::endl;
BuildFollow build_follow(&build_empty, &build_first);
repeat(map_one(build_follow))(input);
std::cout << "const unsigned char follow[NUM_NT][32] = {" << std::endl;
+ std::cerr << "Printing \"follow\" prediction table." << std::endl;
map(scope(nt,
scope(l,
~Rule[nt, NoParam, return_type, l]
@@ -1267,6 +1301,7 @@
)(input);
std::cout << "};" << std::endl;
+ std::cerr << "Printing declartions." << std::endl;
map(scope(nt,
scope(l,
~Rule[nt, NoParam, return_type, l]
@@ -1279,5 +1314,6 @@
)
)(input);
+ std::cerr << "Printing code." << std::endl;
map(print_rule(&build_first, &build_empty, &build_follow))(input);
}
Modified: trunk/src/parser_generator/syntax.cc
===================================================================
--- trunk/src/parser_generator/syntax.cc 2010-08-25 13:53:05 UTC (rev 125)
+++ trunk/src/parser_generator/syntax.cc 2010-09-01 12:36:23 UTC (rev 126)
@@ -42,10 +42,13 @@
struct Start {
void operator()(R_t&, const frame& f, stream& s, const node&) const {
- assert(!found);
if (s.eof()) {
ret_frame<T> rf0 = f.as<ret_frame<T> >();
- result = rf0.t;
+ if (found) {
+ assert(result == rf0.t);
+ }
+ else
+ result = rf0.t;
found = true;
}
}
@@ -71,19 +74,19 @@
u1.parents().insert(u0);
S start;
start(R, empty_frame(), s, u1);
- int lastpos = -1;
+ //int lastpos = -1;
try {
while (true) {
descriptor d = R.pop();
s = d.s;
- if (lastpos < s.get_pos()) {
- lastpos = s.get_pos();
- //std::stringstream ss;
- //ss << "graph." << s.get_pos();
- //std::ofstream out(ss.str());
- std::cerr << lastpos << std::endl;
- //node::printnodes(out);
- }
+ //if (lastpos < s.get_pos()) {
+ //lastpos = s.get_pos();
+ //std::stringstream ss;
+ //ss << "graph." << s.get_pos();
+ //std::ofstream out(ss.str());
+ //std::cerr << lastpos << std::endl;
+ //node::printnodes(out);
+ //}
d.L.call(R, d.f, d.s, d.n);
}
} catch (R_t::Eof) {
@@ -97,7 +100,7 @@
buf_stream bs(in);
stream s = bs.begin();
if (main_loop(s, bs.end())) {
- std::cerr << result << std::endl;
+ //std::cerr << result << std::endl;
T ret = result;
result.~T();
return ret;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-08-25 13:53:13
|
Revision: 125
http://aurelia.svn.sourceforge.net/aurelia/?rev=125&view=rev
Author: valentindavid
Date: 2010-08-25 13:53:05 +0000 (Wed, 25 Aug 2010)
Log Message:
-----------
2010-08-25 Valentin David <val...@ii...>
Use generic lists for terms and patterns.
* src/lists/list_concept.hh: Type enumerators. Fix static assert
on list size. Add a type traits to check a predicate over all
types of the list.
* src/lists/list.hh: Type enumerators. Remove definitions of
unused functions.
* src/lists/listable.hh,
* src/lists/tests/test_listable.cc:
Fix namespace issues with operator comma.
* src/terms/constructor.hh,
* src/terms/term.hh,
* src/patterns/term_pattern.hh:
Use generic lists.
* src/patterns/variable.hh,
* src/patterns/pair.hh:
Fix concept model definitions. Set elements as listable.
* src/patterns/pattern.hh: Fix concept model definitions.
Add predicate for testing if a type is a pattern type.
* src/type_traits/is_callable_with.hh: Extract itself.
* src/type_traits/itself.hh,
* src/type_traits/has_model.hh:
New.
* src/type_traits/Makefile.am: Update.
* src/strategies/patterns/scope.hh:
Remove variable lists.
* src/strategies/patterns/build.hh:
Fix model resolution.
* demos/11-pair_of_int.cc:
Set Int as listable.
Modified Paths:
--------------
trunk/ChangeLog
trunk/demos/11-pair_of_int.cc
trunk/src/lists/list.hh
trunk/src/lists/list_concept.hh
trunk/src/lists/listable.hh
trunk/src/lists/tests/test_listable.cc
trunk/src/patterns/pair.hh
trunk/src/patterns/pattern.hh
trunk/src/patterns/term_pattern.hh
trunk/src/patterns/variable.hh
trunk/src/strategies/patterns/build.hh
trunk/src/strategies/patterns/scope.hh
trunk/src/terms/constructor.hh
trunk/src/terms/term.hh
trunk/src/type_traits/Makefile.am
trunk/src/type_traits/is_callable_with.hh
Added Paths:
-----------
trunk/src/type_traits/has_model.hh
trunk/src/type_traits/itself.hh
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/ChangeLog 2010-08-25 13:53:05 UTC (rev 125)
@@ -1,5 +1,49 @@
2010-08-25 Valentin David <val...@ii...>
+ Use generic lists for terms and patterns.
+
+ * src/lists/list_concept.hh: Type enumerators. Fix static assert
+ on list size. Add a type traits to check a predicate over all
+ types of the list.
+
+ * src/lists/list.hh: Type enumerators. Remove definitions of
+ unused functions.
+
+ * src/lists/listable.hh,
+ * src/lists/tests/test_listable.cc:
+ Fix namespace issues with operator comma.
+
+ * src/terms/constructor.hh,
+ * src/terms/term.hh,
+ * src/patterns/term_pattern.hh:
+ Use generic lists.
+
+ * src/patterns/variable.hh,
+ * src/patterns/pair.hh:
+ Fix concept model definitions. Set elements as listable.
+
+ * src/patterns/pattern.hh: Fix concept model definitions.
+ Add predicate for testing if a type is a pattern type.
+
+ * src/type_traits/is_callable_with.hh: Extract itself.
+
+ * src/type_traits/itself.hh,
+ * src/type_traits/has_model.hh:
+ New.
+
+ * src/type_traits/Makefile.am: Update.
+
+ * src/strategies/patterns/scope.hh:
+ Remove variable lists.
+
+ * src/strategies/patterns/build.hh:
+ Fix model resolution.
+
+ * demos/11-pair_of_int.cc:
+ Set Int as listable.
+
+2010-08-25 Valentin David <val...@ii...>
+
* src/sig/tests/Makefile.am: Use Valgrind if present.
Mark test as XFAIL. To be fixed.
Modified: trunk/demos/11-pair_of_int.cc
===================================================================
--- trunk/demos/11-pair_of_int.cc 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/demos/11-pair_of_int.cc 2010-08-25 13:53:05 UTC (rev 125)
@@ -78,6 +78,15 @@
}
};
+namespace aurelia {
+ template <>
+ struct ListableModel<Int> {
+ struct Model {
+ typedef Int Type;
+ };
+ };
+}
+
struct IntPairPool {};
namespace aurelia {
@@ -111,7 +120,7 @@
IntPairCore(const Int& a, const Int& b)
: super(Constructor<Main>("PairOfInt", 2),
- TermList<Main,2>(TermList<Main,1>(TermList<Main,0>(), a), b)),
+ (a, b)),
a(a), b(b) {}
};
Modified: trunk/src/lists/list.hh
===================================================================
--- trunk/src/lists/list.hh 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/lists/list.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -22,6 +22,15 @@
namespace aurelia {
+ struct ListNil {
+ private:
+ public:
+ enum : unsigned { size = 0 };
+ ListNil() {}
+ ListNil(const ListNil&) {}
+ ListNil(ListNil&&) {}
+ };
+
template <typename T, typename Tail>
struct ListCons {
private:
@@ -29,7 +38,7 @@
Tail t;
public:
- enum { size = Tail::size+1 };
+ enum : unsigned { size = (unsigned)(Tail::size)+1 };
ListCons(T&& h, const Tail& t):
h(std::move(h)), t(t) {}
@@ -74,26 +83,12 @@
return ListCons<H,T>(h, t);
};
- struct ListNil {
- private:
- public:
- enum { size = 0 };
- ListNil() {}
- ListNil(const ListNil&) {}
- ListNil(ListNil&&) {}
- };
+ void head(ListNil);
- void head(ListNil) {
- }
+ ListNil tail(ListNil);
- ListNil tail(ListNil) {
- return ListNil();
- }
+ ListNil cons();
- ListNil cons() {
- return ListNil();
- }
-
}
#endif
Modified: trunk/src/lists/list_concept.hh
===================================================================
--- trunk/src/lists/list_concept.hh 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/lists/list_concept.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -32,13 +32,13 @@
typedef typename Model::Cons Cons;
typedef typename Model::Head Head;
typedef typename Model::Tail Tail;
- enum { size = Model::size };
+ enum { size = (unsigned)Model::size };
#ifdef DOC_GEN
Head head(Cons);
Tail tail(Cons);
Cons cons(Head, Tail);
#else
- static_assert((ListModel<Tail>::Model::size+1 == size) || ((size == 0) && (ListModel<Tail>::Model::size == 0)),
+ static_assert(((unsigned)ListModel<Tail>::Model::size+1 == size) || ((size == 0) && ((unsigned)ListModel<Tail>::Model::size == 0)),
"Wrong size");
static_assert(std::is_same<decltype(head(std::declval<Cons>())),
Head>::value,
@@ -69,7 +69,7 @@
typedef ListCons<H, T> Cons;
typedef H Head;
typedef T Tail;
- enum { size = ListCons<H, T>::size };
+ enum : unsigned { size = ListCons<H, T>::size };
};
};
@@ -81,10 +81,29 @@
typedef ListNil Cons;
typedef void Head;
typedef ListNil Tail;
- enum { size = ListNil::size };
+ enum : unsigned { size = ListNil::size };
};
};
+ template <template <typename> class Predicate,
+ typename T,
+ typename M = typename aurelia::ListModel<T>::Model,
+ bool = std::is_same<void, typename M::Head>::value,
+ bool = Predicate<typename M::Head>::value>
+ struct AllElements: public std::false_type {
+ };
+
+ template <template <typename> class Predicate,
+ typename T, typename M, bool whatever>
+ struct AllElements<Predicate, T, M, true, whatever>
+ : public AllElements<Predicate, typename M::Tail> {
+ };
+
+ template <template <typename> class Predicate,
+ typename T, typename M>
+ struct AllElements<Predicate, T, M, false, true>: public std::true_type {
+ };
+
}
#endif
Modified: trunk/src/lists/listable.hh
===================================================================
--- trunk/src/lists/listable.hh 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/lists/listable.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -35,23 +35,18 @@
}
-namespace {
- using namespace aurelia;
+template <typename H, typename T,
+ typename = typename aurelia::ListableModel<H>::Model,
+ typename = typename aurelia::ListModel<T>::Model>
+aurelia::ListCons<H,T> operator,(const T& t, const H& h) {
+ return aurelia::ListCons<H,T>(h, t);
+}
- template <typename H, typename T,
- typename = typename ListableModel<H>::Model,
- typename = typename ListModel<T>::Model>
- ListCons<H,T> operator,(const T& t, const H& h) {
- return ListCons<H,T>(h, t);
- }
-
- template <typename H, typename T,
- typename = typename ListableModel<H>::Model,
- typename = typename ListableModel<T>::Model>
- ListCons<H,ListCons<T,ListNil> > operator,(const T& t, const H& h) {
- return ListCons<H,ListCons<T,ListNil> >(h, ListCons<T,ListNil>(t, ListNil()));
- }
-
+template <typename H, typename T,
+ typename = typename aurelia::ListableModel<H>::Model,
+ typename = typename aurelia::ListableModel<T>::Model>
+aurelia::ListCons<H,aurelia::ListCons<T,aurelia::ListNil> > operator,(const T& t, const H& h) {
+ return aurelia::ListCons<H,aurelia::ListCons<T,aurelia::ListNil> >(h, aurelia::ListCons<T,aurelia::ListNil>(t, aurelia::ListNil()));
}
#endif
Modified: trunk/src/lists/tests/test_listable.cc
===================================================================
--- trunk/src/lists/tests/test_listable.cc 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/lists/tests/test_listable.cc 2010-08-25 13:53:05 UTC (rev 125)
@@ -17,6 +17,8 @@
#include <lists/listable.hh>
+using namespace aurelia;
+
struct Foo {
private:
int value;
Modified: trunk/src/patterns/pair.hh
===================================================================
--- trunk/src/patterns/pair.hh 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/patterns/pair.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -18,20 +18,21 @@
# define __PAIR_HH
# include <algorithm>
+# include "../lists/listable.hh"
namespace aurelia {
template <typename A, typename B>
struct P {
- typedef PatternConcept<PatternModel<A> > require1;
- typedef PatternConcept<PatternModel<B> > require2;
+ typedef PatternConcept<typename PatternModel<A>::Model> require1;
+ typedef PatternConcept<typename PatternModel<B>::Model> require2;
private:
A a;
B b;
public:
- typedef std::pair<typename PatternModel<A>::BuildType,
- typename PatternModel<B>::BuildType> BuildType;
+ typedef std::pair<typename PatternModel<A>::Model::BuildType,
+ typename PatternModel<B>::Model::BuildType> BuildType;
P(const A& a, const B& b): a(a), b(b) {}
BuildType operator*() const {
@@ -50,11 +51,13 @@
*/
template <typename A, typename B>
struct PatternModel<P<A, B> > {
- typedef PatternConcept<PatternModel<A> > require1;
- typedef PatternConcept<PatternModel<B> > require2;
+ struct Model {
+ typedef PatternConcept<PatternModel<A> > require1;
+ typedef PatternConcept<PatternModel<B> > require2;
- typedef P<A, B> Type;
- typedef typename P<A, B>::BuildType BuildType;
+ typedef P<A, B> Type;
+ typedef typename P<A, B>::BuildType BuildType;
+ };
};
template <typename A, typename B>
@@ -62,6 +65,13 @@
return P<A,B>(a, b);
}
+ template <typename A, typename B>
+ struct ListableModel<P<A, B> > {
+ struct Model {
+ typedef P<A,B> Type;
+ };
+ };
+
}
#endif
Modified: trunk/src/patterns/pattern.hh
===================================================================
--- trunk/src/patterns/pattern.hh 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/patterns/pattern.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -22,6 +22,7 @@
# include "../terms/constructor.hh"
# include "../terms/term.hh"
# include "../strategies/failure.hh"
+# include "../type_traits/has_model.hh"
namespace aurelia {
@@ -63,8 +64,14 @@
* Model for for \ref PatternConcept
*/
template <typename T>
- struct PatternModel;
+ struct PatternModel {
+ typedef void NoModel;
+ };
+ template <typename Pool, typename T>
+ struct IsPattern_traits: public type_traits::has_model<PatternModel<T> > {
+ };
+
}
# include "term_pattern.hh"
Modified: trunk/src/patterns/term_pattern.hh
===================================================================
--- trunk/src/patterns/term_pattern.hh 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/patterns/term_pattern.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -18,45 +18,49 @@
# define __TERM_PATTERN_HH
# include "pattern.hh"
+# include "../lists/listable.hh"
namespace aurelia {
template <typename Pool>
- struct Top {
- enum : unsigned { N = 0 };
+ void assign(const ListNil&, const Term<Pool>&) {
+ }
- void assign(const Term<Pool>&, unsigned n) {
- if (n != 0)
- throw Failure();
- }
+ template <typename Pool, typename T, typename M = typename aurelia::ListModel<T>::Model,
+ typename = typename std::enable_if<!std::is_same<void, typename M::Head>::value>::type>
+ void assign(const T& l, const Term<Pool>& t) {
+ typedef typename aurelia::ListConcept<M>::Check require;
+ head(l) = t[M::size-1];
+ assign(tail(l), t);
+ }
- TermList<Pool, 0> operator*() const {
- return TermList<Pool, 0>();
- }
+ ListNil build(const ListNil&) {
+ return ListNil();
+ }
+
+ template <typename T>
+ struct BuildType {
};
- template <typename Pool, typename Head, typename Tail>
- struct PatternList {
- typedef PatternConcept<PatternModel<Head> > require;
- private:
- Head h;
- Tail t;
+ template <typename H, typename T>
+ struct BuildType<ListCons<H, T> > {
+ typedef ListCons<typename PatternModel<H>::Model::BuildType, typename BuildType<T>::type> type;
+ };
- public:
- enum : unsigned { N = (unsigned)Head::N + 1 };
+ template <>
+ struct BuildType<ListNil> {
+ typedef ListNil type;
+ };
- PatternList(const Head& h, const Tail& t): h(h), t(t) {
- }
+ template <typename T, typename M = typename ListModel<T>::Model,
+ typename = typename std::enable_if<!std::is_same<void, typename M::Head>::value>::type>
+ typename BuildType<T>::type build(const T& l) {
+ typedef typename aurelia::ListConcept<M>::Check require;
+ return typename BuildType<T>::type
+ (*head(l), build(tail(l)));
+ }
- void assign(const Term<Pool>& term, unsigned n) {
- h.assign(term, n-1);
- t = term[n-1];
- }
- TermList<Pool, N> operator*() const {
- return TermList<Pool, N>(*h, *t);
- }
- };
template <typename Pool, typename List>
struct Pattern {
@@ -70,12 +74,12 @@
const Term<Pool>& operator=(const Term<Pool>& t) {
if (c != t.constructor())
throw Failure();
- l.assign(t, t.constructor().arity());
+ assign(l, t);
return t;
}
Term<Pool> operator*() const {
- return Term<Pool>(c, *l);
+ return Term<Pool>(c, build(l));
}
};
@@ -83,99 +87,29 @@
*/
template <typename Pool, typename List>
struct PatternModel<Pattern<Pool, List> > {
- typedef Pattern<Pool, List> Type;
- typedef Term<Pool> BuildType;
+ struct Model {
+ typedef Pattern<Pool, List> Type;
+ typedef Term<Pool> BuildType;
+ };
};
- template <typename Head, typename Pool>
- PatternList<Pool,Head,Variable<Term<Pool> > > operator,(const Head& h,
- const Variable<Term<Pool> > & t) {
- return PatternList<Pool,Head,Variable<Term<Pool> > >(h, t);
- }
+ template <typename Pool, typename List>
+ struct ListableModel<Pattern<Pool, List> > {
+ struct Model {
+ typedef Pattern<Pool, List> Type;
+ };
+ };
- template <typename Head, typename Pool, typename Params>
- PatternList<Pool, Head, Pattern<Pool, Params> >
- operator,(const Head& h, const Pattern<Pool, Params>& t) {
- return PatternList<Pool, Head, Pattern<Pool, Params> >(h, t);
- }
-
template <typename Pool>
- PatternList<Pool,PatternList<Pool,Top<Pool>,Variable<Term<Pool> > >,Variable<Term<Pool> > >
- operator,(const Variable<Term<Pool> > & h, const Variable<Term<Pool> > & t) {
- return PatternList<Pool,PatternList<Pool,Top<Pool>,Variable<Term<Pool> > >,
- Variable<Term<Pool> > >(PatternList<Pool,Top<Pool>,Variable<Term<Pool> > >(Top<Pool>(),h),
- t);
+ template <typename L,
+ typename,
+ template <typename> class,
+ template <typename> class,
+ typename,
+ typename>
+ Pattern<Pool, L> Constructor<Pool>::operator[](const L& l) const {
+ return Pattern<Pool, L>(*this, l);
}
-
- template <typename Pool, typename Params>
- PatternList<Pool,PatternList<Pool,Top<Pool>, Pattern<Pool, Params> >,
- Variable<Term<Pool> > >
- operator,(const Pattern<Pool, Params>& h, const Variable<Term<Pool> > & t) {
- return PatternList<Pool,PatternList<Pool,Top<Pool>,
- Pattern<Pool, Params> >,
- Variable<Term<Pool> > >(PatternList<Pool,Top<Pool>,
- Pattern<Pool, Params> >(Top<Pool>(),h), t);
- }
-
- template <typename Pool, typename Params,
- typename Params2>
- PatternList<Pool,PatternList<Pool,Top<Pool>,
- Pattern<Pool, Params> >,
- Pattern<Pool, Params2> >
- operator,(const Pattern<Pool, Params>& h,
- const Pattern<Pool, Params2>& t) {
- return PatternList<Pool,PatternList<Pool,Top<Pool>,
- Pattern<Pool, Params> >,Pattern<Pool, Params2> >
- (PatternList<Pool,Top<Pool>,Pattern<Pool, Params> >
- (Top<Pool>(),h), t);
- }
-
- template <typename Pool, typename Params>
- PatternList<Pool,PatternList<Pool,Top<Pool>,Variable<Term<Pool> > >,
- Pattern<Pool, Params> >
- operator,(const Variable<Term<Pool> > & h, const Pattern<Pool, Params>& t) {
- return PatternList<Pool,PatternList<Pool,Top<Pool>,Variable<Term<Pool> > >,
- Pattern<Pool, Params> >(PatternList<Pool,Top<Pool>,
- Variable<Term<Pool> > >(Top<Pool>(),h), t);
- }
-
- template <typename Pool>
- template <typename List>
- Pattern<Pool, List>
- Constructor<Pool>::operator[](const List& l) const {
- return Pattern<Pool, List>(*this, l);
- }
-
- template <typename Pool>
- template <typename List>
- Pattern<Pool, PatternList<Pool, Top<Pool>, Term<Pool> > >
- Constructor<Pool>::operator[](const Term<Pool>& l) const {
- return Pattern<Pool, PatternList<Pool, Top<Pool>,
- Term<Pool> > >(*this, PatternList<Pool, Top<Pool>, Term<Pool> >
- (Top<Pool>(), l));
- }
-
- template <typename Pool>
- template <typename List>
- Pattern<Pool, PatternList<Pool, Top<Pool>,
- Pattern<Pool, List> > >
- Constructor<Pool>::operator[](const Pattern<Pool, List>& l) const {
- return Pattern<Pool, PatternList<Pool, Top<Pool>,
- Pattern<Pool, List> > >(*this,
- PatternList<Pool, Top<Pool>,
- Pattern<Pool, List> >
- (Top<Pool>(), l));
- }
-
- template <typename Pool>
- Pattern<Pool, PatternList<Pool, Top<Pool>,
- Variable<Term<Pool> > > >
- Constructor<Pool>::operator[](const Variable<Term<Pool> > & t) const {
- return Pattern<Pool, PatternList<Pool, Top<Pool>,
- Variable<Term<Pool> > > >(*this, PatternList<Pool, Top<Pool>,
- Variable<Term<Pool> > >(Top<Pool>(), t));
- }
-
}
#endif
Modified: trunk/src/patterns/variable.hh
===================================================================
--- trunk/src/patterns/variable.hh 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/patterns/variable.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -20,6 +20,7 @@
# include "pattern.hh"
# include <memory>
# include <stack>
+# include "../lists/listable.hh"
namespace aurelia {
@@ -80,10 +81,19 @@
*/
template <typename T>
struct PatternModel<Variable<T> > {
- typedef Variable<T> Type;
- typedef T BuildType;
+ struct Model {
+ typedef Variable<T> Type;
+ typedef T BuildType;
+ };
};
+ template <typename T>
+ struct ListableModel<Variable<T> > {
+ struct Model {
+ typedef Variable<T> Type;
+ };
+ };
+
}
#endif
Modified: trunk/src/strategies/patterns/build.hh
===================================================================
--- trunk/src/strategies/patterns/build.hh 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/strategies/patterns/build.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -34,7 +34,7 @@
}
template <typename Y>
- typename PatternModel<T>::BuildType operator()(const Y&) const {
+ typename PatternModel<T>::Model::BuildType operator()(const Y&) const {
return *pat;
}
};
Modified: trunk/src/strategies/patterns/scope.hh
===================================================================
--- trunk/src/strategies/patterns/scope.hh 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/strategies/patterns/scope.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -51,61 +51,23 @@
}
};
- template <typename H, typename T>
- struct VariableListCons {
- private:
- H h;
- T t;
- public:
- VariableListCons(const H& h, const T& t):
- h(h), t(t) {}
-
- void push() {
- h.push();
- t.push();
- }
- void pop() {
- h.pop();
- t.pop();
- }
- };
-
- struct VariableListEnd {
- public:
- void push() const {}
- void pop() const {}
- };
-
- template <typename V, typename U>
- VariableListCons<Variable<V>,
- VariableListCons<
- Variable<U>,
- VariableListEnd>
- >
- operator,(const Variable<V>& v, const Variable<U>& u) {
- return
- VariableListCons<Variable<V>, VariableListCons<Variable<U>,
- VariableListEnd> >
- (v, VariableListCons<Variable<U>, VariableListEnd>(u, VariableListEnd()));
- }
-
- template <typename H, typename L, typename U>
- VariableListCons<Variable<U>, VariableListCons<H, L> >
- operator,(const VariableListCons<H, L>& v, const Variable<U>& u) {
- return
- VariableListCons<Variable<U>, VariableListCons<H, L> >
- (u, v);
- }
-
template <typename Strat, typename T>
Scope<Strat, Variable<T> > scope(const Variable<T>& v, const Strat& s) {
return Scope<Strat, Variable<T> >(s, v);
}
- template <typename Strat, typename T, typename U>
- Scope<Strat, VariableListCons<T, U> >
- scope(const VariableListCons<T, U>& v, const Strat& s) {
- return Scope<Strat, VariableListCons<T, U> >(s, v);
+ template <typename T>
+ struct IsVariable: public std::false_type {};
+
+ template <typename T>
+ struct IsVariable<Variable<T> >: public std::true_type {};
+
+ template <typename Strat, typename L,
+ typename = typename ListModel<L>::Model,
+ typename = typename std::enable_if<AllElements<IsVariable, L>::value>::type>
+ Scope<Strat, L>
+ scope(const L& v, const Strat& s) {
+ return Scope<Strat, L>(s, v);
}
}
Modified: trunk/src/terms/constructor.hh
===================================================================
--- trunk/src/terms/constructor.hh 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/terms/constructor.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -19,12 +19,11 @@
# include "shared_object.hh"
# include <string>
+# include "../lists/list_concept.hh"
+# include "../lists/listable.hh"
namespace aurelia {
-template <typename Pool, unsigned N>
-struct TermList;
-
template <typename Pool>
struct Term;
@@ -34,12 +33,44 @@
template <typename Pool, typename List>
struct Pattern;
-template <typename Pool, typename Head, typename Tail>
-struct PatternList;
-
template <typename Pool>
struct Top;
+template <typename Pool>
+struct Constructor;
+
+ template <typename T>
+ struct PatternModel;
+
+ template <typename Pool, typename T>
+ struct IsTerm_traits : public std::false_type {
+ };
+
+ template <typename Pool>
+ struct IsTerm_traits<Pool, Term<Pool> > : public std::true_type {
+ };
+
+ template <typename Pool>
+ struct IsTerm_traits<Pool, Constructor<Pool> > : public std::true_type {
+ };
+
+ template <typename Pool>
+ struct IsTerm {
+ template <typename T>
+ struct traits : public IsTerm_traits<Pool, T> {
+ };
+ };
+
+ template <typename Pool, typename T>
+ struct IsPattern_traits;
+
+ template <typename Pool>
+ struct IsPattern {
+ template <typename T>
+ struct traits : public IsPattern_traits<Pool, T> {
+ };
+ };
+
struct ConstructorCore {
private:
std::string _name;
@@ -144,26 +175,33 @@
static Constructor AS_EMPTY_LIST;
static Constructor AS_ANNOTATION;
- template <unsigned N>
- Term<Pool> operator[](const TermList<Pool, N>&) const;
+ template <typename L,
+ typename = typename ListModel<L>::Model,
+ template <typename> class Predicate = IsTerm<Pool>::template traits,
+ typename = typename std::enable_if<AllElements<Predicate, L>::value>::type>
+ Term<Pool> operator[](const L&) const;
- Term<Pool> operator[](const Term<Pool>&) const;
+ Term<Pool> operator[](const Term<Pool>& t) const {
+ return (*this)[ListCons<Term<Pool>, ListNil>(t, ListNil())];
+ }
- Term<Pool> operator[](const Constructor<Pool>&) const;
+ Term<Pool> operator[](const Constructor<Pool>& c) const {
+ return (*this)[ListCons<Term<Pool>, ListNil>(c, ListNil())];
+ }
- template <typename List>
- Pattern<Pool, List> operator[](const List&) const;
+ template <typename P,
+ typename = typename PatternModel<P>::Model>
+ Pattern<Pool, ListCons<P, ListNil> > operator[](const P& p) const {
+ return (*this)[ListCons<P, ListNil>(p, ListNil())];
+ }
- Pattern<Pool, PatternList<Pool, Top<Pool>, Variable<Term<Pool> > > >
- operator[](const Variable<Term<Pool> >&) const;
-
- template <typename List>
- Pattern<Pool, PatternList<Pool, Top<Pool>, Term<Pool> > >
- operator[](const Term<Pool>& l) const;
-
- template <typename List>
- Pattern<Pool, PatternList<Pool, Top<Pool>, Pattern<Pool, List> > >
- operator[](const Pattern<Pool, List>& l) const;
+ template <typename L,
+ typename = typename ListModel<L>::Model,
+ template <typename> class TermPredicate = IsTerm<Pool>::template traits,
+ template <typename> class PatternPredicate = IsPattern<Pool>::template traits,
+ typename = typename std::enable_if<!(AllElements<TermPredicate, L>::value)>::type,
+ typename = typename std::enable_if<AllElements<PatternPredicate, L>::value>::type>
+ Pattern<Pool, L> operator[](const L& l) const;
};
template <typename Pool>
@@ -185,6 +223,15 @@
return s;
}
+
+ template <typename Pool>
+ struct ListableModel<Constructor<Pool> > {
+ struct Model {
+ typedef Constructor<Pool> Type;
+ };
+ };
+
+
}
#endif
Modified: trunk/src/terms/term.hh
===================================================================
--- trunk/src/terms/term.hh 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/terms/term.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -26,31 +26,13 @@
# include <cassert>
# include <cstdlib>
# include "../strategies/failure.hh"
+# include "../lists/listable.hh"
namespace aurelia {
template <typename Pool>
struct Term;
-template <typename Pool, unsigned N>
-struct TermList: private TermList<Pool, N-1> {
-private:
- const Term<Pool> t;
-public:
- typedef TermList<Pool, N-1> super;
- TermList(const super& o, const Term<Pool>& t): super(o), t(t) {}
-
- void copy(Term<Pool>* list) const {
- super::copy(list);
- new (list+(N-1)) Term<Pool>(t);
- }
-};
-
-template <typename Pool>
-struct TermList<Pool, 0> {
- void copy(const Term<Pool>*) const {}
-};
-
//! \brief Type traits for selecting type of children
template <typename T>
struct ChildrenType {
@@ -89,19 +71,34 @@
other->_hash = h;
}
- template <unsigned N>
- TermCore(const Constructor<Pool>& c, const TermList<ChPool,N>& ch)
+private:
+ void copy(const ListNil&, ChType*) {
+ }
+
+ template <typename T, typename M = typename aurelia::ListModel<T>::Model,
+ typename = typename std::enable_if<!std::is_same<void, typename M::Head>::value>::type>
+ void copy(const T& l, ChType* list) {
+ new (list+(unsigned)M::size-1) ChType(head(l));
+ copy(tail(l), list);
+ }
+
+public:
+
+ //!FIXME: check that all types in the list are ChType
+ template <typename L,
+ typename M = typename ListModel<L>::Model>
+ TermCore(const Constructor<Pool>& c, const L& ch)
: _constructor(c) {
- if (c.arity() != N) {
+ if (c.arity() != M::size) {
children = NULL;
throw Failure();
}
_hash = c.hash();
- if (N != 0)
- children = (ChType*)malloc(N*sizeof(ChType));
+ if (M::size != 0)
+ children = (ChType*)malloc((unsigned)M::size*sizeof(ChType));
else
children = NULL;
- ch.copy(children);
+ copy(ch, children);
for (unsigned i = 0; i < c.arity(); ++i) {
_hash ^= children[i].hash();
_hash = (_hash << 11) | (_hash >> 21);
@@ -222,8 +219,9 @@
new (static_cast<super*>(this)) super(tmp);
}
- template <unsigned N>
- Term(const Constructor<Pool>& c, const TermList<ChPool, N>&l)
+ template <typename L,
+ typename M = typename ListModel<L>::Model>
+ Term(const Constructor<Pool>& c, const L&l)
: super(NoBuild()) {
typename CoreTypeOf<Term<Pool> >::res tmp(c, l);
new (static_cast<super*>(this)) super(tmp);
@@ -243,7 +241,7 @@
Term(const Constructor<Pool>& c)
: super(NoBuild()) {
- new (this) Term(c, TermList<ChPool, 0>());
+ new (this) Term(c, ListNil());
}
Constructor<Pool> constructor() const {
@@ -254,8 +252,8 @@
return this->get()[i];
}
- operator TermList<ChPool, 1>() const {
- return TermList<ChPool, 1>(TermList<ChPool, 0>(), *this);
+ operator ListCons<ChType, ListNil>() const {
+ return ListCons<ChType, ListNil>()(*this, ListNil());
}
unsigned hash() const {
@@ -267,36 +265,6 @@
}
};
-template <unsigned N, typename Pool>
-TermList<Pool,N+1> operator,(const TermList<Pool, N>& l, const Term<Pool>& t) {
- return TermList<Pool,N+1>(l, t);
-}
-
-template <unsigned N, typename Pool>
-TermList<Pool,N+1> operator,(const TermList<Pool, N>& l, const Constructor<Pool>& t) {
- return TermList<Pool,N+1>(l, t);
-}
-
-template <typename Pool>
-TermList<Pool, 2> operator,(const Term<Pool>& l, const Term<Pool>& t) {
- return TermList<Pool,2>(l, t);
-}
-
-template <typename Pool>
-TermList<Pool, 2> operator,(const Constructor<Pool>& l, const Term<Pool>& t) {
- return TermList<Pool,2>(Term<Pool>(l), t);
-}
-
-template <typename Pool>
-TermList<Pool, 2> operator,(const Constructor<Pool>& l, const Constructor<Pool>& t) {
- return TermList<Pool,2>(Term<Pool>(l), Term<Pool>(t));
-}
-
-template <typename Pool>
-TermList<Pool, 2> operator,(const Term<Pool>& l, const Constructor<Pool>& t) {
- return TermList<Pool,2>(l, Term<Pool>(t));
-}
-
template <typename Stream, typename Pool>
void print(Stream& s, const Term<Pool>& t, bool inlist = false) {
if (t.constructor() == Constructor<Pool>::AS_EMPTY_LIST) {
@@ -338,21 +306,22 @@
return s;
}
-template <typename Pool>
-template <unsigned N>
-Term<Pool> Constructor<Pool>::operator[](const TermList<Pool, N>& l) const {
- return Term<Pool>(*this, l);
-}
+ template <typename Pool>
+ struct ListableModel<Term<Pool> > {
+ struct Model {
+ typedef Term<Pool> Type;
+ };
+ };
-template <typename Pool>
-Term<Pool> Constructor<Pool>::operator[](const Term<Pool>& l) const {
- return Term<Pool>(*this, TermList<Pool,1>(TermList<Pool,0>(l)));
-}
-template <typename Pool>
-Term<Pool> Constructor<Pool>::operator[](const Constructor<Pool>& l) const {
- return Term<Pool>(*this, TermList<Pool,1>(TermList<Pool,0>(),Term<Pool>(l)));
-}
+ template <typename Pool>
+ template <typename L,
+ typename,
+ template <typename> class,
+ typename>
+ Term<Pool> Constructor<Pool>::operator[](const L& l) const {
+ return Term<Pool>(*this, l);
+ }
}
Modified: trunk/src/type_traits/Makefile.am
===================================================================
--- trunk/src/type_traits/Makefile.am 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/type_traits/Makefile.am 2010-08-25 13:53:05 UTC (rev 125)
@@ -17,6 +17,8 @@
type_traits_HEADERS= \
is_callable_with.hh \
- overloading_priority.hh
+ overloading_priority.hh \
+ has_model.hh \
+ itself.hh
type_traitsdir=$(includedir)/type_traits
Added: trunk/src/type_traits/has_model.hh
===================================================================
--- trunk/src/type_traits/has_model.hh (rev 0)
+++ trunk/src/type_traits/has_model.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -0,0 +1,46 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#ifndef __HAS_MODEL_HH
+# define __HAS_MODEL_HH
+
+# include <type_traits>
+# include "itself.hh"
+
+namespace aurelia {
+ namespace type_traits {
+
+ template <typename T,
+ typename = typename T::Model>
+ std::true_type has_model_helper(const T&) {
+ assert(false);
+ return std::true_type();
+ }
+
+ template <typename T,
+ typename = typename T::NoModel>
+ std::false_type has_model_helper(const T&) {
+ assert(false);
+ return std::false_type();
+ }
+
+ template <typename T>
+ struct has_model: public itself<decltype(has_model_helper(std::declval<T>()))>::type {
+ };
+ }
+}
+
+#endif
Modified: trunk/src/type_traits/is_callable_with.hh
===================================================================
--- trunk/src/type_traits/is_callable_with.hh 2010-08-25 13:39:48 UTC (rev 124)
+++ trunk/src/type_traits/is_callable_with.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -19,6 +19,7 @@
# include <type_traits>
# include "overloading_priority.hh"
+# include "itself.hh"
namespace aurelia {
namespace type_traits {
@@ -42,11 +43,6 @@
return 0;
}
- template <typename T>
- struct itself {
- typedef T type;
- };
-
template <typename T, typename U>
struct is_callable_with:
public itself<decltype(is_callable_helper(try_first(),
Added: trunk/src/type_traits/itself.hh
===================================================================
--- trunk/src/type_traits/itself.hh (rev 0)
+++ trunk/src/type_traits/itself.hh 2010-08-25 13:53:05 UTC (rev 125)
@@ -0,0 +1,32 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#ifndef __ITSELF_HH
+# define __ITSELF_HH
+
+namespace aurelia {
+ namespace type_traits {
+ //! \brief Used when the compiler does not recognize
+ // type expressions (e.g. decltype).
+ template <typename T>
+ struct itself {
+ typedef T type;
+ };
+
+ }
+}
+
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-08-25 13:39:54
|
Revision: 124
http://aurelia.svn.sourceforge.net/aurelia/?rev=124&view=rev
Author: valentindavid
Date: 2010-08-25 13:39:48 +0000 (Wed, 25 Aug 2010)
Log Message:
-----------
2010-08-25 Valentin David <val...@ii...>
* src/sig/tests/Makefile.am: Use Valgrind if present.
Mark test as XFAIL. To be fixed.
* src/parser_generator/tests/Makefile.am:
Fix call of "make check" before "make all".
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/parser_generator/tests/Makefile.am
trunk/src/sig/tests/Makefile.am
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-08-24 15:32:32 UTC (rev 123)
+++ trunk/ChangeLog 2010-08-25 13:39:48 UTC (rev 124)
@@ -1,3 +1,11 @@
+2010-08-25 Valentin David <val...@ii...>
+
+ * src/sig/tests/Makefile.am: Use Valgrind if present.
+ Mark test as XFAIL. To be fixed.
+
+ * src/parser_generator/tests/Makefile.am:
+ Fix call of "make check" before "make all".
+
2010-08-24 Valentin David <val...@ii...>
Add utilities for handling constant size list building with
Modified: trunk/src/parser_generator/tests/Makefile.am
===================================================================
--- trunk/src/parser_generator/tests/Makefile.am 2010-08-24 15:32:32 UTC (rev 123)
+++ trunk/src/parser_generator/tests/Makefile.am 2010-08-25 13:39:48 UTC (rev 124)
@@ -1,4 +1,4 @@
- # This file is a part of Aurelia.
+# This file is a part of Aurelia.
# Copyright (C) 2010 Valentin David
# Copyright (C) 2010 University of Bergen
#
@@ -31,6 +31,11 @@
SUFFIXES+=.csf
+gamma_2.hh: ../parser_gen
+
+../parser_gen:
+ cd .. && $(MAKE) $(AM_MAKEFLAGS) parser_gen
+
.csf.hh:
if ../parser_gen <$< >$@.tmp; then \
mv -f $@.tmp $@; \
Modified: trunk/src/sig/tests/Makefile.am
===================================================================
--- trunk/src/sig/tests/Makefile.am 2010-08-24 15:32:32 UTC (rev 123)
+++ trunk/src/sig/tests/Makefile.am 2010-08-25 13:39:48 UTC (rev 124)
@@ -42,3 +42,9 @@
CLEANFILES=stratego.hh
EXTRA_DIST=stratego.rtree force-dep.mk
+
+if HAVE_VALGRIND
+TESTS_ENVIRONMENT=ulimit -s 8192; $(VALGRIND) --leak-check=full --show-reachable=yes --error-exitcode=1 >/dev/null --
+endif
+
+XFAIL_TESTS=test
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-08-24 15:32:41
|
Revision: 123
http://aurelia.svn.sourceforge.net/aurelia/?rev=123&view=rev
Author: valentindavid
Date: 2010-08-24 15:32:32 +0000 (Tue, 24 Aug 2010)
Log Message:
-----------
2010-08-24 Valentin David <val...@ii...>
Add utilities for handling constant size list building with
operator comma.
* src/lists/tests/test_listable.cc,
* src/lists/tests/Makefile.am,
* src/lists/list_concept.hh,
* src/lists/list.hh,
* src/lists/Makefile.am,
* src/lists/listable.hh:
New.
* src/Makefile.am,
* configure.ac:
Update.
Modified Paths:
--------------
trunk/ChangeLog
trunk/configure.ac
trunk/src/Makefile.am
Added Paths:
-----------
trunk/src/lists/
trunk/src/lists/Makefile.am
trunk/src/lists/list.hh
trunk/src/lists/list_concept.hh
trunk/src/lists/listable.hh
trunk/src/lists/tests/
trunk/src/lists/tests/Makefile.am
trunk/src/lists/tests/test_listable.cc
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-08-24 15:30:01 UTC (rev 122)
+++ trunk/ChangeLog 2010-08-24 15:32:32 UTC (rev 123)
@@ -1,5 +1,22 @@
2010-08-24 Valentin David <val...@ii...>
+ Add utilities for handling constant size list building with
+ operator comma.
+
+ * src/lists/tests/test_listable.cc,
+ * src/lists/tests/Makefile.am,
+ * src/lists/list_concept.hh,
+ * src/lists/list.hh,
+ * src/lists/Makefile.am,
+ * src/lists/listable.hh:
+ New.
+
+ * src/Makefile.am,
+ * configure.ac:
+ Update.
+
+2010-08-24 Valentin David <val...@ii...>
+
Fix compilation with -DNDEBUG.
* src/llstack/frame.hh,
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2010-08-24 15:30:01 UTC (rev 122)
+++ trunk/configure.ac 2010-08-24 15:32:32 UTC (rev 123)
@@ -156,6 +156,8 @@
demos/Makefile
src/memory/Makefile
src/memory/tests/Makefile
+ src/lists/Makefile
+ src/lists/tests/Makefile
src/type_traits/Makefile
src/terms/Makefile
src/strategies/Makefile
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2010-08-24 15:30:01 UTC (rev 122)
+++ trunk/src/Makefile.am 2010-08-24 15:32:32 UTC (rev 123)
@@ -17,6 +17,7 @@
SUBDIRS= \
memory \
+ lists \
type_traits \
llstack \
patterns \
Property changes on: trunk/src/lists
___________________________________________________________________
Added: svn:ignore
+ Makefile
Makefile.in
Added: trunk/src/lists/Makefile.am
===================================================================
--- trunk/src/lists/Makefile.am (rev 0)
+++ trunk/src/lists/Makefile.am 2010-08-24 15:32:32 UTC (rev 123)
@@ -0,0 +1,24 @@
+# This file is a part of Aurelia.
+# Copyright (C) 2010 Valentin David
+# Copyright (C) 2010 University of Bergen
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+listsdir=$(aureliadir)/patterns
+lists_HEADERS= \
+ listable.hh \
+ list_concept.hh \
+ list.hh
+
+SUBDIRS=tests
Added: trunk/src/lists/list.hh
===================================================================
--- trunk/src/lists/list.hh (rev 0)
+++ trunk/src/lists/list.hh 2010-08-24 15:32:32 UTC (rev 123)
@@ -0,0 +1,99 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef __LIST_HH
+# define __LIST_HH
+
+# include <memory>
+
+namespace aurelia {
+
+ template <typename T, typename Tail>
+ struct ListCons {
+ private:
+ T h;
+ Tail t;
+
+ public:
+ enum { size = Tail::size+1 };
+
+ ListCons(T&& h, const Tail& t):
+ h(std::move(h)), t(t) {}
+
+ ListCons(T&& h, Tail&& t):
+ h(std::move(h)), t(std::move(t)) {}
+
+ ListCons(const T& h, Tail&& t):
+ h(h), t(std::move(t)) {}
+
+ ListCons(const T& h, const Tail& t):
+ h(h), t(t) {}
+
+ ListCons(const ListCons& other):
+ h(other.h), t(other.t) {}
+
+ ListCons(ListCons&& other):
+ h(std::move(other.h)), t(std::move(other.t)) {}
+
+ const T& head() const {
+ return h;
+ }
+
+ const Tail& tail() const {
+ return t;
+ }
+ };
+
+ template <typename H, typename T>
+ H head(const ListCons<H,T>& l) {
+ return l.head();
+ }
+
+
+ template <typename H, typename T>
+ T tail(const ListCons<H,T>& l) {
+ return l.tail();
+ }
+
+ template <typename H, typename T>
+ ListCons<H,T> cons(const H& h, const T& t) {
+ return ListCons<H,T>(h, t);
+ };
+
+ struct ListNil {
+ private:
+ public:
+ enum { size = 0 };
+ ListNil() {}
+ ListNil(const ListNil&) {}
+ ListNil(ListNil&&) {}
+ };
+
+ void head(ListNil) {
+ }
+
+ ListNil tail(ListNil) {
+ return ListNil();
+ }
+
+ ListNil cons() {
+ return ListNil();
+ }
+
+}
+
+#endif
Added: trunk/src/lists/list_concept.hh
===================================================================
--- trunk/src/lists/list_concept.hh (rev 0)
+++ trunk/src/lists/list_concept.hh 2010-08-24 15:32:32 UTC (rev 123)
@@ -0,0 +1,90 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef __LIST_CONCEPT_HH
+# define __LIST_CONCEPT_HH
+
+# include "list.hh"
+
+namespace aurelia {
+ template <typename T>
+ struct ListModel;
+
+ /*! \brief List Concept
+ * \ingroup Concepts
+ */
+ template <typename Model>
+ struct ListConcept: public Model {
+ typedef typename Model::Cons Cons;
+ typedef typename Model::Head Head;
+ typedef typename Model::Tail Tail;
+ enum { size = Model::size };
+#ifdef DOC_GEN
+ Head head(Cons);
+ Tail tail(Cons);
+ Cons cons(Head, Tail);
+#else
+ static_assert((ListModel<Tail>::Model::size+1 == size) || ((size == 0) && (ListModel<Tail>::Model::size == 0)),
+ "Wrong size");
+ static_assert(std::is_same<decltype(head(std::declval<Cons>())),
+ Head>::value,
+ "head(Cons) does not return the right type");
+ static_assert(std::is_same<decltype(tail(std::declval<Cons>())),
+ Tail>::value,
+ "tail(Cons) does not return the right type");
+ static_assert(std::is_same<decltype(cons(std::declval<Head>(),
+ std::declval<Tail>())),
+ Cons>::value,
+ "cons(Head,Teail) does not return the right type");
+ typedef void Check;
+#endif
+ };
+
+ /*! \ingroup Models
+ */
+ template <typename T>
+ struct ListModel {
+ typedef void NoModel;
+ };
+
+ /*! \ingroup Models
+ */
+ template <typename H, typename T>
+ struct ListModel<ListCons<H, T> > {
+ struct Model {
+ typedef ListCons<H, T> Cons;
+ typedef H Head;
+ typedef T Tail;
+ enum { size = ListCons<H, T>::size };
+ };
+ };
+
+ /*! \ingroup Models
+ */
+ template <>
+ struct ListModel<ListNil> {
+ struct Model {
+ typedef ListNil Cons;
+ typedef void Head;
+ typedef ListNil Tail;
+ enum { size = ListNil::size };
+ };
+ };
+
+}
+
+#endif
Added: trunk/src/lists/listable.hh
===================================================================
--- trunk/src/lists/listable.hh (rev 0)
+++ trunk/src/lists/listable.hh 2010-08-24 15:32:32 UTC (rev 123)
@@ -0,0 +1,57 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef __LISTABLE_HH
+# define __LISTABLE_HH
+
+# include "list_concept.hh"
+
+namespace aurelia {
+
+ template <typename Model>
+ struct ListableConcept: public Model {
+ public:
+ typedef typename Model::Type Type;
+ };
+
+ template <typename T>
+ struct ListableModel {
+ typedef void NoModel;
+ };
+
+}
+
+namespace {
+ using namespace aurelia;
+
+ template <typename H, typename T,
+ typename = typename ListableModel<H>::Model,
+ typename = typename ListModel<T>::Model>
+ ListCons<H,T> operator,(const T& t, const H& h) {
+ return ListCons<H,T>(h, t);
+ }
+
+ template <typename H, typename T,
+ typename = typename ListableModel<H>::Model,
+ typename = typename ListableModel<T>::Model>
+ ListCons<H,ListCons<T,ListNil> > operator,(const T& t, const H& h) {
+ return ListCons<H,ListCons<T,ListNil> >(h, ListCons<T,ListNil>(t, ListNil()));
+ }
+
+}
+
+#endif
Property changes on: trunk/src/lists/tests
___________________________________________________________________
Added: svn:ignore
+ .deps
Makefile.in
Makefile
test_listable
Added: trunk/src/lists/tests/Makefile.am
===================================================================
--- trunk/src/lists/tests/Makefile.am (rev 0)
+++ trunk/src/lists/tests/Makefile.am 2010-08-24 15:32:32 UTC (rev 123)
@@ -0,0 +1,27 @@
+# This file is a part of Aurelia.
+# Copyright (C) 2010 Valentin David
+# Copyright (C) 2010 University of Bergen
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AM_CPPFLAGS= \
+ -I$(top_srcdir)/src \
+ -I$(top_builddir)/src \
+ $(EXTRACPPFLAGS)
+
+check_PROGRAMS=test_listable
+
+test_listable_SOURCES=test_listable.cc
+
+TESTS=test_listable
Added: trunk/src/lists/tests/test_listable.cc
===================================================================
--- trunk/src/lists/tests/test_listable.cc (rev 0)
+++ trunk/src/lists/tests/test_listable.cc 2010-08-24 15:32:32 UTC (rev 123)
@@ -0,0 +1,88 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include <lists/listable.hh>
+
+struct Foo {
+private:
+ int value;
+public:
+ operator int&() {
+ return value;
+ }
+ operator const int&() const {
+ return value;
+ }
+
+ Foo(Foo&& other): value(std::move(other.value)) {}
+ Foo(const Foo& other): value(other.value) {}
+ Foo(int value): value(value) {}
+ Foo() {}
+};
+
+namespace aurelia {
+ template <>
+ struct ListableModel<Foo> {
+ struct Model {
+ typedef Foo Type;
+ };
+ };
+}
+
+struct Bar {
+private:
+ int value;
+public:
+ operator int&() {
+ return value;
+ }
+ operator const int&() const {
+ return value;
+ }
+
+ Bar(Bar&& other): value(std::move(other.value)) {}
+ Bar(const Bar& other): value(other.value) {}
+ Bar(int value): value(value) {}
+ Bar() {}
+};
+
+namespace aurelia {
+ template <>
+ struct ListableModel<Bar> {
+ struct Model {
+ typedef Bar Type;
+ };
+ };
+}
+
+static
+int p(const ListNil&) {
+ return 0;
+}
+
+template <typename T, typename M = typename aurelia::ListModel<T>::Model,
+ typename = typename std::enable_if<!std::is_same<void, typename M::Head>::value>::type>
+static
+int p(const T& l) {
+ typedef typename aurelia::ListConcept<M>::Check require;
+ return p(tail(l)) + head(l);
+}
+
+int main() {
+ using namespace aurelia;
+ return (p((Foo(1), Bar(2), Bar(3), Foo(4))) != 10);
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-08-24 15:30:07
|
Revision: 122
http://aurelia.svn.sourceforge.net/aurelia/?rev=122&view=rev
Author: valentindavid
Date: 2010-08-24 15:30:01 +0000 (Tue, 24 Aug 2010)
Log Message:
-----------
2010-08-24 Valentin David <val...@ii...>
Fix compilation with -DNDEBUG.
* src/llstack/frame.hh,
* src/memory/tests/test_pool.cc: Fix a warnings.
* src/streams/tests/test_buf_stream.cc: Disable NDEBUG.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/llstack/frame.hh
trunk/src/memory/tests/test_pool.cc
trunk/src/streams/tests/test_buf_stream.cc
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-08-24 14:35:40 UTC (rev 121)
+++ trunk/ChangeLog 2010-08-24 15:30:01 UTC (rev 122)
@@ -1,5 +1,14 @@
2010-08-24 Valentin David <val...@ii...>
+ Fix compilation with -DNDEBUG.
+
+ * src/llstack/frame.hh,
+ * src/memory/tests/test_pool.cc: Fix a warnings.
+
+ * src/streams/tests/test_buf_stream.cc: Disable NDEBUG.
+
+2010-08-24 Valentin David <val...@ii...>
+
* configure.ac: Fix docdeps config.status command.
2010-07-30 Valentin David <val...@ii...>
Modified: trunk/src/llstack/frame.hh
===================================================================
--- trunk/src/llstack/frame.hh 2010-08-24 14:35:40 UTC (rev 121)
+++ trunk/src/llstack/frame.hh 2010-08-24 15:30:01 UTC (rev 122)
@@ -32,7 +32,12 @@
template <typename T>
struct real_frame_helper: public real_frame {
- void* operator new(size_t t) {
+ void* operator new
+#ifdef NDEBUG
+ (size_t) {
+#else
+ (size_t t) {
+#endif
assert(t == sizeof(T));
return ChunkAlloc<T>::alloc();
}
Modified: trunk/src/memory/tests/test_pool.cc
===================================================================
--- trunk/src/memory/tests/test_pool.cc 2010-08-24 14:35:40 UTC (rev 121)
+++ trunk/src/memory/tests/test_pool.cc 2010-08-24 15:30:01 UTC (rev 122)
@@ -31,7 +31,12 @@
struct Foo {
#ifndef REF
- void *operator new(size_t s) {
+ void *operator new
+#ifdef NDEBUG
+ (size_t) {
+#else
+ (size_t s) {
+#endif
assert(sizeof(Foo) == s);
return ChunkAlloc<Foo, TS, SIZE>::alloc();
}
Modified: trunk/src/streams/tests/test_buf_stream.cc
===================================================================
--- trunk/src/streams/tests/test_buf_stream.cc 2010-08-24 14:35:40 UTC (rev 121)
+++ trunk/src/streams/tests/test_buf_stream.cc 2010-08-24 15:30:01 UTC (rev 122)
@@ -15,6 +15,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#ifdef NDEBUG
+# undef NDEBUG
+#endif
#include <streams/buf_stream.hh>
#include <iostream>
#include <fstream>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-08-24 14:35:49
|
Revision: 121
http://aurelia.svn.sourceforge.net/aurelia/?rev=121&view=rev
Author: valentindavid
Date: 2010-08-24 14:35:40 +0000 (Tue, 24 Aug 2010)
Log Message:
-----------
2010-08-24 Valentin David <val...@ii...>
* configure.ac: Fix docdeps config.status command.
Modified Paths:
--------------
trunk/ChangeLog
trunk/configure.ac
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-07-30 22:10:24 UTC (rev 120)
+++ trunk/ChangeLog 2010-08-24 14:35:40 UTC (rev 121)
@@ -1,3 +1,7 @@
+2010-08-24 Valentin David <val...@ii...>
+
+ * configure.ac: Fix docdeps config.status command.
+
2010-07-30 Valentin David <val...@ii...>
* src/terms/shared_object.hh:
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2010-07-30 22:10:24 UTC (rev 120)
+++ trunk/configure.ac 2010-08-24 14:35:40 UTC (rev 121)
@@ -144,10 +144,10 @@
PACKAGE_VERSION
VERSION])
-AC_CONFIG_COMMANDS([docdeps], [
- AS_MKDIR_P([doc/$DEPDIR])
- test -f doc/$DEPDIR/doc.deps || echo '# Dummy' >doc/$DEPDIR/doc.deps
-])
+AC_CONFIG_COMMANDS([docdeps], [dnl
+ AS_MKDIR_P([doc/$DOCDEPDIR])
+ test -f doc/$DOCDEPDIR/doc.deps || echo '# Dummy' >doc/$DOCDEPDIR/doc.deps
+], [DOCDEPDIR=$DEPDIR])
AC_CONFIG_FILES([
Makefile
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-07-30 22:10:31
|
Revision: 120
http://aurelia.svn.sourceforge.net/aurelia/?rev=120&view=rev
Author: valentindavid
Date: 2010-07-30 22:10:24 +0000 (Fri, 30 Jul 2010)
Log Message:
-----------
2010-07-30 Valentin David <val...@ii...>
* src/terms/shared_object.hh:
Fix a warning.
* src/parser_generator/Makefile.am:
Add rule for bootstrapping locally.
* src/parser_generator/parser_gen.cc:
Fix a warning. Add pragmas in generated code to disable some
warnings.
* src/strategies/traversals/one.hh:
Fix return.
* src/streams/buf_stream.hh:
Fix a return.
* configure.ac:
Add -W -Wall if default CXXFLAGS if accepted by the compiler.
* config/cxx.m4:
Add macros to check for warning compiler options.
* demos/06-patterns.cc:
Fix a bug in two patterns.
Modified Paths:
--------------
trunk/ChangeLog
trunk/config/cxx.m4
trunk/configure.ac
trunk/demos/06-patterns.cc
trunk/src/parser_generator/Makefile.am
trunk/src/parser_generator/parser_gen.cc
trunk/src/strategies/traversals/one.hh
trunk/src/streams/buf_stream.hh
trunk/src/terms/shared_object.hh
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-07-30 01:42:36 UTC (rev 119)
+++ trunk/ChangeLog 2010-07-30 22:10:24 UTC (rev 120)
@@ -1,6 +1,33 @@
2010-07-30 Valentin David <val...@ii...>
+ * src/terms/shared_object.hh:
+ Fix a warning.
+
+ * src/parser_generator/Makefile.am:
+ Add rule for bootstrapping locally.
+
+ * src/parser_generator/parser_gen.cc:
+ Fix a warning. Add pragmas in generated code to disable some
+ warnings.
+
+ * src/strategies/traversals/one.hh:
+ Fix return.
+
+ * src/streams/buf_stream.hh:
+ Fix a return.
+
* configure.ac:
+ Add -W -Wall if default CXXFLAGS if accepted by the compiler.
+
+ * config/cxx.m4:
+ Add macros to check for warning compiler options.
+
+ * demos/06-patterns.cc:
+ Fix a bug in two patterns.
+
+2010-07-30 Valentin David <val...@ii...>
+
+ * configure.ac:
Check for parser_gen on bootstrap. Remove useless checks.
* src/parser_generator/Syntax.def,
Modified: trunk/config/cxx.m4
===================================================================
--- trunk/config/cxx.m4 2010-07-30 01:42:36 UTC (rev 119)
+++ trunk/config/cxx.m4 2010-07-30 22:10:24 UTC (rev 120)
@@ -138,3 +138,23 @@
CPPFLAGS="$EXTRACPPFLAGS $oldCPPFLAGS"
AC_LANG_POP
])
+
+AC_DEFUN([CXX_WALL],[
+if ! test "$ac_test_CXXFLAGS" = set; then
+ AC_LANG_PUSH([C++])
+ oldCXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -W -Wall"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[],[CXXFLAGS="$oldCXXFLAGS"])
+ AC_LANG_POP
+fi
+])
+
+AC_DEFUN([CXX_WERROR],[
+if ! test "$ac_test_CXXFLAGS" = set; then
+ AC_LANG_PUSH([C++])
+ oldCXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -Werror"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[],[CXXFLAGS="$oldCXXFLAGS"])
+ AC_LANG_POP
+fi
+])
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2010-07-30 01:42:36 UTC (rev 119)
+++ trunk/configure.ac 2010-07-30 22:10:24 UTC (rev 120)
@@ -32,6 +32,12 @@
AC_LANG_CPLUSPLUS
AC_PROG_CXX([g++ icpc])
+if ! test "$ac_test_CXXFLAGS" = set; then
+ CXXFLAGS=`echo "$CXXFLAGS" | sed "s/-O2/-O3/g"`
+fi
+CXX_WALL
+dnl CXX_WERROR
+
AC_PROG_INSTALL
AC_PROG_LIBTOOL
Modified: trunk/demos/06-patterns.cc
===================================================================
--- trunk/demos/06-patterns.cc 2010-07-30 01:42:36 UTC (rev 119)
+++ trunk/demos/06-patterns.cc 2010-07-30 22:10:24 UTC (rev 120)
@@ -37,7 +37,8 @@
V X;
try {
- c[X, b] = t;
+ V vb = T(b);
+ c[X, vb] = t;
std::cout << *X << std::endl;
}
catch (Failure) {
@@ -45,7 +46,8 @@
}
try {
- c[X, b] = c[b, b];
+ V vb = T(b);
+ c[X, vb] = c[b, b];
std::cout << *X << std::endl;
}
catch (Failure) {
Modified: trunk/src/parser_generator/Makefile.am
===================================================================
--- trunk/src/parser_generator/Makefile.am 2010-07-30 01:42:36 UTC (rev 119)
+++ trunk/src/parser_generator/Makefile.am 2010-07-30 22:10:24 UTC (rev 120)
@@ -26,6 +26,15 @@
if BOOTSTRAP
+use-local-generator: parser_gen
+use-local-generator: syntax.csf
+ if ./parser_gen <$< >syntax.hh.tmp; then \
+ mv -f syntax.hh.tmp syntax.hh; \
+ else \
+ rm -f syntax.hh.tmp; \
+ exit 1; \
+ fi
+
syntax.hh: syntax.csf
if $(PARSER_GEN) <$< >syntax.hh.tmp; then \
mv -f syntax.hh.tmp syntax.hh; \
Modified: trunk/src/parser_generator/parser_gen.cc
===================================================================
--- trunk/src/parser_generator/parser_gen.cc 2010-07-30 01:42:36 UTC (rev 119)
+++ trunk/src/parser_generator/parser_gen.cc 2010-07-30 22:10:24 UTC (rev 120)
@@ -52,7 +52,7 @@
int l = 0;
int k = 0;
- for (int i = 0; i < N; ++i) {
+ for (unsigned i = 0; i < N; ++i) {
if (k == 8) {
s << l << ",";
k = 0;
@@ -253,6 +253,7 @@
Some[AttrRule[params, attrcode]] = *attr;
std::cout << " struct res {" << std::endl;
+ std::cout << "#pragma GCC diagnostic ignored \"-Wunused-parameter\"" << std::endl;
std::cout << " void operator()(R_t& R, const frame& f, stream& s, const node& cu) const {" << std::endl;
std::cout << ((get_cons_name < undouble_quote)(*attrcode)) << std::endl;
std::cout << " parse_symbol<" << toparse
@@ -303,7 +304,9 @@
Some[AttrRule[params, attrcode]] = *attr;
std::cout << " struct res {" << std::endl;
+ std::cout << "#pragma GCC diagnostic ignored \"-Wunused-parameter\"" << std::endl;
std::cout << " void operator()(R_t& R, const frame& f, stream& s, const node& cu) const {" << std::endl;
+
std::cout << ((get_cons_name < undouble_quote)(*attrcode)) << std::endl;
std::cout << " parse_string<str_"
<< i << ", branch<" << nt_name
@@ -376,7 +379,9 @@
Some[AttrRule[params, attrcode]] = *attr;
std::cout << " struct res {" << std::endl;
+ std::cout << "#pragma GCC diagnostic ignored \"-Wunused-parameter\"" << std::endl;
std::cout << " void operator()(R_t& R, const frame& f, stream& s, const node& cu) const {" << std::endl;
+
std::cout << ((get_cons_name < undouble_quote)(*attrcode)) << std::endl;
std::cout << " cu.pop(R, ret, s);" << std::endl;
std::cout << " }" << std::endl;
Modified: trunk/src/strategies/traversals/one.hh
===================================================================
--- trunk/src/strategies/traversals/one.hh 2010-07-30 01:42:36 UTC (rev 119)
+++ trunk/src/strategies/traversals/one.hh 2010-07-30 22:10:24 UTC (rev 120)
@@ -55,8 +55,8 @@
return T(term.constructor(), list);
} catch (Failure) {
}
- throw Failure();
}
+ throw Failure();
}
else
throw Failure();
Modified: trunk/src/streams/buf_stream.hh
===================================================================
--- trunk/src/streams/buf_stream.hh 2010-07-30 01:42:36 UTC (rev 119)
+++ trunk/src/streams/buf_stream.hh 2010-07-30 22:10:24 UTC (rev 120)
@@ -254,6 +254,7 @@
unsigned hash = (unsigned)pos;
hash = (hash << 11) | (hash >> 21);
hash ^= s->hash();
+ return hash;
}
bool buf_stream_iterator::operator==(const buf_stream_iterator& other) const {
Modified: trunk/src/terms/shared_object.hh
===================================================================
--- trunk/src/terms/shared_object.hh 2010-07-30 01:42:36 UTC (rev 119)
+++ trunk/src/terms/shared_object.hh 2010-07-30 22:10:24 UTC (rev 120)
@@ -247,7 +247,7 @@
}
public:
- SharedObject(const NoBuild& n): o(NULL) {}
+ SharedObject(const NoBuild&): o(NULL) {}
SharedObject(const SharedObject& other): o(other.o) {
if (o != NULL) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-07-30 01:42:42
|
Revision: 119
http://aurelia.svn.sourceforge.net/aurelia/?rev=119&view=rev
Author: valentindavid
Date: 2010-07-30 01:42:36 +0000 (Fri, 30 Jul 2010)
Log Message:
-----------
2010-07-30 Valentin David <val...@ii...>
* configure.ac:
Check for parser_gen on bootstrap. Remove useless checks.
* src/parser_generator/Syntax.def,
* src/parser_generator/bootstrap.cc:
Remove.
* src/parser_generator/Makefile.am:
Use installed Aurelia to bootstrap.
Modified Paths:
--------------
trunk/ChangeLog
trunk/configure.ac
trunk/src/parser_generator/Makefile.am
Removed Paths:
-------------
trunk/src/parser_generator/Syntax.def
trunk/src/parser_generator/bootstrap.cc
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-07-30 00:51:24 UTC (rev 118)
+++ trunk/ChangeLog 2010-07-30 01:42:36 UTC (rev 119)
@@ -1,5 +1,17 @@
2010-07-30 Valentin David <val...@ii...>
+ * configure.ac:
+ Check for parser_gen on bootstrap. Remove useless checks.
+
+ * src/parser_generator/Syntax.def,
+ * src/parser_generator/bootstrap.cc:
+ Remove.
+
+ * src/parser_generator/Makefile.am:
+ Use installed Aurelia to bootstrap.
+
+2010-07-30 Valentin David <val...@ii...>
+
* src/parser_generator/parser_gen.cc:
Jump on next label in last rule.
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2010-07-30 00:51:24 UTC (rev 118)
+++ trunk/configure.ac 2010-07-30 01:42:36 UTC (rev 119)
@@ -69,26 +69,16 @@
AC_SUBST([EXTRACPPFLAGS])
AC_ARG_ENABLE([bootstrap],[AS_HELP_STRING([--enable-bootstrap],dnl
- [bootstrap when checked out from SVN. Needs sdf2 and aterm.])],[dnl
- AC_ARG_VAR([SGLR], [Scanner-less GLR parser])
- AC_ARG_VAR([SDF2TABLE], [SGLR parse table generator])
- AC_ARG_VAR([IMPLODEASFIX], [implode-asfix Stratego tool])
- AC_ARG_VAR([PKGCONFIG], [pkg-config tool])
+ [bootstrap when checked out from SVN.])],[dnl
+ AC_ARG_VAR([PARSER_GEN], [Aurelia parser generator])
AC_ARG_VAR([DOXYGEN], [Doxygen documentation generation tool])
AC_ARG_VAR([SVN], [svn command])
- AC_CHECK_PROGS([PKGCONFIG], [pkg-config], [dnl
- AC_MSG_ERROR([pkg-config is mssing!])
- ])
AC_CHECK_PROGS([SVN], [svn], [dnl
AC_MSG_ERROR([svn is mssing!])
])
- AC_CHECK_PROGS([SGLR], [sglr], [dnl
- AC_MSG_ERROR([sglr not found. Please set variable SGLR.])])
- AC_CHECK_PROGS([SDF2TABLE], [sdf2table], [dnl
- AC_MSG_ERROR([sdf2table not found. Please set variable SDF2TABLE.])])
- AC_CHECK_PROGS([IMPLODEASFIX], [implode-asfix], [dnl
- AC_MSG_ERROR([implode-asfix not found. Please set variable IMPLODEASFIX.])])
+ AC_CHECK_PROGS([PARSER_GEN], [parser_gen], [dnl
+ AC_MSG_ERROR([parser_gen not found. Please set variable PARSER_GEN.])])
AC_CHECK_PROGS([DOXYGEN], [doxygen], [dnl
AC_MSG_ERROR([doxygen not found. Please set variable DOXYGEN.])])
BOOTSTRAP=true
Modified: trunk/src/parser_generator/Makefile.am
===================================================================
--- trunk/src/parser_generator/Makefile.am 2010-07-30 00:51:24 UTC (rev 118)
+++ trunk/src/parser_generator/Makefile.am 2010-07-30 01:42:36 UTC (rev 119)
@@ -18,24 +18,25 @@
parser_gen_bootstrap_CPPFLAGS=-I$(srcdir)/.. $(EXTRACPPFLAGS)
parser_gen_CPPFLAGS=-I$(srcdir)/.. $(EXTRACPPFLAGS)
-bin_PROGRAMS=parser_gen_bootstrap parser_gen
+bin_PROGRAMS=parser_gen
parser_gen_SOURCES=parser_gen_main.cc parser_gen.cc syntax.cc
-parser_gen_bootstrap_SOURCES=bootstrap.cc parser_gen.cc
-EXTRA_DIST=syntax.tree Syntax.def syntax.hh syntax.csf force-deps.mk
+EXTRA_DIST=syntax.hh syntax.csf force-deps.mk
CLEANFILES=
if BOOTSTRAP
-syntax.tree: syntax.csf Syntax.tbl
- $(SGLR) -2 -fi -p Syntax.tbl -i $< | \
- $(IMPLODEASFIX) -b -o syntax.tree
-Syntax.tbl: Syntax.def
- $(SDF2TABLE) -i $< -m Syntax -o Syntax.tbl
+syntax.hh: syntax.csf
+ if $(PARSER_GEN) <$< >syntax.hh.tmp; then \
+ mv -f syntax.hh.tmp syntax.hh; \
+ else \
+ rm -f syntax.hh.tmp; \
+ exit 1; \
+ fi
-syntax.hh: parser_gen_bootstrap syntax.csf
+syntax.hh: syntax.csf
-CLEANFILES+=Syntax.tbl syntax.tree syntax.hh
+CLEANFILES+=syntax.hh
nodist_parser_gen_SOURCES=syntax.hh
@@ -47,12 +48,4 @@
endif
-syntax.hh: syntax.tree
- if ./parser_gen_bootstrap <$< >syntax.hh.tmp; then \
- mv -f syntax.hh.tmp syntax.hh; \
- else \
- rm -f syntax.hh.tmp; \
- exit 1; \
- fi
-
SUBDIRS=tests
Deleted: trunk/src/parser_generator/Syntax.def
===================================================================
--- trunk/src/parser_generator/Syntax.def 2010-07-30 00:51:24 UTC (rev 118)
+++ trunk/src/parser_generator/Syntax.def 2010-07-30 01:42:36 UTC (rev 119)
@@ -1,107 +0,0 @@
-%% This file is a part of Aurelia.
-%% Copyright (C) 2010 Valentin David
-%% Copyright (C) 2010 University of Bergen
-%%
-%% This program is free software: you can redistribute it and/or modify
-%% it under the terms of the GNU General Public License as published by
-%% the Free Software Foundation, either version 3 of the License, or
-%% (at your option) any later version.
-%%
-%% This program is distributed in the hope that it will be useful,
-%% but WITHOUT ANY WARRANTY; without even the implied warranty of
-%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-%% GNU General Public License for more details.
-%%
-%% You should have received a copy of the GNU General Public License
-%% along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-definition
-module Syntax
-exports
-context-free start-symbols
- Syntax
-sorts
- Line Argument
- CxxTypes CxxUType CxxType SpecialChar Char RangeOrChar
- StringChar ListOfChains Rule Chain ChainElt AttrRule Range RangeOrChars
- ClassChar SymbolChar Symbol String ParameterList RetType CxxCode
- Arguments ArgumentList CxxExpression CxxIdentifier CxxChar Parameter
- TemplateArguments Parameters Syntax LocalParameters AttrChainElt
-lexical syntax
- [\ \n\r\t] -> LAYOUT
- "//" Line -> LAYOUT
- (~[\n])* [\n] -> Line
-
- [rnt\\\"\-\]] -> SpecialChar
- ~[\\\-\^\]] -> Char
- "\\" SpecialChar -> Char
- Char "-" Char -> Range
- Char -> RangeOrChar
- Range -> RangeOrChar
- RangeOrChar+ -> RangeOrChars
- "[" RangeOrChars "]" -> ClassChar
- "[" "^" RangeOrChars "]" -> ClassChar
-
- [A-Za-z\*\?\+\-\_] -> SymbolChar
- SymbolChar+ -> Symbol
-
- ~[\\\"] -> StringChar
- "\\" SpecialChar -> StringChar
- "\"" StringChar* "\"" -> String
- [A-Za-z\_][A-Za-z\_0-9]* -> CxxIdentifier
-
-context-free syntax
-
- Rule* -> Syntax
-
- Symbol ParameterList RetType "::=" ListOfChains -> Rule {cons("Rule")}
-
- "(" Parameters ")" -> ParameterList {cons("Params")}
- -> ParameterList {cons("NoParam")}
-
- {Chain "|"}+ -> ListOfChains
-
- ":" CxxType -> RetType {cons("RetType")}
- -> RetType {cons("Void")}
-
- AttrChainElt* AttrRule? -> Chain {cons("Chain")}
-
-syntax
- <LocalParameters?-CF> <LAYOUT?-CF> "$" <CxxCode-LEX> "$" -> <AttrRule-CF> {cons("AttrRule")}
-
-context-free syntax
- "{" Parameters "}" -> LocalParameters {cons("LocalParameters")}
-
- AttrRule? ChainElt -> AttrChainElt {cons("AttrChainElt")}
- String -> ChainElt {cons("String")}
- ClassChar -> ChainElt {cons("Class")}
- Symbol ArgumentList -> ChainElt {cons("Symbol")}
-
- "(" Arguments ")" -> ArgumentList {cons("Args")}
- -> ArgumentList {cons("NoArg")}
-
- {Argument ","}+ -> Arguments
- CxxExpression -> Argument
- {CxxIdentifier "."}+ -> CxxExpression
-
-lexical syntax
- CxxChar* -> CxxCode
- ~[\$] -> CxxChar
-
-context-free syntax
-
- {Parameter ","}+ -> Parameters
- CxxType CxxIdentifier -> Parameter {cons("Parameter")}
- CxxIdentifier TemplateArguments -> CxxUType {cons("CxxUType")}
- {CxxUType "::"}+ -> CxxType
-
- "<" CxxTypes ">" -> TemplateArguments {cons("TArgs")}
- -> TemplateArguments {cons("NoTArg")}
-
- {CxxType ","}+ -> CxxTypes
-
-context-free restrictions
- CxxIdentifier -/- [a-zA-Z0-9\_]
- Symbol -/- [A-Za-z\*\?\+\-\_]
-
- LAYOUT? -/- [\ \n\r\t] | [\/].[\/]
Deleted: trunk/src/parser_generator/bootstrap.cc
===================================================================
--- trunk/src/parser_generator/bootstrap.cc 2010-07-30 00:51:24 UTC (rev 118)
+++ trunk/src/parser_generator/bootstrap.cc 2010-07-30 01:42:36 UTC (rev 119)
@@ -1,39 +0,0 @@
-// This file is a part of Aurelia.
-// Copyright (C) 2010 Valentin David
-// Copyright (C) 2010 University of Bergen
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include "terms/term.hh"
-#include "terms/baf_read.hh"
-
-using namespace aurelia;
-struct Main {};
-typedef Term<Main> T;
-
-void parser_generator(T input);
-
-int main(){
- try {
- T input = readBaf(Main(), std::cin);
-
- parser_generator(input);
- } catch (Failure) {
- std::cerr << "Rewriting failed." << std::endl;
-
- return 1;
- }
-
- return 0;
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-07-30 00:51:30
|
Revision: 118
http://aurelia.svn.sourceforge.net/aurelia/?rev=118&view=rev
Author: valentindavid
Date: 2010-07-30 00:51:24 +0000 (Fri, 30 Jul 2010)
Log Message:
-----------
Fix ChangeLog
Modified Paths:
--------------
trunk/ChangeLog
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-07-30 00:50:36 UTC (rev 117)
+++ trunk/ChangeLog 2010-07-30 00:51:24 UTC (rev 118)
@@ -3,6 +3,9 @@
* src/parser_generator/parser_gen.cc:
Jump on next label in last rule.
+ * src/parser_generator/Makefile.am:
+ Fix CLEANFILES.
+
2010-07-30 Valentin David <val...@ii...>
* src/llstack/queue.hh:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-07-30 00:50:42
|
Revision: 117
http://aurelia.svn.sourceforge.net/aurelia/?rev=117&view=rev
Author: valentindavid
Date: 2010-07-30 00:50:36 +0000 (Fri, 30 Jul 2010)
Log Message:
-----------
2010-07-30 Valentin David <val...@ii...>
* src/parser_generator/parser_gen.cc:
Jump on next label in last rule.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/parser_generator/Makefile.am
trunk/src/parser_generator/parser_gen.cc
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-07-30 00:35:20 UTC (rev 116)
+++ trunk/ChangeLog 2010-07-30 00:50:36 UTC (rev 117)
@@ -1,5 +1,10 @@
2010-07-30 Valentin David <val...@ii...>
+ * src/parser_generator/parser_gen.cc:
+ Jump on next label in last rule.
+
+2010-07-30 Valentin David <val...@ii...>
+
* src/llstack/queue.hh:
Disable garbage collection.
Modified: trunk/src/parser_generator/Makefile.am
===================================================================
--- trunk/src/parser_generator/Makefile.am 2010-07-30 00:35:20 UTC (rev 116)
+++ trunk/src/parser_generator/Makefile.am 2010-07-30 00:50:36 UTC (rev 117)
@@ -35,7 +35,7 @@
syntax.hh: parser_gen_bootstrap syntax.csf
-CLEANFILES+=Syntax.tbl syntax.tree
+CLEANFILES+=Syntax.tbl syntax.tree syntax.hh
nodist_parser_gen_SOURCES=syntax.hh
Modified: trunk/src/parser_generator/parser_gen.cc
===================================================================
--- trunk/src/parser_generator/parser_gen.cc 2010-07-30 00:35:20 UTC (rev 116)
+++ trunk/src/parser_generator/parser_gen.cc 2010-07-30 00:50:36 UTC (rev 117)
@@ -913,7 +913,14 @@
<<", 0>::res(), f, cu, s);" << std::endl;
++i;
return t;
- })(*l);
+ })((*l)[1]);
+ std::cout << " if (test(s, NT_"<<nt_name<<", "<<nt_name<<"_"
+ <<i<<"_0)) {" << std::endl;
+ std::cout << " branch<"<<nt_name<<", "<<i<<", 0>::res n;"
+ << std::endl;
+ std::cout << " return n(R, f, s, cu);" << std::endl;
+ std::cout << " }" << std::endl;
+
std::cout << " } else {" << std::endl;
i = 0;
map([&i, nt_name](const T& t) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-07-30 00:35:26
|
Revision: 116
http://aurelia.svn.sourceforge.net/aurelia/?rev=116&view=rev
Author: valentindavid
Date: 2010-07-30 00:35:20 +0000 (Fri, 30 Jul 2010)
Log Message:
-----------
2010-07-30 Valentin David <val...@ii...>
* src/parser_generator/force-deps.mk: Fix dependencies.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/parser_generator/force-deps.mk
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-07-30 00:31:37 UTC (rev 115)
+++ trunk/ChangeLog 2010-07-30 00:35:20 UTC (rev 116)
@@ -17,6 +17,8 @@
* src/parser_generator/syntax.cc:
Remove main functions.
+ * src/parser_generator/force-deps.mk: Fix dependencies.
+
2010-07-30 Valentin David <val...@ii...>
* src/llstack/node.hpp:
Modified: trunk/src/parser_generator/force-deps.mk
===================================================================
--- trunk/src/parser_generator/force-deps.mk 2010-07-30 00:31:37 UTC (rev 115)
+++ trunk/src/parser_generator/force-deps.mk 2010-07-30 00:35:20 UTC (rev 116)
@@ -15,4 +15,4 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-syntax-syntax.o: syntax.hh
+parser_gen-syntax.o: syntax.hh
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-07-30 00:31:44
|
Revision: 115
http://aurelia.svn.sourceforge.net/aurelia/?rev=115&view=rev
Author: valentindavid
Date: 2010-07-30 00:31:37 +0000 (Fri, 30 Jul 2010)
Log Message:
-----------
2010-07-30 Valentin David <val...@ii...>
* src/llstack/queue.hh:
Disable garbage collection.
* src/parser_generator/bootstrap.cc,
* src/parser_generator/parser_gen_main.cc:
New.
* src/parser_generator/tests/Makefile.am:
Use the new parser.
* src/parser_generator/Makefile.am:
Make two parser generators: one for BAF terms, one in concrete syntax.
* src/parser_generator/parser_gen.cc,
* src/parser_generator/syntax.cc:
Remove main functions.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/llstack/queue.hh
trunk/src/parser_generator/Makefile.am
trunk/src/parser_generator/parser_gen.cc
trunk/src/parser_generator/syntax.cc
trunk/src/parser_generator/tests/Makefile.am
Added Paths:
-----------
trunk/src/parser_generator/bootstrap.cc
trunk/src/parser_generator/parser_gen_main.cc
Property Changed:
----------------
trunk/src/parser_generator/
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-07-29 23:51:31 UTC (rev 114)
+++ trunk/ChangeLog 2010-07-30 00:31:37 UTC (rev 115)
@@ -1,5 +1,24 @@
2010-07-30 Valentin David <val...@ii...>
+ * src/llstack/queue.hh:
+ Disable garbage collection.
+
+ * src/parser_generator/bootstrap.cc,
+ * src/parser_generator/parser_gen_main.cc:
+ New.
+
+ * src/parser_generator/tests/Makefile.am:
+ Use the new parser.
+
+ * src/parser_generator/Makefile.am:
+ Make two parser generators: one for BAF terms, one in concrete syntax.
+
+ * src/parser_generator/parser_gen.cc,
+ * src/parser_generator/syntax.cc:
+ Remove main functions.
+
+2010-07-30 Valentin David <val...@ii...>
+
* src/llstack/node.hpp:
Call directly the return address when only one is available.
Modified: trunk/src/llstack/queue.hh
===================================================================
--- trunk/src/llstack/queue.hh 2010-07-29 23:51:31 UTC (rev 114)
+++ trunk/src/llstack/queue.hh 2010-07-30 00:31:37 UTC (rev 115)
@@ -100,7 +100,7 @@
stream s = (*i).first;
m.erase(i);
node::drop(s);
- collect_nodes();
+ //collect_nodes();
i = m.begin();
if (i == m.end())
throw Eof();
Property changes on: trunk/src/parser_generator
___________________________________________________________________
Modified: svn:ignore
- Makefile
Makefile.in
.deps
parser_gen
syntax.hh
syntax.tree
Syntax.tbl
syntax
+ Makefile
Makefile.in
.deps
parser_gen
syntax.hh
syntax.tree
Syntax.tbl
syntax
parser_gen_bootstrap
Modified: trunk/src/parser_generator/Makefile.am
===================================================================
--- trunk/src/parser_generator/Makefile.am 2010-07-29 23:51:31 UTC (rev 114)
+++ trunk/src/parser_generator/Makefile.am 2010-07-30 00:31:37 UTC (rev 115)
@@ -15,16 +15,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+parser_gen_bootstrap_CPPFLAGS=-I$(srcdir)/.. $(EXTRACPPFLAGS)
parser_gen_CPPFLAGS=-I$(srcdir)/.. $(EXTRACPPFLAGS)
-syntax_CPPFLAGS=-I$(srcdir)/.. $(EXTRACPPFLAGS) -DSRCDIR=\"$(srcdir)\"
-bin_PROGRAMS=parser_gen syntax
-parser_gen_SOURCES=parser_gen.cc
+bin_PROGRAMS=parser_gen_bootstrap parser_gen
+parser_gen_SOURCES=parser_gen_main.cc parser_gen.cc syntax.cc
+parser_gen_bootstrap_SOURCES=bootstrap.cc parser_gen.cc
-TESTS=syntax
-
-syntax_SOURCES=syntax.cc
-
EXTRA_DIST=syntax.tree Syntax.def syntax.hh syntax.csf force-deps.mk
CLEANFILES=
@@ -36,22 +33,22 @@
Syntax.tbl: Syntax.def
$(SDF2TABLE) -i $< -m Syntax -o Syntax.tbl
-syntax.hh: parser_gen syntax.csf
+syntax.hh: parser_gen_bootstrap syntax.csf
CLEANFILES+=Syntax.tbl syntax.tree
-nodist_syntax_SOURCES=syntax.hh
+nodist_parser_gen_SOURCES=syntax.hh
-include $(srcdir)/force-deps.mk
else
-syntax_SOURCES+=syntax.hh
+parser_gen_SOURCES+=syntax.hh
endif
syntax.hh: syntax.tree
- if ./parser_gen <$< >syntax.hh.tmp; then \
+ if ./parser_gen_bootstrap <$< >syntax.hh.tmp; then \
mv -f syntax.hh.tmp syntax.hh; \
else \
rm -f syntax.hh.tmp; \
@@ -59,7 +56,3 @@
fi
SUBDIRS=tests
-
-if HAVE_PTHREAD_H
-AM_LDFLAGS=-lpthread
-endif
Added: trunk/src/parser_generator/bootstrap.cc
===================================================================
--- trunk/src/parser_generator/bootstrap.cc (rev 0)
+++ trunk/src/parser_generator/bootstrap.cc 2010-07-30 00:31:37 UTC (rev 115)
@@ -0,0 +1,39 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "terms/term.hh"
+#include "terms/baf_read.hh"
+
+using namespace aurelia;
+struct Main {};
+typedef Term<Main> T;
+
+void parser_generator(T input);
+
+int main(){
+ try {
+ T input = readBaf(Main(), std::cin);
+
+ parser_generator(input);
+ } catch (Failure) {
+ std::cerr << "Rewriting failed." << std::endl;
+
+ return 1;
+ }
+
+ return 0;
+}
Modified: trunk/src/parser_generator/parser_gen.cc
===================================================================
--- trunk/src/parser_generator/parser_gen.cc 2010-07-29 23:51:31 UTC (rev 114)
+++ trunk/src/parser_generator/parser_gen.cc 2010-07-30 00:31:37 UTC (rev 115)
@@ -17,11 +17,11 @@
#include <iomanip>
#include <bitset>
+#include <sstream>
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <list>
-#include "terms/baf_read.hh"
#include "terms/term.hh"
#include "strategies/strategies.hh"
#include "strategies/generic/debug.hh"
@@ -1185,17 +1185,13 @@
PrintLabels(): super(PrintLabelsKernel()) {}
} print_labels;
-int main()
+void parser_generator(T input)
{
- try {
- T input = readBaf(Main(), std::cin);
-
BuildEmpty build_empty;
repeat(map_one(build_empty))(input);
static C Rule("Rule", 4);
static V NoParam = T(C("NoParam"));
- //static V Void = T(C("Void"));
V l, nt, return_type;
@@ -1272,11 +1268,4 @@
)(input);
map(print_rule(&build_first, &build_empty, &build_follow))(input);
- } catch (Failure) {
- std::cerr << "Rewriting failed." << std::endl;
-
- return 1;
- }
-
- return 0;
}
Added: trunk/src/parser_generator/parser_gen_main.cc
===================================================================
--- trunk/src/parser_generator/parser_gen_main.cc (rev 0)
+++ trunk/src/parser_generator/parser_gen_main.cc 2010-07-30 00:31:37 UTC (rev 115)
@@ -0,0 +1,38 @@
+// This file is a part of Aurelia.
+// Copyright (C) 2010 Valentin David
+// Copyright (C) 2010 University of Bergen
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include <fstream>
+#include "terms/term.hh"
+
+using namespace aurelia;
+struct Main {};
+typedef Term<Main> T;
+
+void parser_generator(T input);
+T parse_syntax(std::istream& in);
+
+int main(){
+ try {
+ parser_generator(parse_syntax(std::cin));
+ } catch (Failure) {
+ std::cerr << "Rewriting failed." << std::endl;
+
+ return 1;
+ }
+
+ return 0;
+}
Modified: trunk/src/parser_generator/syntax.cc
===================================================================
--- trunk/src/parser_generator/syntax.cc 2010-07-29 23:51:31 UTC (rev 114)
+++ trunk/src/parser_generator/syntax.cc 2010-07-30 00:31:37 UTC (rev 115)
@@ -93,14 +93,14 @@
return found;
}
-int main() {
- std::ifstream in(SRCDIR"/syntax.csf");
+T parse_syntax(std::istream& in) {
buf_stream bs(in);
stream s = bs.begin();
if (main_loop(s, bs.end())) {
std::cerr << result << std::endl;
+ T ret = result;
result.~T();
- return 0;
+ return ret;
}
- return 1;
+ throw Failure();
}
Modified: trunk/src/parser_generator/tests/Makefile.am
===================================================================
--- trunk/src/parser_generator/tests/Makefile.am 2010-07-29 23:51:31 UTC (rev 114)
+++ trunk/src/parser_generator/tests/Makefile.am 2010-07-30 00:31:37 UTC (rev 115)
@@ -23,24 +23,18 @@
gamma_2_SOURCES=gamma_2.cc
nodist_gamma_2_SOURCES=gamma_2.hh
-EXTRA_DIST=gamma_2.csf gamma_2.tree force-deps.mk input.txt
+EXTRA_DIST=gamma_2.csf force-deps.mk input.txt
CLEANFILES=gamma_2.hh
SUFFIXES=
-if BOOTSTRAP
-SUFFIXES+= .csf
-.csf.tree:
- $(SGLR) -2 -fi -p ../Syntax.tbl -i $< | \
- $(IMPLODEASFIX) -b -o $@
-endif
-
-include $(srcdir)/force-deps.mk
-SUFFIXES+=.tree
+SUFFIXES+=.csf
-.tree.hh:
+.csf.hh:
if ../parser_gen <$< >$@.tmp; then \
mv -f $@.tmp $@; \
else \
rm -f $@.tmp; \
+ exit 1; \
fi
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-07-29 23:51:37
|
Revision: 114
http://aurelia.svn.sourceforge.net/aurelia/?rev=114&view=rev
Author: valentindavid
Date: 2010-07-29 23:51:31 +0000 (Thu, 29 Jul 2010)
Log Message:
-----------
2010-07-30 Valentin David <val...@ii...>
* src/llstack/node.hpp:
Call directly the return address when only one is available.
* src/llstack/node.hh:
Update declarations.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/llstack/node.hh
trunk/src/llstack/node.hpp
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-07-29 23:35:13 UTC (rev 113)
+++ trunk/ChangeLog 2010-07-29 23:51:31 UTC (rev 114)
@@ -1,5 +1,13 @@
2010-07-30 Valentin David <val...@ii...>
+ * src/llstack/node.hpp:
+ Call directly the return address when only one is available.
+
+ * src/llstack/node.hh:
+ Update declarations.
+
+2010-07-30 Valentin David <val...@ii...>
+
* src/llstack/node.hh, src/llstack/node.hpp:
Do not create frame on void return.
Modified: trunk/src/llstack/node.hh
===================================================================
--- trunk/src/llstack/node.hh 2010-07-29 23:35:13 UTC (rev 113)
+++ trunk/src/llstack/node.hh 2010-07-29 23:51:31 UTC (rev 114)
@@ -275,12 +275,12 @@
}
template <typename Ret>
- void pop(R_t& queue, const Ret& ret_value, const stream& j);
+ void pop(R_t& queue, const Ret& ret_value, stream& j);
- void pop(R_t& queue, const VoidReturn&, const stream& j);
+ void pop(R_t& queue, const VoidReturn&, stream& j);
template <typename Ret>
- void pop(R_t& queue, const Ret& ret_value, const stream& j) const {
+ void pop(R_t& queue, const Ret& ret_value, stream& j) const {
node(*this).pop(queue, ret_value, j);
}
};
Modified: trunk/src/llstack/node.hpp
===================================================================
--- trunk/src/llstack/node.hpp 2010-07-29 23:35:13 UTC (rev 113)
+++ trunk/src/llstack/node.hpp 2010-07-29 23:51:31 UTC (rev 114)
@@ -65,8 +65,14 @@
return node(l, empty_frame(), s.get_pos());
}
-void node::pop(R_t& queue, const VoidReturn&, const stream& j) {
- this->P()[j].push_front(get().get_frame());
+void node::pop(R_t& queue, const VoidReturn&, stream& j) {
+ switch (this->parents().size()) {
+ case 0:
+ return ;
+ case 1:
+ this->get_label().call(queue, get().get_frame(), j, *(this->parents().begin()));
+ return ;
+ }
for (node_core::node_set_t::iterator i = this->parents().begin();
i != this->parents().end(); ++i) {
queue.add(this->get_label(), get().get_frame(), *i, j);
@@ -74,9 +80,16 @@
}
template <typename Ret>
-void node::pop(R_t& queue, const Ret& ret_val, const stream& j) {
+void node::pop(R_t& queue, const Ret& ret_val, stream& j) {
ret_frame<Ret> ret(get().get_frame(), ret_val);
this->P()[j].push_front(ret);
+ switch (this->parents().size()) {
+ case 0:
+ return ;
+ case 1:
+ this->get_label().call(queue, ret, j, *(this->parents().begin()));
+ return ;
+ }
for (node_core::node_set_t::iterator i = this->parents().begin();
i != this->parents().end(); ++i) {
queue.add(this->get_label(), ret, *i, j);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-07-29 23:35:19
|
Revision: 113
http://aurelia.svn.sourceforge.net/aurelia/?rev=113&view=rev
Author: valentindavid
Date: 2010-07-29 23:35:13 +0000 (Thu, 29 Jul 2010)
Log Message:
-----------
2010-07-30 Valentin David <val...@ii...>
* src/llstack/node.hh, src/llstack/node.hpp:
Do not create frame on void return.
* src/llstack/frame.hh:
Fail when wrong conversion. Expect to make exact conversion each time.
* src/llstack/utils.hh:
Update.
* src/parser_generator/syntax.csf:
Build the tree.
* src/parser_generator/parser_gen.cc:
Remove use of drop_ret.
* src/parser_generator/syntax.cc:
Print out the result.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/llstack/frame.hh
trunk/src/llstack/node.hh
trunk/src/llstack/node.hpp
trunk/src/llstack/utils.hh
trunk/src/parser_generator/parser_gen.cc
trunk/src/parser_generator/syntax.cc
trunk/src/parser_generator/syntax.csf
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-07-29 23:09:50 UTC (rev 112)
+++ trunk/ChangeLog 2010-07-29 23:35:13 UTC (rev 113)
@@ -1,5 +1,25 @@
2010-07-30 Valentin David <val...@ii...>
+ * src/llstack/node.hh, src/llstack/node.hpp:
+ Do not create frame on void return.
+
+ * src/llstack/frame.hh:
+ Fail when wrong conversion. Expect to make exact conversion each time.
+
+ * src/llstack/utils.hh:
+ Update.
+
+ * src/parser_generator/syntax.csf:
+ Build the tree.
+
+ * src/parser_generator/parser_gen.cc:
+ Remove use of drop_ret.
+
+ * src/parser_generator/syntax.cc:
+ Print out the result.
+
+2010-07-30 Valentin David <val...@ii...>
+
* src/terms/shared_object.hh:
Do not use virtual for dealing with unknown objects. Force
use of inline-able destructor for the core object.
Modified: trunk/src/llstack/frame.hh
===================================================================
--- trunk/src/llstack/frame.hh 2010-07-29 23:09:50 UTC (rev 112)
+++ trunk/src/llstack/frame.hh 2010-07-29 23:35:13 UTC (rev 113)
@@ -112,13 +112,15 @@
return *rf == *(other.rf);
}
- struct BadFrame {};
template <typename T>
const T& as() const {
+#if NDEBUG
+ return *static_cast<const T*>(&*rf);
+#else
const T* ret = dynamic_cast<const T*>(&*rf);
- if (ret != NULL)
- return *ret;
- throw BadFrame();
+ assert(ret != NULL);
+ return *ret;
+#endif
}
};
Modified: trunk/src/llstack/node.hh
===================================================================
--- trunk/src/llstack/node.hh 2010-07-29 23:09:50 UTC (rev 112)
+++ trunk/src/llstack/node.hh 2010-07-29 23:35:13 UTC (rev 113)
@@ -277,6 +277,8 @@
template <typename Ret>
void pop(R_t& queue, const Ret& ret_value, const stream& j);
+ void pop(R_t& queue, const VoidReturn&, const stream& j);
+
template <typename Ret>
void pop(R_t& queue, const Ret& ret_value, const stream& j) const {
node(*this).pop(queue, ret_value, j);
Modified: trunk/src/llstack/node.hpp
===================================================================
--- trunk/src/llstack/node.hpp 2010-07-29 23:09:50 UTC (rev 112)
+++ trunk/src/llstack/node.hpp 2010-07-29 23:35:13 UTC (rev 113)
@@ -65,6 +65,14 @@
return node(l, empty_frame(), s.get_pos());
}
+void node::pop(R_t& queue, const VoidReturn&, const stream& j) {
+ this->P()[j].push_front(get().get_frame());
+ for (node_core::node_set_t::iterator i = this->parents().begin();
+ i != this->parents().end(); ++i) {
+ queue.add(this->get_label(), get().get_frame(), *i, j);
+ }
+}
+
template <typename Ret>
void node::pop(R_t& queue, const Ret& ret_val, const stream& j) {
ret_frame<Ret> ret(get().get_frame(), ret_val);
Modified: trunk/src/llstack/utils.hh
===================================================================
--- trunk/src/llstack/utils.hh 2010-07-29 23:09:50 UTC (rev 112)
+++ trunk/src/llstack/utils.hh 2010-07-29 23:35:13 UTC (rev 113)
@@ -61,14 +61,9 @@
struct drop_ret {
public:
void operator()(R_t& R, const frame& f, stream& s, const node& cu) const {
- try {
- ret_frame<Ret> t = f.as<ret_frame<Ret> >();
- Label l;
- l(R, t.parent, s, cu);
- } catch (frame::BadFrame) {
- Label l;
- l(R, f, s, cu);
- }
+ ret_frame<Ret> t = f.as<ret_frame<Ret> >();
+ Label l;
+ l(R, t.parent, s, cu);
}
unsigned hash() const {
Modified: trunk/src/parser_generator/parser_gen.cc
===================================================================
--- trunk/src/parser_generator/parser_gen.cc 2010-07-29 23:09:50 UTC (rev 112)
+++ trunk/src/parser_generator/parser_gen.cc 2010-07-29 23:35:13 UTC (rev 113)
@@ -268,14 +268,10 @@
std::cout << " };" << std::endl;
} catch (Failure) {
std::cout << " typedef ";
- if (index_l > 0)
- std::cout << "drop_ret<";
std::cout << "parse_symbol<" << toparse
<< ", " << nt_name << "_" << index
<< "_" << index_l << ", branch<" << nt_name
<< "," << index << "," << index_l+1 << "> > ";
- if (index_l > 0)
- std::cout << "> ";
std::cout << "res;"
<< std::endl;
}
@@ -321,14 +317,10 @@
std::cout << " };" << std::endl;
} catch (Failure) {
std::cout << " typedef ";
- if (index_l > 0)
- std::cout << "drop_ret<";
std::cout << "parse_string<str_"
<< i << ", branch<" << nt_name
<< "," << index << "," << index_l + 1
<< "> > ";
- if (index_l > 0)
- std::cout << "> ";
std::cout << "res;" << std::endl;
}
@@ -350,13 +342,9 @@
<< index << "," << index_l
<< "> {" << std::endl;
std::cout << " typedef ";
- if (index_l > 0)
- std::cout << "drop_ret<";
std::cout << "parse_set<set_" << num << ", branch<"
<< nt_name << ", " << index << ", " << index_l+1
<< "> > ";
- if (index_l > 0)
- std::cout << "> ";
std::cout << "res;" << std::endl;
std::cout << "};" << std::endl;
}
Modified: trunk/src/parser_generator/syntax.cc
===================================================================
--- trunk/src/parser_generator/syntax.cc 2010-07-29 23:09:50 UTC (rev 112)
+++ trunk/src/parser_generator/syntax.cc 2010-07-29 23:35:13 UTC (rev 113)
@@ -38,11 +38,14 @@
#include "syntax.hh"
bool found;
+T result;
struct Start {
- void operator()(R_t&, const frame&, stream& s, const node&) const {
+ void operator()(R_t&, const frame& f, stream& s, const node&) const {
+ assert(!found);
if (s.eof()) {
- std::cerr << s.get_pos() << " " << "Found!" << std::endl;
+ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ result = rf0.t;
found = true;
}
}
@@ -94,5 +97,10 @@
std::ifstream in(SRCDIR"/syntax.csf");
buf_stream bs(in);
stream s = bs.begin();
- return !main_loop(s, bs.end());
+ if (main_loop(s, bs.end())) {
+ std::cerr << result << std::endl;
+ result.~T();
+ return 0;
+ }
+ return 1;
}
Modified: trunk/src/parser_generator/syntax.csf
===================================================================
--- trunk/src/parser_generator/syntax.csf 2010-07-29 23:09:50 UTC (rev 112)
+++ trunk/src/parser_generator/syntax.csf 2010-07-29 23:35:13 UTC (rev 113)
@@ -51,12 +51,12 @@
Range ::= Char "-" Char
RangesOrChars ::= Range RangesOrChars? | Char RangesOrChars?
RangesOrChars? ::= RangesOrChars |
- ClassChar ::= $ ret_frame<stream> next_frame(f, s); $ "[" $ frame next_frame(f); $ RangesOrChars $ frame next_frame(pop_void(f)); $ "]"
+ ClassChar ::= $ ret_frame<stream> next_frame(f, s); $ "[" RangesOrChars "]"
$
ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
$
- | $ ret_frame<stream> next_frame(f, s); $ "[" $ frame next_frame(f); $ "^" $ frame next_frame(f); $ RangesOrChars $ frame next_frame(pop_void(f)); $ "]"
+ | $ ret_frame<stream> next_frame(f, s); $ "[" "^" RangesOrChars "]"
$
ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
@@ -81,55 +81,47 @@
if (((*s) >= 'a') && (*s) <= 'z')
return ;
}
- ret_frame<VoidReturn> rf0 = f.as<ret_frame<VoidReturn> >();
- ret_frame<stream> rf1 = rf0.parent.as<ret_frame<stream> >();
- T ret(C("\"" + stream_range_to_string(rf1.t, s) + "\"", 0));
+ ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
+ T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
$
StringChar ::= [^\"\\] | "\\" SpecialChar
StringChar+ ::= StringChar StringChar*
StringChar* ::= StringChar+ |
String ::= $ ret_frame<stream> next_frame(f, s); $ "\""
- $ frame next_frame(f); $ StringChar* $ frame next_frame(pop_void(f)); $ "\""
+ StringChar* "\""
$
ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
$
Rule ::=
- Symbol $ frame next_frame(f); $ //rf7
- LAYOUT? $ frame next_frame(f); $ //rf6
- ParameterList $ frame next_frame(f); $ //rf5
- LAYOUT? $ frame next_frame(f); $ //rf4
- RetType $ frame next_frame(f); $ //rf3
- LAYOUT? $ frame next_frame(f); $ //rf2
+ Symbol //rf3
+ LAYOUT? $ frame next_frame(f); $
+ ParameterList //rf2
+ LAYOUT? $ frame next_frame(f); $
+ RetType //rf1
+ LAYOUT? $ frame next_frame(f); $
"::=" $ frame next_frame(f); $
- LAYOUT? $ frame next_frame(f); $ //rf1
+ LAYOUT? $ frame next_frame(f); $
ListOfChains //rf0
$
ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<VoidReturn> rf1 = rf0.parent.as<ret_frame<VoidReturn> >();
- ret_frame<VoidReturn> rf2 = rf1.parent.as<ret_frame<VoidReturn> >();
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ ret_frame<T> rf2 = rf1.parent.as<ret_frame<T> >();
ret_frame<T> rf3 = rf2.parent.as<ret_frame<T> >();
- ret_frame<VoidReturn> rf4 = rf3.parent.as<ret_frame<VoidReturn> >();
- ret_frame<T> rf5 = rf4.parent.as<ret_frame<T> >();
- ret_frame<VoidReturn> rf6 = rf5.parent.as<ret_frame<VoidReturn> >();
- ret_frame<T> rf7 = rf6.parent.as<ret_frame<T> >();
- T ret(C("Rule", 4), (rf7.t, rf5.t, rf3.t, rf0.t));
+ T ret(C("Rule", 4), (rf3.t, rf2.t, rf1.t, rf0.t));
$
S ::= LAYOUT? SS LAYOUT? $
- ret_frame<VoidReturn> rf0 = f.as<ret_frame<VoidReturn> >();
- ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
- std::cerr << rf1.t << std::endl;
- VoidReturn ret;
+ ret_frame<T> rf0 = f.as<ret_frame<T> >();
+ T ret = rf0.t;
$
- SS ::= Rule $ frame next_frame(f); $ LAYOUT? $ frame next_frame(f); $ SSS
+ SS ::= Rule LAYOUT? SSS
$
ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<VoidReturn> rf1 = rf0.parent.as<ret_frame<VoidReturn> >();
- ret_frame<T> rf2 = rf1.parent.as<ret_frame<T> >();
- T ret(C::AS_LIST, (rf2.t, rf0.t));
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C::AS_LIST, (rf1.t, rf0.t));
$
SSS ::= SS $
ret_frame<T> rf0 = f.as<ret_frame<T> >();
@@ -138,15 +130,15 @@
| $ T ret(C::AS_EMPTY_LIST); $
ParameterList ::=
- "(" LAYOUT? Parameters $ frame next_frame(f); $ LAYOUT? $ frame next_frame(f); $ ")"
- $ T ret = f.as<ret_frame<VoidReturn> >().parent.as<ret_frame<T> >().t; $
+ "(" LAYOUT? Parameters LAYOUT? ")"
+ $ T ret = f.as<ret_frame<T> >().t; $
| $ T ret(C("NoParam")); $
- LocalParameters ::= "{" LAYOUT? Parameters $ frame next_frame(f); $ LAYOUT? $ frame next_frame(f); $ "}"
- $ T ret(C("Some", 1), f.as<ret_frame<VoidReturn> >().parent.as<ret_frame<T> >().t); $
+ LocalParameters ::= "{" LAYOUT? Parameters LAYOUT? "}"
+ $ T ret(C("Some", 1), f.as<ret_frame<T> >().t); $
| $ T ret(C("None")); $
- ListOfChains ::= Chain $ frame next_frame(f); $ LAYOUT? $ frame next_frame(pop_void(f)); $ AttrRule? $ frame next_frame(f); $ LAYOUT? $ frame next_frame(pop_void(f)); $ ListOfChainsTail
+ ListOfChains ::= Chain LAYOUT? AttrRule? LAYOUT? ListOfChainsTail
$
ret_frame<T> rf0 = f.as<ret_frame<T> >();
ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
@@ -174,7 +166,7 @@
| $ T ret(C::AS_EMPTY_LIST); $
NonEmptyChain ::=
- AttrRule? $ frame next_frame(f); $ LAYOUT? $ frame next_frame(pop_void(f)); $ ChainElt $ frame next_frame(f); $ LAYOUT? $ frame next_frame(pop_void(f)); $ Chain
+ AttrRule? LAYOUT? ChainElt LAYOUT? Chain
$
ret_frame<T> rf0 = f.as<ret_frame<T> >();
ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
@@ -183,15 +175,13 @@
$
AttrRule ::=
- LocalParameters $ frame next_frame(f); $ LAYOUT? $ frame next_frame(f); $ "$" $ ret_frame<stream> next_frame(f, s); $ CxxCode $ ret_frame<stream> next_frame(f, s); $ "$"
+ LocalParameters LAYOUT? "$" $ ret_frame<stream> next_frame(f, s); $ CxxCode $ ret_frame<stream> next_frame(f, s); $ "$"
$
ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
- ret_frame<VoidReturn> rf1 = rf0.parent.as<ret_frame<VoidReturn> >();
- ret_frame<stream> rf2 = rf1.parent.as<ret_frame<stream> >();
- ret_frame<VoidReturn> rf3 = rf2.parent.as<ret_frame<VoidReturn> >();
- ret_frame<T> rf4 = rf3.parent.as<ret_frame<T> >();
- T ret(C("AttrRule", 2), (rf4.t,
- T(C("\"" + stream_range_to_string(rf2.t, rf0.t) + "\"", 0))));
+ ret_frame<stream> rf1 = rf0.parent.as<ret_frame<stream> >();
+ ret_frame<T> rf2 = rf1.parent.as<ret_frame<T> >();
+ T ret(C("AttrRule", 2), (rf2.t,
+ T(C("\"" + stream_range_to_string(rf1.t, rf0.t) + "\"", 0))));
$
ChainElt ::=
@@ -204,7 +194,7 @@
ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
T ret(C("Symbol", 2), (rf1.t, rf0.t)); $
- ArgumentList ::= "(" LAYOUT? Arguments $ frame next_frame(f); $ LAYOUT? $ frame next_frame(pop_void(f)); $ ")" $
+ ArgumentList ::= "(" LAYOUT? Arguments LAYOUT? ")" $
ret_frame<T> rf0 = f.as<ret_frame<T> >();
T ret(C("Args", 1), rf0.t);
$
@@ -216,7 +206,7 @@
$
| $ T ret(C::AS_EMPTY_LIST); $
- Arguments ::= Argument $ frame next_frame(f); $ LAYOUT? $ frame next_frame(pop_void(f)); $ OtherArguments
+ Arguments ::= Argument LAYOUT? OtherArguments
$
ret_frame<T> rf0 = f.as<ret_frame<T> >();
ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
@@ -224,9 +214,8 @@
$
Argument ::= $ ret_frame<stream> next_frame(f, s); $ CxxExpression $
- ret_frame<VoidReturn> rf0 = f.as<ret_frame<VoidReturn> >();
- ret_frame<stream> rf1 = rf0.parent.as<ret_frame<stream> >();
- T ret(C("\"" + stream_range_to_string(rf1.t, s) + "\"", 0));
+ ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
+ T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
$
CxxExpression ::= CxxIdentifier
@@ -236,23 +225,17 @@
CxxCode? ::= CxxCode |
CxxChar ::= [^$]
- Parameter ::= CxxType $ frame next_frame(f); $ LAYOUT $ frame next_frame(f); $ CxxIdentifier
+ Parameter ::= CxxType LAYOUT CxxIdentifier
$
ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<VoidReturn> rf1 = rf0.parent.as<ret_frame<VoidReturn> >();
- ret_frame<T> rf2 = rf1.parent.as<ret_frame<T> >();
- T ret(C("Parameter", 2), (rf2.t, rf0.t));
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C("Parameter", 2), (rf1.t, rf0.t));
$
- CxxType ::= $ ret_frame<stream> next_frame(f, s); $ CxxIdentifier $ frame next_frame(f); $ LAYOUT? $ frame next_frame(f); $ TemplateArguments $ frame next_frame(f); $ LAYOUT? $ frame next_frame(f); $ ContCxxType
+ CxxType ::= $ ret_frame<stream> next_frame(f, s); $ CxxIdentifier LAYOUT? TemplateArguments LAYOUT? ContCxxType
$
- ret_frame<VoidReturn> rf0 = f.as<ret_frame<VoidReturn> >();
- ret_frame<VoidReturn> rf1 = rf0.parent.as<ret_frame<VoidReturn> >();
- ret_frame<VoidReturn> rf2 = rf1.parent.as<ret_frame<VoidReturn> >();
- ret_frame<VoidReturn> rf3 = rf2.parent.as<ret_frame<VoidReturn> >();
- ret_frame<VoidReturn> rf4 = rf3.parent.as<ret_frame<VoidReturn> >();
- ret_frame<stream> rf5 = rf4.parent.as<ret_frame<stream> >();
- T ret(C("\"" + stream_range_to_string(rf5.t, s) + "\"", 0));
+ ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
+ T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
$
ContCxxType ::= "::" LAYOUT? CxxType |
@@ -265,12 +248,11 @@
|
$ T ret(T(C("None"))); $
- Parameters ::= Parameter $ frame next_frame(f); $ LAYOUT? $ frame next_frame(f); $ CParameters
+ Parameters ::= Parameter LAYOUT? CParameters
$
ret_frame<T> rf0 = f.as<ret_frame<T> >();
- ret_frame<VoidReturn> rf1 = rf0.parent.as<ret_frame<VoidReturn> >();
- ret_frame<T> rf2 = rf1.parent.as<ret_frame<T> >();
- T ret(C::AS_LIST, (rf2.t, rf0.t));
+ ret_frame<T> rf1 = rf0.parent.as<ret_frame<T> >();
+ T ret(C::AS_LIST, (rf1.t, rf0.t));
$
CParameters ::= "," LAYOUT? Parameters $
@@ -279,11 +261,9 @@
$
| $ T ret(C::AS_EMPTY_LIST); $
- CxxIdentifier ::= $ ret_frame<stream> next_frame(f, s); $ [A-Za-z_] $ frame next_frame(f); $ CIS
+ CxxIdentifier ::= $ ret_frame<stream> next_frame(f, s); $ [A-Za-z_] CIS
$
- ret_frame<VoidReturn> rf0 = f.as<ret_frame<VoidReturn> >();
- ret_frame<VoidReturn> rf1 = rf0.parent.as<ret_frame<VoidReturn> >();
- ret_frame<stream> rf2 = rf1.parent.as<ret_frame<stream> >();
- T ret(C("\"" + stream_range_to_string(rf2.t, s) + "\"", 0));
+ ret_frame<stream> rf0 = f.as<ret_frame<stream> >();
+ T ret(C("\"" + stream_range_to_string(rf0.t, s) + "\"", 0));
$
CIS ::= [A-Za-z_0-9] CIS |
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <val...@us...> - 2010-07-29 23:09:56
|
Revision: 112
http://aurelia.svn.sourceforge.net/aurelia/?rev=112&view=rev
Author: valentindavid
Date: 2010-07-29 23:09:50 +0000 (Thu, 29 Jul 2010)
Log Message:
-----------
2010-07-30 Valentin David <val...@ii...>
* src/terms/shared_object.hh:
Do not use virtual for dealing with unknown objects. Force
use of inline-able destructor for the core object.
* src/llstack/node.hh:
Update.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/llstack/node.hh
trunk/src/terms/shared_object.hh
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-07-29 22:36:46 UTC (rev 111)
+++ trunk/ChangeLog 2010-07-29 23:09:50 UTC (rev 112)
@@ -1,3 +1,12 @@
+2010-07-30 Valentin David <val...@ii...>
+
+ * src/terms/shared_object.hh:
+ Do not use virtual for dealing with unknown objects. Force
+ use of inline-able destructor for the core object.
+
+ * src/llstack/node.hh:
+ Update.
+
2010-07-29 Valentin David <val...@ii...>
Use pooled memory allocators.
Modified: trunk/src/llstack/node.hh
===================================================================
--- trunk/src/llstack/node.hh 2010-07-29 22:36:46 UTC (rev 111)
+++ trunk/src/llstack/node.hh 2010-07-29 23:09:50 UTC (rev 112)
@@ -138,7 +138,7 @@
typedef SharedObject<node> super;
node(RealObject* ro): super(NoBuild()) {
- this->o = (VirtualRealObject<False>*)(ro);
+ this->o = ro;
this->o->inc();
}
Modified: trunk/src/terms/shared_object.hh
===================================================================
--- trunk/src/terms/shared_object.hh 2010-07-29 22:36:46 UTC (rev 111)
+++ trunk/src/terms/shared_object.hh 2010-07-29 23:09:50 UTC (rev 112)
@@ -68,6 +68,9 @@
VirtualRealObject(): refs(0) {}
};
+template <typename T>
+struct SharedObject;
+
template <typename HasLock>
struct VirtualSharedObject {
protected:
@@ -87,6 +90,14 @@
}
}
+ template <typename T>
+ VirtualSharedObject(const SharedObject<T>& other)
+ : o(other.o) {
+ if (o != NULL) {
+ o->inc();
+ }
+ }
+
~VirtualSharedObject() {
if (o == NULL)
return ;
@@ -119,11 +130,9 @@
};
template <typename T>
-struct SharedObject
- : public VirtualSharedObject<typename ThreadSafe<T>::res> {
+struct SharedObject {
+ friend class VirtualSharedObject<typename ThreadSafe<T>::res>;
private:
- typedef VirtualSharedObject<typename ThreadSafe<T>::res> super;
-
typedef typename SOLock<typename ThreadSafe<T>::res>::res Lock;
public:
struct RealObject;
@@ -189,6 +198,9 @@
}
public:
virtual void destroy() {
+ fast_destroy();
+ }
+ void fast_destroy() {
map_lock().lock();
this->ref_lock.lock();
if (this->refs == 0) {
@@ -227,23 +239,46 @@
set_data((core_type*)realdata);
}
};
-private:
+protected:
+ RealObject* o;
+
RealObject* obj() const {
- return (RealObject*)(this->o);
+ return o;
}
public:
- SharedObject(const NoBuild& n): super(n) {}
+ SharedObject(const NoBuild& n): o(NULL) {}
- SharedObject(const core_type& ct): super(NoBuild()) {
+ SharedObject(const SharedObject& other): o(other.o) {
+ if (o != NULL) {
+ o->inc();
+ }
+ }
+
+ SharedObject(const core_type& ct) {
RealObject tmp(*const_cast<core_type*>(&ct));
map_lock().lock();
std::pair<o_map_it,bool> i = objects().insert(tmp);
- this->o = (VirtualRealObject<typename ThreadSafe<T>::res>*)(&(*(i.first)));
- this->o->inc();
+ o = const_cast<RealObject*>(&(*(i.first)));
+ o->inc();
map_lock().unlock();
}
+ ~SharedObject() {
+ if (o == NULL)
+ return ;
+ o->ref_lock.lock();
+ o->refs--;
+ if (o->refs == 0) {
+ o->ref_lock.unlock();
+ o->fast_destroy();
+ o = NULL;
+ return ;
+ }
+ o->ref_lock.unlock();
+ o = NULL;
+ }
+
public:
const core_type& get() const {
return *(obj()->data());
@@ -262,6 +297,20 @@
static_cast<T*>(this)->swap(other);
return *static_cast<T*>(this);
}
+
+ bool operator==(const SharedObject& other) const {
+ return o == other.o;
+ }
+
+ bool operator!=(const SharedObject& other) const {
+ return !(o == other.o);
+ }
+
+ void swap(SharedObject& so) {
+ RealObject *a = o;
+ o = so.o;
+ so.o = a;
+ }
};
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|