[from now] 2012/03/21 18:00:57

diff --git a/SConstruct b/SConstruct
index acd7931..8e2a8e7 100755
--- a/SConstruct
+++ b/SConstruct
@@ -104,7 +104,8 @@ TESTS = {'notificator' : 'src/mocha/roaster/notificator',
          'platform_directory' : 'src/mocha/roaster/platform/fs/directory',
          'platform_path' : 'src/mocha/roaster/platform/fs/path',
          'nexc' : 'src/mocha/roaster/nexc',
-         'nexc-scanner' : 'src/mocha/roaster/nexc/scanner'
+         'nexc-scanner' : 'src/mocha/roaster/nexc/scanner',
+         'nexc-parser' : 'src/mocha/roaster/nexc/parser'
          }

diff --git a/src/mocha/roaster/ast/ast.cc b/src/mocha/roaster/ast/ast.cc
index 73b5418..01af260 100755
--- a/src/mocha/roaster/ast/ast.cc
+++ b/src/mocha/roaster/ast/ast.cc
@@ -20,9 +20,9 @@
  *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  *DEALINGS IN THE SOFTWARE.
  */
-#include <assert.h>
+#include <mocha/roaster/assert/assert_def.h>
 #include <mocha/roaster/ast/ast.h>
-#include <mocha/roaster/tokens/token_info.h>
+#include <mocha/roaster/nexc/tokens/token_info.h>
 namespace mocha {

 AstNode::AstNode(int type, const char* name, int64_t line) :
@@ -31,7 +31,7 @@ AstNode::AstNode(int type, const char* name, int64_t line) :
     next_sibling_(0), prev_sibling_(0) {}

 void AstNode::AddChild(AstNode* node) {
-  assert(this != node);
+  ASSERT(true, this != node);
   if (first_child_ == 0) {
     first_child_ = node;
     last_child_ = node;
@@ -49,7 +49,7 @@ void AstNode::AddChild(AstNode* node) {
 }

 void AstNode::InsertBefore(AstNode* node) {
-  assert(this != node);
+  ASSERT(true, this != node);
   if (first_child_ == 0) {
     first_child_ = node;
     last_child_ = node;
@@ -66,9 +66,9 @@ void AstNode::InsertBefore(AstNode* node) {
 }

 void AstNode::InsertBefore(AstNode* insert, AstNode* target) {
-  assert(this != insert);
-  assert(this != target);
-  assert(target != insert);
+  ASSERT(true, this != insert);
+  ASSERT(true, this != target);
+  ASSERT(true, target != insert);
   bool is_insert = false;
   if (first_child_ == target) {
     first_child_ = insert;
@@ -91,9 +91,9 @@ void AstNode::InsertBefore(AstNode* insert, AstNode* target) {
 }

 void AstNode::InsertAfter(AstNode* insert, AstNode* target) {
-  assert(this != insert);
-  assert(target != insert);
-  assert(this != target);
+  ASSERT(true, this != insert);
+  ASSERT(true, target != insert);
+  ASSERT(true, this != target);
   bool is_insert = false;

   if (last_child_ == target  ) {
@@ -117,15 +117,15 @@ void AstNode::InsertAfter(AstNode* insert, AstNode* target) {
 }

 void AstNode::Append(AstNode* node) {
-  assert(this != node);
+  ASSERT(true, this != node);
   if (node) {
     typedef std::vector<AstNode*> AstArray;
     AstArray ast_array;
     NodeIterator iterator = node->ChildNodes();
     while (iterator.HasNext()) {
       AstNode* item = iterator.Next();
-      assert(this != item);
-      assert(node != item);
+      ASSERT(true, this != item);
+      ASSERT(true, node != item);
       ast_array.push_back(item);
     }
     AstArray::iterator begin = ast_array.begin(), end = ast_array.end();
@@ -163,7 +163,7 @@ AstNode* ReverseNodeIterator::Next() {
 }

 void AstNode::RemoveChild(AstNode* node) {
-  assert(this != node);
+  ASSERT(true, this != node);
   AstNode* match_ptr = 0;
   NodeIterator iterator = ChildNodes();
   while (iterator.HasNext()) {
@@ -206,7 +206,7 @@ void AstNode::RemoveChild(AstNode* node) {

 void AstNode::ReplaceWith(AstNode* node) {
-  assert(this != node);
+  ASSERT(true, this != node);
   node->parent_ = parent_;
   node->next_sibling_ = next_sibling_;
   node->prev_sibling_ = prev_sibling_;
@@ -220,9 +220,9 @@ void AstNode::ReplaceWith(AstNode* node) {

 void AstNode::ReplaceChild(AstNode* old_node, AstNode* new_node) {
-  assert(old_node != new_node);
-  assert(this != old_node);
-  assert(this != new_node);
+  ASSERT(true, old_node != new_node);
+  ASSERT(true, this != old_node);
+  ASSERT(true, this != new_node);
   if (first_child_) {
     if (old_node == first_child_) {
       first_child_ = new_node;
@@ -237,12 +237,12 @@ void AstNode::ReplaceChild(AstNode* old_node, AstNode* new_node) {

 template <typename T, typename T2>
 inline T2* CopyChildren(T* dest, T2* source, memory::Pool* pool) {
-  assert(dest != source);
+  ASSERT(true, dest != source);
   dest->set_parent_node(source->parent_node());
   NodeIterator iter = source->ChildNodes();
   while (iter.HasNext()) {
     AstNode* item = iter.Next();
-    assert(source != item);
+    ASSERT(true, source != item);
     dest->AddChild(item->Clone(pool));
   }
   return dest;
diff --git a/src/mocha/roaster/ast/ast.h b/src/mocha/roaster/ast/ast.h
index 5826e64..79dcc7c 100755
--- a/src/mocha/roaster/ast/ast.h
+++ b/src/mocha/roaster/ast/ast.h
@@ -27,11 +27,11 @@
 #include <string>
 #include <mocha/roaster/misc/class_traits/uncopyable.h>
 #include <mocha/roaster/misc/class_traits/unallocatable.h>
+#include <mocha/roaster/memory/pool.h>
 #include <mocha/roaster/scopes/scope.h>
-#include <mocha/roaster/tokens/token_info.h>
 #include <mocha/roaster/ast/ast_foward_decl.h>
 #include <mocha/roaster/ast/visitors/ivisitor.h>
-#include <mocha/roaster/memory/pool.h>
+#include <mocha/roaster/nexc/tokens/token_info.h>

 namespace mocha {
 #define NVI_ACCEPTOR_DECL virtual void NVIAccept_(IVisitor* visitor)
diff --git a/src/mocha/roaster/ast/builder/ast_builder.cc b/src/mocha/roaster/ast/builder/ast_builder.cc
index 8b647d4..80f93f5 100755
--- a/src/mocha/roaster/ast/builder/ast_builder.cc
+++ b/src/mocha/roaster/ast/builder/ast_builder.cc
@@ -1,14 +1,14 @@
 #include <string.h>
 #include <stdarg.h>
 #include <sstream>
+#include <mocha/roaster/platform/fs/fs.h>
+#include <mocha/roaster/memory/pool.h>
 #include <mocha/roaster/ast/builder/ast_builder.h>
 #include <mocha/roaster/ast/ast.h>
 #include <mocha/roaster/ast/visitors/utils/visitor_info.h>
-#include <mocha/roaster/tokens/js_token.h>
-#include <mocha/roaster/tokens/token_info.h>
-#include <mocha/roaster/tokens/symbol_list.h>
-#include <mocha/roaster/platform/fs/fs.h>
-#include <mocha/roaster/memory/pool.h>
+#include <mocha/roaster/nexc/tokens/js_token.h>
+#include <mocha/roaster/nexc/tokens/token_info.h>
+#include <mocha/roaster/nexc/tokens/symbol_list.h>

 #define TOKEN yy::ParserImplementation::token

diff --git a/src/mocha/roaster/ast/builder/ast_builder.h b/src/mocha/roaster/ast/builder/ast_builder.h
index d4e05a3..fd5510c 100755
--- a/src/mocha/roaster/ast/builder/ast_builder.h
+++ b/src/mocha/roaster/ast/builder/ast_builder.h
@@ -25,7 +25,6 @@
 #define mocha_ast_utils_h_
 #include <assert.h>
 #include <sstream>
-#include <mocha/roaster/compiler.h>
 #include <mocha/roaster/misc/class_traits/static.h>
 #include <mocha/roaster/ast/ast_foward_decl.h>
 #include <mocha/roaster/platform/thread/thread.h>
@@ -34,10 +33,7 @@ namespace mocha {
 namespace memory {
 class Pool;
 }
-#define AST_ERROR(info, message)                                     \
-  char buf[ 1000 ];                                                     \
-  sprintf(buf, "%s at %d\n", message, __LINE__);                    \
-  info->GetCompiler()->CatchException(ExceptionHandler::CreateException(buf))
+#define AST_ERROR(info, message)
 class VisitorInfo;
 class TokenInfo;
 class AstBuilder : private Uncopyable {
diff --git a/src/mocha/roaster/ast/visitors/utils/visitor_info.cc b/src/mocha/roaster/ast/visitors/utils/visitor_info.cc
index 2f5e664..0dd314b 100755
--- a/src/mocha/roaster/ast/visitors/utils/visitor_info.cc
+++ b/src/mocha/roaster/ast/visitors/utils/visitor_info.cc
@@ -1,11 +1,8 @@
 #include <mocha/roaster/platform/fs/fs.h>
-#include <mocha/fileinfo/fileinfo.h>
 #include <mocha/roaster/ast/visitors/utils/visitor_info.h>
 #include <mocha/roaster/ast/visitors/utils/processors/dsta_processor.h>
 #include <mocha/roaster/ast/ast.h>
-#include <mocha/xml/xml_setting_info.h>
 #include <mocha/roaster/smart_pointer/ref_count/shared_ptr.h>
-#include <mocha/roaster/platform/fs/fs.h>

 namespace mocha {

@@ -20,12 +17,12 @@ void CreateRelativePath(const char* base, const char* target, std::string *buffe
   buffer->append("'");
 }

-VisitorInfo::VisitorInfo(bool is_runtime, ScopeRegistry* scope_registry, Compiler *compiler,
+VisitorInfo::VisitorInfo(bool is_runtime, CompilationEvent *event,
                           DstaExtractedExpressions* dsta_exp, const char* main_file_path, const char* file_name) :
     tmp_index_(0), object_depth_(0), is_in_class_(0) ,is_in_module_(0),
     main_file_path_(main_file_path), file_name_(file_name),
     compile_info_(compiler->compilation_info()) ,dsta_exp_(dsta_exp),
-    scope_registry_(scope_registry), compiler_(compiler), current_stmt_(0), current_fn_(0),
+    compilation_event_(event), current_stmt_(0), current_fn_(0),
     builder_(AstBuilder::Local()){
   if (is_runtime){
     bit_vector_.Set(2);
diff --git a/src/mocha/roaster/ast/visitors/utils/visitor_info.h b/src/mocha/roaster/ast/visitors/utils/visitor_info.h
index 2401ef7..4de8394 100755
--- a/src/mocha/roaster/ast/visitors/utils/visitor_info.h
+++ b/src/mocha/roaster/ast/visitors/utils/visitor_info.h
@@ -3,9 +3,8 @@
 #include <string>
 #include <list>
 #include <utility>
-#include <mocha/misc/int_types.h>
-#include <mocha/roaster/utils/compilation_info.h>
-#include <mocha/roaster/tokens/token_info.h>
+#include <mocha/roaster/misc/int_types.h>
+#include <mocha/roaster/nexc/tokens/token_info.h>
 #include <mocha/roaster/smart_pointer/scope/scoped_ptr.h>
 #include <mocha/roaster/misc/class_traits/uncopyable.h>
 #include <mocha/xml/versions.h>
@@ -13,8 +12,7 @@
 #include <mocha/roaster/misc/bits.h>

 namespace mocha {
-class ScopeRegistry;
-class Scope;
+class CompilationEvent;
 class Compiler;
 class ClassProcessor;
 class AstBuilder;
@@ -23,15 +21,14 @@ class VisitorInfo : private Uncopyable{
  public :
   typedef std::pair<AstNode*, AstNode*> AstPair;
   typedef std::list<AstPair> PrivateNameList;
-  VisitorInfo(bool is_runtime, ScopeRegistry* scope_registry, Compiler *compiler ,
-               DstaExtractedExpressions* dsta_exp, const char* main_file_path, const char* file_name);
+  VisitorInfo(bool is_runtime, CompilationEvent* e,
+              DstaExtractedExpressions* dsta_exp, const char* main_file_path, const char* file_name);
   ~VisitorInfo(){};
   int tmp_index() { int ret = tmp_index_;tmp_index_++;return ret; };
   const char* main_file_path() const { return main_file_path_; };
   const char* filename() const { return file_name_; };
   const char* relative_path() const { return relative_path_.c_str(); }
-  ScopeRegistry* scope_registry() const { return scope_registry_; };
-  Compiler* compiler() const { return compiler_; };
+  CompilationEvent* compilation_event() const { return event_; };
   void set_rest_expression(TokenInfo* info) { rest_exp_ = info; }
   TokenInfo* rest_expression() const { return rest_exp_; }
   void set_current_statement(Statement* stmt) { current_stmt_ = stmt; }
@@ -43,7 +40,6 @@ class VisitorInfo : private Uncopyable{
   bool rest_injection() { return bit_vector_[ 1 ]; }

   bool runtime() const { return bit_vector_.At(2); }
-  bool HasVersion(const char* ver) { return compile_info_->HasVersion(ver); }
   bool IsInModules() const { return is_in_module_ > 0; }
   void EscapeModuel() { is_in_module_--;}
   void EnterModuel() { is_in_module_++ ;}
@@ -75,11 +71,9 @@ class VisitorInfo : private Uncopyable{
   std::string relative_path_;
   PrivateNameList private_names_;
   BitVector8 bit_vector_;
-  const CompilationInfo* compile_info_;
   DstaExtractedExpressions* dsta_exp_;
   TokenInfo* rest_exp_;
-  ScopeRegistry *scope_registry_;
-  Compiler *compiler_;
+  CompilationEvent* event_;
   Statement* current_stmt_;
   Function* current_fn_;
   ClassProcessor* current_class_;
diff --git a/src/mocha/roaster/nexc/parser/parser.cc b/src/mocha/roaster/nexc/parser/parser.cc
index 71a2da3..b4e054e 100755
--- a/src/mocha/roaster/nexc/parser/parser.cc
+++ b/src/mocha/roaster/nexc/parser/parser.cc
@@ -4,10 +4,12 @@
 #include <mocha/roaster/ast/ast.h>
 #include <mocha/roaster/ast/builder/ast_builder.h>
 #include <mocha/roaster/utils/error_reporter.h>
-#include <mocha/roaster/parser/parser.h>
-#include <mocha/roaster/scanner/token_stream.h>
-#include <mocha/roaster/tokens/js_token.h>
-#include <mocha/roaster/tokens/symbol_list.h>
+#include <mocha/roaster/nexc/nexc.h>
+#include <mocha/roaster/nexc/parser/parser.h>
+#include <mocha/roaster/nexc/scanner/token_stream.h>
+#include <mocha/roaster/nexc/tokens/js_token.h>
+#include <mocha/roaster/nexc/tokens/symbol_list.h>
+#include <mocha/roaster/nexc/events/compilation_event/compilation_event.h>

 namespace mocha {

@@ -106,13 +108,13 @@ bool IsValidProperty(int type) {
 }

-Parser::ParseEventListener::operator()(CompilationEvent* event) {
+void Parser::ParseEventListener::operator()(CompilationEvent* event) {
   ParserConnector* connector = event->parser_connector();
   ErrorReporter* reporter = event->error_reporter();
   const char* filename = event->filename();
   Parser parser(connector, reporter, filename);
   event->set_ast(parser.Parse());
-  event->notificator()->NotifyForKey(CompilationEvent::EventKey::kTransform, event);
+  event->NotifyForKey(Nexc::kTransformAst);
 }

diff --git a/src/mocha/roaster/nexc/parser/parser.h b/src/mocha/roaster/nexc/parser/parser.h
index 9094de9..7bac272 100755
--- a/src/mocha/roaster/nexc/parser/parser.h
+++ b/src/mocha/roaster/nexc/parser/parser.h
@@ -1,17 +1,40 @@
-#ifndef mocha_parser_h_
-#define mocha_parser_h_
+/**
+ *@author Taketoshi Aono
+ *@fileOverview
+ *@license
+ *Copyright (c) 2011 Taketoshi Aono
+ *Licensed under the BSD.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+ *associated doc umentation files (the "Software"), to deal in the Software without restriction,
+ *including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ *and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ *subject to the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be included in all copies or
+ *substantial portions ofthe Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ *TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ *THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ *DEALINGS IN THE SOFTWARE.
+ */
+#ifndef mocha_nexc_parser_parser_h_
+#define mocha_nexc_parser_parser_h_
 #include <string.h>
 #include <string>
 #include <mocha/roaster/ast/ast_foward_decl.h>
-#include <mocha/roaster/smart_pointer/scope/scoped_ptr.h>
-#include <mocha/roaster/binding/parser_connector.h>
-#include <mocha/roaster/tokens/token_info.h>
-#include <mocha/roaster/tokens/js_token.h>
 #include <mocha/roaster/memory/pool.h>
+#include <mocha/roaster/smart_pointer/scope/scoped_ptr.h>
+#include <mocha/roaster/nexc/binding/parser_connector.h>
+#include <mocha/roaster/nexc/tokens/token_info.h>
+#include <mocha/roaster/nexc/tokens/js_token.h>
 namespace mocha {
 class ErrorReporter;
 class ParserConnector;
 class AstBuilder;
+class CompilationEvent;
 class Parser{
  public :
   Parser(ParserConnector* connector_, ErrorReporter* reporter, const char* filename);
@@ -27,13 +50,11 @@ class Parser{
   AstBuilder* builder() { return builder_; }
   TokenInfo* Advance(int len = 1) {
     TokenInfo* info = connector_->Advance(len);
-    //printf("advance %s\n", static_cast<const char*>(TokenConverter(info)));
     return info;
   }
   TokenInfo* Undo(int len = 1) { return connector_->Undo(len); }
   TokenInfo* Seek(int len = 1) {
     TokenInfo* info = connector_->Seek(len);
-    //printf("seek %s\n", static_cast<const char*>(TokenConverter(info)));
     return info;
   }
   void IllegalEnd(const char* expect, int64_t line);
diff --git a/src/mocha/roaster/nexc/tokens/symbol_list.cc b/src/mocha/roaster/nexc/tokens/symbol_list.cc
index 56eedff..ec0c878 100755
--- a/src/mocha/roaster/nexc/tokens/symbol_list.cc
+++ b/src/mocha/roaster/nexc/tokens/symbol_list.cc
@@ -1,4 +1,4 @@
-#include <mocha/roaster/tokens/symbol_list.h>
+#include <mocha/roaster/nexc/tokens/symbol_list.h>

 namespace mocha {

diff --git a/src/mocha/roaster/notificator/SConscript b/src/mocha/roaster/notificator/SConscript
index cecb6a5..488cec9 100755
--- a/src/mocha/roaster/notificator/SConscript
+++ b/src/mocha/roaster/notificator/SConscript
@@ -1,4 +1,4 @@
-import os
+import os, sys
 root_dir = os.path.dirname(File('SConscript').rfile().abspath + '/../../../../')
 sys.path.insert(0, os.path.join(root_dir, 'tools/scons_helper'))
 from platform_utils import Config
diff --git a/src/mocha/roaster/platform/utils/ut.cc b/src/mocha/roaster/platform/utils/ut.cc
index 6c59309..8787555 100755
--- a/src/mocha/roaster/platform/utils/ut.cc
+++ b/src/mocha/roaster/platform/utils/ut.cc
@@ -1,6 +1,5 @@
 #include <gtest/gtest.h>
 #include <mocha/roaster/platform/utils/utils.h>
-#include <mocha/roaster/compiler/events/io_event/io_event.h>
 TEST(PlatformUtilsTest, PrintfTest) {
   const char* tmp = "ok!";
   mocha::os::Printf("test print %s\n", tmp);