1 /*$Id: ap_skip.cc,v 1.1 2009-10-23 12:01:44 felix Exp $ -*- C++ -*-
2 * Copyright (C) 2001 Albert Davis
3 * Author: Albert Davis <aldavis@gnu.org>
5 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 *------------------------------------------------------------------
22 * collection of functions to skip input
23 * all except skip1 skip leading whitespace, skip whatever is being skipped,
24 * then skip trailing whitespace.
26 //testing=script 2006.07.17
28 /*--------------------------------------------------------------------------*/
29 /* skipbl: skip whitespace. (any non-graphic character is ws)
31 * update string pointer
32 * pointer points to first non-space
33 * does NOT update _ok flag
37 while (peek() && (!isgraph(peek()))) {
42 /*--------------------------------------------------------------------------*/
43 /* skip1b: skip 1 matching character and surrounding blanks
46 CS
& CS::skip1b(char t
)
53 /*--------------------------------------------------------------------------*/
54 /* skip1: skip 1 character matching any in t
67 /*--------------------------------------------------------------------------*/
68 /* skip1b: skip 1 matching character and surrounding blanks
71 CS
& CS::skip1b(const std::string
& t
)
78 /*--------------------------------------------------------------------------*/
79 /* skip1: skip 1 character matching any in t
82 CS
& CS::skip1(const std::string
& t
)
92 /*--------------------------------------------------------------------------*/
93 /* skiparg: skip an argument (maybe just a comma)
94 * _ok = skipped something
98 unsigned here
= cursor();
104 while (is_alpha() || is_float() || is_argsym()) {
109 // empty field, just a comma
111 _ok
= cursor() > here
;
114 /*--------------------------------------------------------------------------*/
115 /* skipto: skip to a character (one of ...)
116 * _ok = skipped something
118 CS
& CS::skipto1(const std::string
& t
)
120 unsigned here
= cursor();
121 while (ns_more() && !match1(t
)) {untested();
125 if (!_ok
) {untested();
131 /*--------------------------------------------------------------------------*/
132 /* skipto: skip to a character (explicit)
133 * _ok = skipped something
135 CS
& CS::skipto1(char c
)
137 unsigned here
= cursor();
138 while (ns_more() && !match1(c
)) {
142 if (!_ok
) {untested();
148 /*--------------------------------------------------------------------------*/
149 /*--------------------------------------------------------------------------*/
150 // vim:ts=8:sw=2:noet: