Loading pcbnew/dsn.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -588,7 +588,7 @@ DSN_T LEXER::NextTok() throw (IOError) char* cur = next; char* head = cur; lastTok = curTok; prevTok = curTok; if( curTok != T_EOF ) { Loading @@ -613,7 +613,7 @@ L_read: goto L_read; // switching the string_quote character if( lastTok == T_string_quote ) if( prevTok == T_string_quote ) { static const wxString errtxt( _("String delimiter must be a single character of ', \", or $")); Loading pcbnew/dsn.h +10 −2 Original line number Diff line number Diff line Loading @@ -527,7 +527,7 @@ class LEXER bool space_in_quoted_tokens; ///< blank spaces within quoted strings wxString filename; int lastTok; ///< curTok from previous NextTok() call. DSN_T prevTok; ///< curTok from previous NextTok() call. int curOffset; ///< offset within current line of the current token DSN_T curTok; ///< the current token obtained on last NextTok() Loading Loading @@ -640,7 +640,6 @@ public: return curText.c_str(); } /** * Function CurTok * returns whatever NextTok() returned the last time it was called. Loading @@ -650,6 +649,15 @@ public: return curTok; } /** * Function PrevTok * returns whatever NextTok() returned the 2nd to last time it was called. */ DSN_T PrevTok() { return prevTok; } /** * Function CurOffset * returns the char offset within the current line, using a 1 based index. Loading pcbnew/specctra.cpp +71 −12 Original line number Diff line number Diff line Loading @@ -539,22 +539,35 @@ public: /** * Class RULE * holds a single rule and corresponds to <rule_descriptors> * Class RULES * corresponds to the <rule_descriptor> in the specctra dsn spec. */ class RULE : public ELEM class RULES : public ELEM { friend class SPECCTRA_DB; }; STRINGS rules; ///< rules are saved in std::string form. public: /** * Class RULES * corresponds to the <rule_descriptor> in the specctra dsn spec. */ class RULES : public ELEM RULES( ELEM* aParent ) : ELEM( T_rule, aParent ) { ; } ~RULES() { } void Save( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) { out->Print( nestLevel, "(%s\n", LEXER::GetTokenText( Type() ) ); for( STRINGS::const_iterator i = rules.begin(); i!=rules.end(); ++i ) out->Print( nestLevel+1, "%s\n", i->c_str() ); out->Print( nestLevel, ")\n" ); } }; Loading Loading @@ -670,6 +683,7 @@ class STRUCTURE : public ELEM BOUNDARY* place_boundary; VIA* via; CONTROL* control; RULES* rules; typedef boost::ptr_vector<LAYER> LAYERS; LAYERS layers; Loading @@ -684,6 +698,7 @@ public: place_boundary = 0; via = 0; control = 0; rules = 0; } ~STRUCTURE() Loading @@ -693,6 +708,7 @@ public: delete place_boundary; delete via; delete control; delete rules; } void Save( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) Loading Loading @@ -722,6 +738,9 @@ public: At(i)->Save( out, nestLevel+1 ); } if( rules ) rules->Save( out, nestLevel+1 ); out->Print( nestLevel, ")\n" ); } Loading Loading @@ -910,6 +929,7 @@ class SPECCTRA_DB : public OUTPUTFORMATTER void doVIA( VIA* growth ) throw( IOError ); void doCONTROL( CONTROL* growth ) throw( IOError ); void doLAYER( LAYER* growth ) throw( IOError ); void doRULES( RULES* growth ) throw( IOError ); public: Loading Loading @@ -1339,6 +1359,11 @@ L_place: doLAYER( layer ); break; case T_rule: growth->rules = new RULES( growth ); doRULES( growth->rules ); break; default: unexpected( lexer->CurText() ); } Loading Loading @@ -1608,7 +1633,8 @@ void SPECCTRA_DB::doLAYER( LAYER* growth ) throw( IOError ) break; case T_rule: // @todo growth->rules = new RULES( growth ); doRULES( growth->rules ); break; case T_property: Loading Loading @@ -1714,6 +1740,39 @@ void SPECCTRA_DB::doLAYER( LAYER* growth ) throw( IOError ) } void SPECCTRA_DB::doRULES( RULES* growth ) throw( IOError ) { std::string builder; int bracketNesting = 1; // we already saw the opening T_LEFT while( bracketNesting != 0 ) { DSN_T tok = nextTok(); switch( tok ) { case T_LEFT: ++bracketNesting; break; case T_RIGHT: --bracketNesting; break; default: ; } if( bracketNesting >= 1 ) { if( lexer->PrevTok() != T_LEFT && tok!=T_RIGHT ) builder += ' '; builder += lexer->CurText(); } if( bracketNesting == 1 ) { growth->rules.push_back( builder ); builder.clear(); } } } void SPECCTRA_DB::Print( int nestLevel, const char* fmt, ... ) throw( IOError ) { va_list args; Loading Loading
pcbnew/dsn.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -588,7 +588,7 @@ DSN_T LEXER::NextTok() throw (IOError) char* cur = next; char* head = cur; lastTok = curTok; prevTok = curTok; if( curTok != T_EOF ) { Loading @@ -613,7 +613,7 @@ L_read: goto L_read; // switching the string_quote character if( lastTok == T_string_quote ) if( prevTok == T_string_quote ) { static const wxString errtxt( _("String delimiter must be a single character of ', \", or $")); Loading
pcbnew/dsn.h +10 −2 Original line number Diff line number Diff line Loading @@ -527,7 +527,7 @@ class LEXER bool space_in_quoted_tokens; ///< blank spaces within quoted strings wxString filename; int lastTok; ///< curTok from previous NextTok() call. DSN_T prevTok; ///< curTok from previous NextTok() call. int curOffset; ///< offset within current line of the current token DSN_T curTok; ///< the current token obtained on last NextTok() Loading Loading @@ -640,7 +640,6 @@ public: return curText.c_str(); } /** * Function CurTok * returns whatever NextTok() returned the last time it was called. Loading @@ -650,6 +649,15 @@ public: return curTok; } /** * Function PrevTok * returns whatever NextTok() returned the 2nd to last time it was called. */ DSN_T PrevTok() { return prevTok; } /** * Function CurOffset * returns the char offset within the current line, using a 1 based index. Loading
pcbnew/specctra.cpp +71 −12 Original line number Diff line number Diff line Loading @@ -539,22 +539,35 @@ public: /** * Class RULE * holds a single rule and corresponds to <rule_descriptors> * Class RULES * corresponds to the <rule_descriptor> in the specctra dsn spec. */ class RULE : public ELEM class RULES : public ELEM { friend class SPECCTRA_DB; }; STRINGS rules; ///< rules are saved in std::string form. public: /** * Class RULES * corresponds to the <rule_descriptor> in the specctra dsn spec. */ class RULES : public ELEM RULES( ELEM* aParent ) : ELEM( T_rule, aParent ) { ; } ~RULES() { } void Save( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) { out->Print( nestLevel, "(%s\n", LEXER::GetTokenText( Type() ) ); for( STRINGS::const_iterator i = rules.begin(); i!=rules.end(); ++i ) out->Print( nestLevel+1, "%s\n", i->c_str() ); out->Print( nestLevel, ")\n" ); } }; Loading Loading @@ -670,6 +683,7 @@ class STRUCTURE : public ELEM BOUNDARY* place_boundary; VIA* via; CONTROL* control; RULES* rules; typedef boost::ptr_vector<LAYER> LAYERS; LAYERS layers; Loading @@ -684,6 +698,7 @@ public: place_boundary = 0; via = 0; control = 0; rules = 0; } ~STRUCTURE() Loading @@ -693,6 +708,7 @@ public: delete place_boundary; delete via; delete control; delete rules; } void Save( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) Loading Loading @@ -722,6 +738,9 @@ public: At(i)->Save( out, nestLevel+1 ); } if( rules ) rules->Save( out, nestLevel+1 ); out->Print( nestLevel, ")\n" ); } Loading Loading @@ -910,6 +929,7 @@ class SPECCTRA_DB : public OUTPUTFORMATTER void doVIA( VIA* growth ) throw( IOError ); void doCONTROL( CONTROL* growth ) throw( IOError ); void doLAYER( LAYER* growth ) throw( IOError ); void doRULES( RULES* growth ) throw( IOError ); public: Loading Loading @@ -1339,6 +1359,11 @@ L_place: doLAYER( layer ); break; case T_rule: growth->rules = new RULES( growth ); doRULES( growth->rules ); break; default: unexpected( lexer->CurText() ); } Loading Loading @@ -1608,7 +1633,8 @@ void SPECCTRA_DB::doLAYER( LAYER* growth ) throw( IOError ) break; case T_rule: // @todo growth->rules = new RULES( growth ); doRULES( growth->rules ); break; case T_property: Loading Loading @@ -1714,6 +1740,39 @@ void SPECCTRA_DB::doLAYER( LAYER* growth ) throw( IOError ) } void SPECCTRA_DB::doRULES( RULES* growth ) throw( IOError ) { std::string builder; int bracketNesting = 1; // we already saw the opening T_LEFT while( bracketNesting != 0 ) { DSN_T tok = nextTok(); switch( tok ) { case T_LEFT: ++bracketNesting; break; case T_RIGHT: --bracketNesting; break; default: ; } if( bracketNesting >= 1 ) { if( lexer->PrevTok() != T_LEFT && tok!=T_RIGHT ) builder += ' '; builder += lexer->CurText(); } if( bracketNesting == 1 ) { growth->rules.push_back( builder ); builder.clear(); } } } void SPECCTRA_DB::Print( int nestLevel, const char* fmt, ... ) throw( IOError ) { va_list args; Loading