Changeset 118 for trunk/lib/Parser.cc


Ignore:
Timestamp:
Jul 3, 2006, 9:44:49 AM (15 years ago)
Author:
Peter Johansson
Message:

fixes #46 #45 #26 #40

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Parser.cc

    r107 r118  
    2323
    2424#include "Parser.h"
     25#include "utility.h"
    2526
    2627#include <algorithm>
     
    2829#include <fstream>
    2930#include <iostream>
     31#include <string>
    3032
    3133namespace theplu{
     
    3335
    3436
    35   Parser::Parser(std::istream& is)
     37  Parser::Parser(const std::string& path)
     38  {
     39    std::ifstream is(path.c_str());
     40    cc_mode(is);
     41    is.close();
     42  }
     43
     44
     45  void Parser::cc_mode(std::istream& is)
    3646  {
    3747    std::string str;
    3848    while(getline(is,str)) {
    39       std::string::const_iterator where;
     49      std::string::iterator where;
    4050      where = std::find_if(str.begin(), str.end(), std::not1(WhiteSpace()));
    4151      if (where==str.end())
    4252        type_.push_back(empty);
    43       else if (*where=='/' && ((where++)!=str.end()) && *where=='/')
    44         type_.push_back(comment);
    45       else
     53      else if (match_begin(where, str.end(), "//")) {
     54        where = std::find_if(where, str.end(), AlphaNum());
     55        if (where==str.end())
     56          type_.push_back(empty);
     57        else
     58          type_.push_back(comment);
     59      }
     60      else {
    4661        type_.push_back(code);
     62      }
    4763    }
    4864  }
Note: See TracChangeset for help on using the changeset viewer.