25#ifndef SPICE_GRAMMAR_H
26#define SPICE_GRAMMAR_H
36 struct garbage : plus<one<' ', '\t', '=', '(', ')', ','>> {};
38 struct trailers : plus<one<' ', '\t', '\v', '\f'>> {};
66 seq<star<not_at<eolf>,
67 not_at<string<'\\', '\\'>,
83 sor<backslashContinuation,
84 commentBackslashContinuation,
90 struct sep : sor<plus<continuation>,
93 struct modelName : plus<not_at<garbageOrEolf>, any> {};
96 seq<TAO_PEGTL_ISTRING( "vdmos" ),
98 sor<TAO_PEGTL_ISTRING( "nchan" ),
99 TAO_PEGTL_ISTRING( "pchan" )>>,
100 plus<not_at<garbageOrEolf>, any>> {};
113 opt<seq<star<sor<tao::pegtl::digit,
116 opt<one<'+', '-'>>>>> {};
120 not_at<backslashContinuation>,
121 not_one<' ', '\t', '=', '(', ')', ',', ';'>>> {};
136 if_must<seq<TAO_PEGTL_ISTRING( ".model" ),
140 TAO_PEGTL_ISTRING( "ako:" )>,
151 if_must<TAO_PEGTL_ISTRING( ".model" ),
167 opt<plusContinuation>,
169 opt<plusContinuation>,
175 dotSubcktParamValuePairs> {};
177 plus<not_at<space>, any>> {};
183 if_must<TAO_PEGTL_ISTRING( ".subckt" ),
187 dotSubcktPinSequence>,
203 TAO_PEGTL_ISTRING( ".control" ),
204 until<TAO_PEGTL_ISTRING( ".endc" )>,
211 TAO_PEGTL_ISTRING( ".title" ),
222 TAO_PEGTL_ISTRING( ".inc" ),
223 star<not_at<garbageOrEolf>, any>,
226 dotIncludePathWithoutQuotes,
229 dotIncludePathWithoutApostrophes,
271 template <
typename>
inline constexpr const char*
errorMessage =
nullptr;
275 "expected token separator (one or more whitespace, parenthesis, '=', ',', or line continuation)";
276 template <>
inline constexpr auto errorMessage<opt<sep>> =
279 "expected model name";
281 "expected model type";
282 template <>
inline constexpr auto errorMessage<opt<sep, dotModelType>> =
284 template <>
inline constexpr auto errorMessage<opt<sep, paramValuePairs>> =
286 template <>
inline constexpr auto errorMessage<opt<sep, dotSubcktPinSequence>> =
288 template <>
inline constexpr auto errorMessage<opt<sep, dotSubcktParams>> =
290 template <>
inline constexpr auto errorMessage<until<dotSubcktEnd, spiceUnit>> =
291 "expected (possibly empty) sequence of Spice lines followed by an .ends line";
293 "expected Spice directive, item, subcircuit definitions, or empty or commented-out line";
295 "expected zero or more Spice directives, items, subcircuit definitions, or empty or commented-out lines";
301 template <
typename Rule>
static constexpr auto message = errorMessage<Rule>;
304 template <
typename Rule>
using control = must_if<error>::control<Rule>;
constexpr auto errorMessage< dotModelType >
constexpr auto errorMessage< spiceUnit >
constexpr auto errorMessage< sep >
constexpr auto errorMessage< spiceSource >
must_if< error >::control< Rule > control
constexpr auto errorMessage< modelName >
constexpr auto errorMessage< newline >
constexpr const char * errorMessage
static constexpr auto message
static constexpr bool raise_on_failure