From cb65012eb524eb57b00249f1dee0f245e947cda4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 13 Sep 2009 18:46:11 +0200 Subject: Use new path class, add context and generator classes Use cutl::fs::path instead of std::string in the semantic graph. Add context and generator stubs, to be filled next. Connect everything in the compiler driver. --- cli/parser.cxx | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'cli/parser.cxx') diff --git a/cli/parser.cxx b/cli/parser.cxx index 9b9c116..54ab78a 100644 --- a/cli/parser.cxx +++ b/cli/parser.cxx @@ -124,15 +124,15 @@ recover (token& t) } auto_ptr parser:: -parse (std::istream& is, std::string const& id) +parse (std::istream& is, path const& p) { - auto_ptr unit (new cli_unit (id)); + auto_ptr unit (new cli_unit (p)); unit_ = unit.get (); - lexer l (is, id); + lexer l (is, p.string ()); lexer_ = &l; - id_ = &id; + path_ = &p; valid_ = true; def_unit (); @@ -179,7 +179,7 @@ def_unit () continue; } - cerr << *id_ << ':' << t.line () << ':' << t.column () << ": error: " + cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: " << "expected namespace or class declaration instead of " << t << endl; throw error (); @@ -201,14 +201,14 @@ include_decl () if (t.type () != token::t_path_lit) { - cerr << *id_ << ':' << t.line () << ':' << t.column () << ": error: " + cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: " << "expected path literal instead of " << t << endl; throw error (); } if (valid_) { - cxx_unit& n (unit_->new_node (*id_, t.line (), t.column ())); + cxx_unit& n (unit_->new_node (*path_, t.line (), t.column ())); unit_->new_edge (*unit_, n, t.literal ()); } @@ -216,7 +216,7 @@ include_decl () if (t.punctuation () != token::p_semi) { - cerr << *id_ << ':' << t.line () << ':' << t.column () << ": error: " + cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: " << "expected ';' instead of " << t << endl; throw error (); } @@ -253,7 +253,7 @@ namespace_def () if (t.type () != token::t_identifier) { - cerr << *id_ << ':' << t.line () << ':' << t.column () << ": error: " + cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: " << "expected identifier instead of " << t << endl; throw error (); } @@ -263,7 +263,7 @@ namespace_def () if (valid_) { namespace_& n ( - unit_->new_node (*id_, t.line (), t.column ())); + unit_->new_node (*path_, t.line (), t.column ())); unit_->new_edge (*scope_, n, t.identifier ()); scope_ = &n; } @@ -272,7 +272,7 @@ namespace_def () if (t.punctuation () != token::p_lcbrace) { - cerr << *id_ << ':' << t.line () << ':' << t.column () << ": error: " + cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: " << "expected '{' instead of " << t << endl; throw error (); } @@ -288,7 +288,7 @@ namespace_def () if (t.punctuation () != token::p_rcbrace) { - cerr << *id_ << ':' << t.line () << ':' << t.column () << ": error: " + cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: " << "expected namespace declaration, class declaration, or '}' " << "instead of " << t << endl; throw error (); @@ -302,7 +302,7 @@ class_def () if (t.type () != token::t_identifier) { - cerr << *id_ << ':' << t.line () << ':' << t.column () << ": error: " + cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: " << "expected identifier instead of " << t << endl; throw error (); } @@ -311,7 +311,7 @@ class_def () if (valid_) { - class_& n (unit_->new_node (*id_, t.line (), t.column ())); + class_& n (unit_->new_node (*path_, t.line (), t.column ())); unit_->new_edge (*scope_, n, t.identifier ()); scope_ = &n; } @@ -320,7 +320,7 @@ class_def () if (t.punctuation () != token::p_lcbrace) { - cerr << *id_ << ':' << t.line () << ':' << t.column () << ": error: " + cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: " << "expected '{' instead of " << t << endl; throw error (); } @@ -349,7 +349,7 @@ class_def () if (t.punctuation () != token::p_rcbrace) { - cerr << *id_ << ':' << t.line () << ':' << t.column () << ": error: " + cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: " << "expected option declaration or '}' instead of " << t << endl; throw error (); } @@ -358,7 +358,7 @@ class_def () if (t.punctuation () != token::p_semi) { - cerr << *id_ << ':' << t.line () << ':' << t.column () << ": error: " + cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: " << "expected ';' instead of " << t << endl; throw error (); } @@ -383,8 +383,8 @@ option_def (token& t) if (valid_) { - o = &unit_->new_node