diff --git a/eeschema/netlist_exporters/netlist_exporter_spice.cpp b/eeschema/netlist_exporters/netlist_exporter_spice.cpp index 43b813198e..c170d76790 100644 --- a/eeschema/netlist_exporters/netlist_exporter_spice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_spice.cpp @@ -198,7 +198,7 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives( unsigned aNetlistOptions ) else continue; - tao::pegtl::string_input<> in( ( text + "\n" ).ToUTF8(), "from_content" ); + tao::pegtl::string_input<> in( text.ToUTF8(), "from_content" ); std::unique_ptr root; try diff --git a/eeschema/sim/sim_library_spice.cpp b/eeschema/sim/sim_library_spice.cpp index 0cbeb855fc..c5248bb634 100644 --- a/eeschema/sim/sim_library_spice.cpp +++ b/eeschema/sim/sim_library_spice.cpp @@ -36,7 +36,7 @@ namespace SIM_LIBRARY_SPICE_PARSER // TODO: unknownLine is already handled in spiceUnit. struct library : spiceSource {}; - struct libraryGrammar : must {}; + struct libraryGrammar : must {}; template struct librarySelector : std::false_type {}; diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index a91cba272f..84c66afbd6 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -886,9 +886,9 @@ void SIM_MODEL::ReadSpiceCode( const wxString& aSpiceCode ) if( !SetParamFromSpiceCode( paramName, subnode->string() ) ) { THROW_IO_ERROR( wxString::Format( - _( "Failed to set parameter '%s' to '%s'" ), - paramName, - subnode->string() ) ); + _( "Failed to set parameter '%s' to '%s'" ), + paramName, + subnode->string() ) ); } } else diff --git a/eeschema/sim/spice_grammar.h b/eeschema/sim/spice_grammar.h index 805bcc583d..0bc4b0af58 100644 --- a/eeschema/sim/spice_grammar.h +++ b/eeschema/sim/spice_grammar.h @@ -40,39 +40,39 @@ namespace SPICE_GRAMMAR // 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, + struct eolfCommentStart : sor, string<'/', '/'>> {}; - struct eolComment : seq> {}; + struct eolfComment : seq> {}; struct commentLine : seq, one<'*'>, - until> {}; + until> {}; - struct newline : seq, + struct newline : seq, not_at>> {}; struct backslashContinuation : seq, opt, - eol> {}; + eolf> {}; - struct commentBackslashContinuation : seq, + struct commentBackslashContinuation : seq, not_at, opt, - eol>, + eolf>, any>, string<'\\', '\\'>, opt, - eol>> {}; + eolf>> {}; - struct plusContinuation : seq, + struct plusContinuation : seq, star, opt, one<'+'>> {}; @@ -96,7 +96,7 @@ namespace SPICE_GRAMMAR opt>>>> {}; struct token : seq, + star, not_at, not_one<' ', '\t', '=', '(', ')', ',', '+', '-', '*', '/', '^', ';'>>> {}; @@ -111,8 +111,9 @@ namespace SPICE_GRAMMAR struct paramValuePairs : seq, star> {}; - struct modelName : star>> {}; + struct modelName : plus, any> {}; + /*sor>> {};*/ /*seq>>> {};*/ @@ -175,7 +176,8 @@ namespace SPICE_GRAMMAR dotSubcktParams>, opt, newline, - until> {}; + until> {}; struct modelUnit : sor, until> {}; - struct unknownLine : until {}; + struct unknownLine : seq, any>, until> {}; struct spiceUnit : sor {}; - struct spiceUnitGrammar : must {}; + struct spiceUnitGrammar : must {}; struct spiceSource : star {}; - struct spiceSourceGrammar : must {}; + struct spiceSourceGrammar : must {}; } #endif // SPICE_GRAMMAR_H diff --git a/qa/data/eeschema/spice_netlists/libraries/diodes.lib.spice b/qa/data/eeschema/spice_netlists/libraries/diodes.lib.spice index 07ccd13da8..ec9d2598d8 100644 --- a/qa/data/eeschema/spice_netlists/libraries/diodes.lib.spice +++ b/qa/data/eeschema/spice_netlists/libraries/diodes.lib.spice @@ -99,7 +99,8 @@ + N = 6.6G ; * All valid combinations of + - signs. -.model D18 D +* Non-alphanumeric characters in model name. +.model D<>/?:\|[]!@#$%^&-_18 D + N -1.1, MJ +2.2, JS -3.3e-3, IBV +4.4e+4, CJ0 5.5e-5, BV 6.6e+6 * Multiple empty-line continuations. diff --git a/qa/unittests/eeschema/sim/test_library_spice.cpp b/qa/unittests/eeschema/sim/test_library_spice.cpp index 2909ea9bac..4c54b078af 100644 --- a/qa/unittests/eeschema/sim/test_library_spice.cpp +++ b/qa/unittests/eeschema/sim/test_library_spice.cpp @@ -203,7 +203,7 @@ BOOST_AUTO_TEST_CASE( Diodes ) break; case 18: - BOOST_CHECK_EQUAL( modelName, "D18" ); + BOOST_CHECK_EQUAL( modelName, "D<>/?:\\|[]!@#$%^&-_18" ); BOOST_CHECK_EQUAL( model.FindParam( "n" )->value->ToString(), "-1.1" ); BOOST_CHECK_EQUAL( model.FindParam( "m_" )->value->ToString(), "2.2" ); BOOST_CHECK_EQUAL( model.FindParam( "is" )->value->ToString(), "-3.3m" );