/* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2022 Mikolaj Wielgus * Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, you may find one here: * https://www.gnu.org/licenses/gpl-3.0.html * or you may search the http://www.gnu.org website for the version 3 license, * or you may write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef SPICE_GRAMMAR_H #define SPICE_GRAMMAR_H #include namespace SPICE_GRAMMAR { using namespace SIM_VALUE_GRAMMAR; struct garbage : plus> {}; struct leaders : plus> {}; struct trailers : plus> {}; // NOTE: In Ngspice, a '$' opening a comment must be preceded by ' ', ',', or '\t'. We don't // implement that here - this may cause problems in the future. // Ngspice supports '//' for comments. struct eolCommentStart : sor, string<'/', '/'>> {}; struct eolComment : seq> {}; struct commentLine : seq, one<'*'>, until> {}; struct newline : seq, not_at>> {}; struct backslashContinuation : seq, opt, eol> {}; struct commentBackslashContinuation : seq, not_at, opt, eol>, any>, string<'\\', '\\'>, opt, eol>> {}; struct plusContinuation : seq, star, opt, one<'+'>> {}; struct continuation : seq, sor, opt> {}; struct sep : sor, garbage> {}; // Ngspice has some heuristic logic to allow + and - in tokens. We mimic that here. struct tokenStart : seq>, opt>>, one<'e', 'E'>, opt>>>> {}; struct token : seq, not_at, not_one<' ', '\t', '=', '(', ')', ',', '+', '-', '*', '/', '^', ';'>>> {}; struct param : token {}; struct paramValue : token {}; struct paramValuePair : seq {}; struct paramValuePairs : seq, star> {}; struct modelName : star>> {}; /*seq>>> {};*/ /*struct dotModelType : sor {};*/ struct dotModelType : plus {}; struct dotModel : seq, TAO_PEGTL_ISTRING( ".model" ), sep, modelName, sep, dotModelType, opt, one<'('>, opt, paramValuePairs, opt, // Ngspice doesn't require the parentheses to match, though. one<')'>>, seq>>, opt, newline> {}; struct dotSubcktPinName : seq, plus, any>> {}; struct dotSubcktPinSequence : seq>> {}; struct dotSubcktEnd : seq> {}; struct spiceUnit; struct dotSubckt : seq, TAO_PEGTL_ISTRING( ".subckt" ), sep, modelName, sep, dotSubcktPinSequence, opt, opt, newline, until> {}; struct modelUnit : sor {}; struct dotTitleTitle : star, any> {}; struct dotTitle : seq, TAO_PEGTL_ISTRING( ".title" ), sep, dotTitleTitle, newline> {}; struct dotIncludePathWithoutQuotes : star> {}; struct dotIncludePathWithoutApostrophes : star> {}; struct dotIncludePath : star, any> {}; struct dotInclude : seq, TAO_PEGTL_ISTRING( ".include" ), sep, sor, dotIncludePathWithoutQuotes, one<'\"'>>, seq, dotIncludePathWithoutApostrophes, one<'\''>>, dotIncludePath>, opt, newline> {}; struct dotLine : seq, one<'.'>, until> {}; struct unknownLine : until {}; struct spiceUnit : sor {}; struct spiceUnitGrammar : must {}; struct spiceSource : star {}; struct spiceSourceGrammar : must {}; } #endif // SPICE_GRAMMAR_H