coan  6.0.1
A C/C++ Configuration Analyzer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
formal_parameter_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 "formal_parameter_list.h"
35 #include "canonical.h"
36 #include "parse_buffer.h"
37 
42 using namespace std;
43 
44 template<class CharSeq>
46 {
48  if (*chew == '(') {
49  unique_ptr<vector<string>> params(new vector<string>);
50  chew(+1,greyspace);
51  string param;
52  for ( ; chew; chew(+1,greyspace)) {
53  param = canonical<symbol>(chew);
54  chew(greyspace);
55  if (param.empty()) {
56  if (*chew == '.') {
57  chew(+1,continuation);
58  if (*chew != '.') {
60  break;
61  }
62  chew(+1,continuation);
63  if (*chew != '.') {
65  break;
66  }
67  _variadic = true;
68  param = "...";
69  chew(+1,continuation);
70  } else if (*chew == ')') {
71  break;
72  } else {
74  }
75  }
76  if (*chew == ',') {
77  if (_variadic) {
79  }
80  else {
81  params->push_back(param);
82  if (param.empty()) {
84  } else {
85  param.clear();
86  }
87  }
88  } else if (*chew == ')') {
89  if (param.empty()) {
90  if (params->size()) {
92  }
93  } else {
94  params->push_back(param);
95  param.clear();
96  }
97  break;
98  }
99  }
100  if (!param.empty()) {
101  params->push_back(param);
102  }
103  if (!chew || *chew != ')') {
105  } else {
106  ++chew;
107  }
108  if (params->size()) {
109  _params.reset(params.release());
110  }
111  return;
112  }
113  _params.reset();
114 }
115 
116 template
118 template
120 
121 // EOF
122 
Non-identifier where parameter expected.
void read(chewer< CharSeq > &chew)
Read the formal_parameter_list from a chewer<CharSeq>
chew_mode::continuation const continuation
An exemplar chew_mode::continuation
Definition: chew.h:213
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