coan  6.0.1
A C/C++ Configuration Analyzer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
argument_list.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2007-2013 Mike Kinghan, imk@burroingroingjoing.com *
3  * All rights reserved. *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions *
7  * are met: *
8  * *
9  * Redistributions of source code must retain the above copyright *
10  * notice, this list of conditions and the following disclaimer. *
11  * *
12  * Redistributions in binary form must reproduce the above copyright *
13  * notice, this list of conditions and the following disclaimer in the *
14  * documentation and/or other materials provided with the distribution. *
15  * *
16  * Neither the name of Mike Kinghan nor the names of its contributors *
17  * may be used to endorse or promote products derived from this software *
18  * without specific prior written permission. *
19  * *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
24  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS *
27  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED *
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,*
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF *
30  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
31  * DAMAGE. *
32  * *
33  **************************************************************************/
34 #include "argument_list.h"
35 #include "canonical.h"
36 #include "parse_buffer.h"
37 
42 using namespace std;
43 
44 template<class CharSeq>
46 {
47  _defect = argument_list::none;
48  if (*chew == '(') {
49  unique_ptr<vector<string>> args(new vector<string>) ;
50  chew(+1,greyspace);
51  string arg;
52  while (chew) {
53  arg = canonical<macro_argument>(chew);
54  if (*chew == ',') {
55  args->push_back(arg);
56  if (arg.empty()) {
58  }
59  arg.clear();
60  ++chew;
61  } else if (*chew == ')') {
62  if (arg.empty()) {
63  if (args->size()) {
65  }
66  } else {
67  args->push_back(arg);
68  arg.clear();
69  }
70  break;
71  }
72  }
73  if (!arg.empty()) {
74  args->push_back(arg);
75  }
76  if (!chew || *chew != ')') {
77  _defect = argument_list::unclosed;
78  } else {
79  ++chew;
80  }
81  if (args->size()) {
82  _params.reset(args.release());
83  _expand_flags.reset(new vector<bool>(_params->size(),false));
84  }
85  return;
86  }
87  _params.reset();
88  _expand_flags.reset();
89 }
90 
91 template
93 template
95 
96 // EOF
void read(chewer< CharSeq > &chew)
Read the argument_list from a chewer<CharSeq>
chew_mode::greyspace const greyspace
An exemplar chew_mode::greyspace
Definition: chew.h:211
`template struct chewer<CharSeq> is a cursor-like type that is associated with a character-sequence t...
Definition: chew.h:248
template class canonical<What> encapsulates the canonical representation of values of type What...
Definition: canonical.h:82