Loading include/dsnlexer.h +9 −9 Original line number Original line Diff line number Diff line Loading @@ -399,23 +399,23 @@ public: void Unexpected( int aTok ) throw( IO_ERROR ); void Unexpected( int aTok ) throw( IO_ERROR ); /** /** * Function Duplicate * Function Unexpected * throws an IO_ERROR exception with a message saying specifically that aTok * throws an IO_ERROR exception with an input file specific error message. * is a duplicate of one already seen in current context. * @param aToken is the token which was not expected at the * @param aTok is the token/keyword type which was not expected at the * current input location. * current input location. * @throw IO_ERROR with the location within the input file of the problem. * @throw IO_ERROR with the location within the input file of the problem. */ */ void Duplicate( int aTok ) throw( IO_ERROR ); void Unexpected( const char* aToken ) throw( IO_ERROR ); /** /** * Function Unexpected * Function Duplicate * throws an IO_ERROR exception with an input file specific error message. * throws an IO_ERROR exception with a message saying specifically that aTok * @param aToken is the token which was not expected at the * is a duplicate of one already seen in current context. * @param aTok is the token/keyword type which was not expected at the * current input location. * current input location. * @throw IO_ERROR with the location within the input file of the problem. * @throw IO_ERROR with the location within the input file of the problem. */ */ void Unexpected( const char* aToken ) throw( IO_ERROR ); void Duplicate( int aTok ) throw( IO_ERROR ); /** /** * Function NeedLEFT * Function NeedLEFT Loading new/make-dir-lib-source-test-data.sh +8 −0 Original line number Original line Diff line number Diff line Loading @@ -15,6 +15,12 @@ ARC="(arc (pos 22 33)(radius 12)(start 2 4)(end 13 33)(line_width 2.3)(fill fill BEZIER="(bezier (fill none)(line_width 2.0)(pts (xy 0 1)(xy 2 4)))" BEZIER="(bezier (fill none)(line_width 2.0)(pts (xy 0 1)(xy 2 4)))" TEXT="(text \"This is some text\" (at 23 23 90.0)(justify left bottom)(visible yes)(fill filled))" TEXT="(text \"This is some text\" (at 23 23 90.0)(justify left bottom)(visible yes)(fill filled))" PIN="(pin input line (at 7 8 90.0)(length 2)(visible YES))" # add to pin # (name NAME (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD])(visible YES)) # (number NUMBER (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD] (visible YES)) for C in ${CATEGORIES}; do for C in ${CATEGORIES}; do mkdir -p $BASEDIR/$C mkdir -p $BASEDIR/$C Loading @@ -28,6 +34,7 @@ for C in ${CATEGORIES}; do $ARC $ARC $BEZIER $BEZIER $TEXT $TEXT $PIN )" > $BASEDIR/$C/$P.part.$R )" > $BASEDIR/$C/$P.part.$R done done # also make the part without a rev: # also make the part without a rev: Loading @@ -38,6 +45,7 @@ for C in ${CATEGORIES}; do $ARC $ARC $BEZIER $BEZIER $TEXT $TEXT $PIN )" > $BASEDIR/$C/$P.part )" > $BASEDIR/$C/$P.part done done done done Loading new/sch_part.cpp +6 −2 Original line number Original line Diff line number Diff line Loading @@ -53,13 +53,17 @@ void PART::clear() extends = 0; extends = 0; } } // graphics objects I own, and the container will not destroy them: // delete graphics I own, since their container will not destroy them: for( GRAPHICS::iterator it = graphics.begin(); it != graphics.end(); ++it ) for( GRAPHICS::iterator it = graphics.begin(); it != graphics.end(); ++it ) delete *it; delete *it; graphics.clear(); graphics.clear(); // delete PINs I own, since their container will not destroy them. for( PINS::iterator it = pins.begin(); it != pins.end(); ++it ) delete *it; pins.clear(); // @todo delete all properties, pins, and graphics // @todo delete all properties } } Loading new/sch_part.h +68 −24 Original line number Original line Diff line number Diff line Loading @@ -7,10 +7,19 @@ //-----<temporary home for PART sub objects, move after stable>------------------ //-----<temporary home for PART sub objects, move after stable>------------------ typedef wxPoint POINT; #include <wx/gdicmn.h> #include <wx/gdicmn.h> #include <deque> #include <deque> #include <vector> #include <sweet_lexer.h> class POINT : public wxPoint { public: POINT( int x, int y ) : wxPoint( x, y ) {} POINT() : wxPoint() {} }; namespace SCH { namespace SCH { Loading @@ -36,7 +45,7 @@ public: typedef std::deque<POINT> POINTS; typedef std::deque<POINT> POINTS; class POLY_LINE : BASE_GRAPHIC class POLY_LINE : public BASE_GRAPHIC { { friend class PART; friend class PART; friend class SWEET_PARSER; friend class SWEET_PARSER; Loading @@ -52,7 +61,7 @@ public: {} {} }; }; class BEZIER : POLY_LINE class BEZIER : public POLY_LINE { { friend class PART; friend class PART; friend class SWEET_PARSER; friend class SWEET_PARSER; Loading @@ -63,7 +72,7 @@ public: {} {} }; }; class RECTANGLE : BASE_GRAPHIC class RECTANGLE : public BASE_GRAPHIC { { friend class PART; friend class PART; friend class SWEET_PARSER; friend class SWEET_PARSER; Loading @@ -81,16 +90,16 @@ public: }; }; class CIRCLE : BASE_GRAPHIC class CIRCLE : public BASE_GRAPHIC { { friend class PART; friend class PART; friend class SWEET_PARSER; friend class SWEET_PARSER; protected: protected: double lineWidth; int fillType; // T_none, T_filled, or T_transparent POINT center; POINT center; int radius; int radius; double lineWidth; int fillType; // T_none, T_filled, or T_transparent public: public: CIRCLE( PART* aOwner ) : CIRCLE( PART* aOwner ) : Loading @@ -99,15 +108,15 @@ public: }; }; class ARC : BASE_GRAPHIC class ARC : public BASE_GRAPHIC { { friend class PART; friend class PART; friend class SWEET_PARSER; friend class SWEET_PARSER; protected: protected: POINT pos; double lineWidth; double lineWidth; int fillType; // T_none, T_filled, or T_transparent int fillType; // T_none, T_filled, or T_transparent POINT pos; int radius; int radius; POINT start; POINT start; POINT end; POINT end; Loading @@ -119,7 +128,7 @@ public: }; }; class GR_TEXT : BASE_GRAPHIC class GR_TEXT : public BASE_GRAPHIC { { friend class PART; friend class PART; friend class SWEET_PARSER; friend class SWEET_PARSER; Loading @@ -127,24 +136,54 @@ class GR_TEXT : BASE_GRAPHIC protected: protected: POINT pos; POINT pos; float angle; float angle; int fillType; // T_none, T_filled, or T_transparent int fillType; ///< T_none, T_filled, or T_transparent int hjustify; // T_center, T_right, or T_left int hjustify; ///< T_center, T_right, or T_left int vjustify; // T_center, T_top, or T_bottom int vjustify; ///< T_center, T_top, or T_bottom bool isVisible; bool isVisible; wxString text; wxString text; // FONT font; // FONT font; public: public: GR_TEXT( PART* aOwner ) : GR_TEXT( PART* aOwner ) : BASE_GRAPHIC( aOwner ) BASE_GRAPHIC( aOwner ), /* , fillType( T_filled ), hjustify( T_left ), vjustify( T_bottom ), angle( 0 ), angle( 0 ), fillType( PR::T_filled ), hjustify( PR::T_left ), vjustify( PR::T_bottom ), isVisible( true ) {} }; class PIN : public BASE_GRAPHIC { friend class PART; friend class SWEET_PARSER; protected: POINT pos; float angle; int connectionType; ///< T_input, T_output, T_bidirectional, T_tristate, T_passive, T_unspecified, ///< T_power_in, T_power_out, T_open_collector, T_open_emitter, or T_unconnected. int shape; ///< T_none, T_line, T_inverted, T_clock, T_inverted_clk, T_input_low, T_clock_low, ///< T_falling_edge, T_non_logic. int length; ///< length of pin in internal units wxString name; wxString number; bool nameIsVisible; ///< name is visible bool numIsVisible; ///< number is visible bool isVisible; ///< pin is visible public: PIN( PART* aOwner ) : BASE_GRAPHIC( aOwner ), angle( 0 ), connectionType( PR::T_input ), shape( PR::T_line ), length( 0 ), nameIsVisible( true ), numIsVisible( true ), isVisible( true ) isVisible( true ) */ {} {} }; }; Loading @@ -156,7 +195,8 @@ public: namespace SCH { namespace SCH { typedef std::deque< BASE_GRAPHIC* > GRAPHICS; typedef std::vector< BASE_GRAPHIC* > GRAPHICS; typedef std::vector< PIN* > PINS; class LPID; class LPID; class SWEET_PARSER; class SWEET_PARSER; Loading Loading @@ -227,8 +267,12 @@ protected: // not likely to have C++ descendants, but protected none-the-le */ */ GRAPHICS graphics; GRAPHICS graphics; /// A pin list /** //PINS pins; * Member pins * owns all the PINs in pins. */ PINS pins; /// Alternate body forms. /// Alternate body forms. //ALTERNATES alternates; //ALTERNATES alternates; Loading new/sch_sweet_parser.cpp +159 −30 Original line number Original line Diff line number Diff line Loading @@ -33,17 +33,19 @@ using namespace SCH; using namespace PR; using namespace PR; #define MAX_INHERITANCE_NESTING 6 // no problem going larger #define MAX_INHERITANCE_NESTING 6 ///< max depth of inheritance, no problem going larger #define INTERNAL_PER_LOGICAL 10000 ///< no. internal units per logical unit /** /** * Function log2int * Function log2int * converts a logical coordinate to an internal coordinate. Logical coordinates * converts a logical coordinate to an internal coordinate. Logical coordinates * are defined as the standard distance between pins being equal to one. * are defined as the standard distance between pins being equal to one. * Internal coordinates are 1000 times that. * Internal coordinates are currently INTERNAL_PER_LOGICAL times that. */ */ static inline int log2int( double aCoord ) static inline int log2int( double aCoord ) { { return int( aCoord * 1000 ); return int( aCoord * INTERNAL_PER_LOGICAL ); } } static inline int internal( const STRING& aCoord ) static inline int internal( const STRING& aCoord ) Loading Loading @@ -80,7 +82,6 @@ static inline const int PB( PartBit oneBitOnly ) } } void SWEET_PARSER::parseExtends( PART* me ) void SWEET_PARSER::parseExtends( PART* me ) { { PART* base; PART* base; Loading Loading @@ -280,6 +281,13 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E NeedRIGHT(); NeedRIGHT(); break; break; case T_pin: PIN* pin; pin = new PIN( me ); me->pins.push_back( pin ); parsePin( pin ); break; /* /* case T_keywords: case T_keywords: break; break; Loading @@ -293,9 +301,6 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E case T_property_del: case T_property_del: break; break; case T_pin: break; case T_pin_merge: case T_pin_merge: break; break; Loading Loading @@ -329,6 +334,130 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E } } void SWEET_PARSER::parseBool( bool* aBool ) { T tok = NeedSYMBOL(); switch( tok ) { case T_yes: case T_no: *aBool = (tok == T_yes); break; default: Expecting( "yes|no" ); } } void SWEET_PARSER::parsePin( PIN* me ) { /* (pin TYPE SHAPE (at X Y [ANGLE]) (length LENGTH) (name NAME (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD])(visible YES)) (number NUMBER (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD] (visible YES)) (visible YES) ) */ T tok; bool sawShape = false; bool sawType = false; bool sawAt = false; bool sawLen = false; bool sawName = false; bool sawNum = false; bool sawVis = false; while( ( tok = NextTok() ) != T_RIGHT ) { if( tok == T_LEFT ) { tok = NextTok(); switch( tok ) { case T_at: if( sawAt ) Duplicate( tok ); sawAt = true; parseAt( &me->pos, &me->angle ); break; case T_length: if( sawLen ) Duplicate( tok ); sawLen = true; NeedNUMBER( "length" ); me->length = internal( CurText() ); NeedRIGHT(); break; /* @todo and associated fonts case T_name: case T_number: break; */ case T_visible: if( sawVis ) Duplicate( tok ); parseBool( &me->isVisible ); NeedRIGHT(); sawVis = true; break; default: Unexpected( tok ); } } else // not wrapped in parentheses { switch( tok ) { case T_input: case T_output: case T_bidirectional: case T_tristate: case T_passive: case T_unspecified: case T_power_in: case T_power_out: case T_open_collector: case T_open_emitter: case T_unconnected: if( sawType ) Duplicate( tok ); sawType = true; me->connectionType = tok; break; case T_none: case T_line: case T_inverted: case T_clock: case T_inverted_clk: case T_input_low: case T_clock_low: case T_falling_edge: case T_non_logic: if( sawShape ) Duplicate( tok ); sawShape = true; me->shape = tok; break; default: Unexpected( tok ); } } } } void SWEET_PARSER::parsePolyLine( POLY_LINE* me ) void SWEET_PARSER::parsePolyLine( POLY_LINE* me ) { { T tok; T tok; Loading Loading @@ -646,6 +775,27 @@ void SWEET_PARSER::parseArc( ARC* me ) } } void SWEET_PARSER::parseAt( POINT* pos, float* angle ) { T tok; NeedNUMBER( "at x" ); pos->x = internal( CurText() ); NeedNUMBER( "at y" ); pos->y = internal( CurText() ); tok = NextTok(); if( angle && tok == T_NUMBER ) { *angle = strtod( CurText(), NULL ); tok = NextTok(); } if( tok != T_RIGHT ) Expecting( T_RIGHT ); } void SWEET_PARSER::parseText( GR_TEXT* me ) void SWEET_PARSER::parseText( GR_TEXT* me ) { { T tok; T tok; Loading @@ -670,19 +820,7 @@ void SWEET_PARSER::parseText( GR_TEXT* me ) case T_at: case T_at: if( sawAt ) if( sawAt ) Duplicate( tok ); Duplicate( tok ); NeedNUMBER( "at x" ); parseAt( &me->pos, &me->angle ); me->pos.x = internal( CurText() ); NeedNUMBER( "at y" ); me->pos.y = internal( CurText() ); tok = NextTok(); if( tok == T_NUMBER ) { me->angle = strtod( CurText(), NULL ); tok = NextTok(); } if( tok != T_RIGHT ) Expecting( T_RIGHT ); sawAt = true; sawAt = true; break; break; Loading Loading @@ -737,16 +875,7 @@ void SWEET_PARSER::parseText( GR_TEXT* me ) case T_visible: case T_visible: if( sawVis ) if( sawVis ) Duplicate( tok ); Duplicate( tok ); tok = NeedSYMBOL(); parseBool( &me->isVisible ); switch( tok ) { case T_yes: case T_no: me->isVisible = (tok == T_yes); break; default: Expecting( "yes|no" ); } NeedRIGHT(); NeedRIGHT(); sawVis = true; sawVis = true; break; break; Loading Loading
include/dsnlexer.h +9 −9 Original line number Original line Diff line number Diff line Loading @@ -399,23 +399,23 @@ public: void Unexpected( int aTok ) throw( IO_ERROR ); void Unexpected( int aTok ) throw( IO_ERROR ); /** /** * Function Duplicate * Function Unexpected * throws an IO_ERROR exception with a message saying specifically that aTok * throws an IO_ERROR exception with an input file specific error message. * is a duplicate of one already seen in current context. * @param aToken is the token which was not expected at the * @param aTok is the token/keyword type which was not expected at the * current input location. * current input location. * @throw IO_ERROR with the location within the input file of the problem. * @throw IO_ERROR with the location within the input file of the problem. */ */ void Duplicate( int aTok ) throw( IO_ERROR ); void Unexpected( const char* aToken ) throw( IO_ERROR ); /** /** * Function Unexpected * Function Duplicate * throws an IO_ERROR exception with an input file specific error message. * throws an IO_ERROR exception with a message saying specifically that aTok * @param aToken is the token which was not expected at the * is a duplicate of one already seen in current context. * @param aTok is the token/keyword type which was not expected at the * current input location. * current input location. * @throw IO_ERROR with the location within the input file of the problem. * @throw IO_ERROR with the location within the input file of the problem. */ */ void Unexpected( const char* aToken ) throw( IO_ERROR ); void Duplicate( int aTok ) throw( IO_ERROR ); /** /** * Function NeedLEFT * Function NeedLEFT Loading
new/make-dir-lib-source-test-data.sh +8 −0 Original line number Original line Diff line number Diff line Loading @@ -15,6 +15,12 @@ ARC="(arc (pos 22 33)(radius 12)(start 2 4)(end 13 33)(line_width 2.3)(fill fill BEZIER="(bezier (fill none)(line_width 2.0)(pts (xy 0 1)(xy 2 4)))" BEZIER="(bezier (fill none)(line_width 2.0)(pts (xy 0 1)(xy 2 4)))" TEXT="(text \"This is some text\" (at 23 23 90.0)(justify left bottom)(visible yes)(fill filled))" TEXT="(text \"This is some text\" (at 23 23 90.0)(justify left bottom)(visible yes)(fill filled))" PIN="(pin input line (at 7 8 90.0)(length 2)(visible YES))" # add to pin # (name NAME (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD])(visible YES)) # (number NUMBER (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD] (visible YES)) for C in ${CATEGORIES}; do for C in ${CATEGORIES}; do mkdir -p $BASEDIR/$C mkdir -p $BASEDIR/$C Loading @@ -28,6 +34,7 @@ for C in ${CATEGORIES}; do $ARC $ARC $BEZIER $BEZIER $TEXT $TEXT $PIN )" > $BASEDIR/$C/$P.part.$R )" > $BASEDIR/$C/$P.part.$R done done # also make the part without a rev: # also make the part without a rev: Loading @@ -38,6 +45,7 @@ for C in ${CATEGORIES}; do $ARC $ARC $BEZIER $BEZIER $TEXT $TEXT $PIN )" > $BASEDIR/$C/$P.part )" > $BASEDIR/$C/$P.part done done done done Loading
new/sch_part.cpp +6 −2 Original line number Original line Diff line number Diff line Loading @@ -53,13 +53,17 @@ void PART::clear() extends = 0; extends = 0; } } // graphics objects I own, and the container will not destroy them: // delete graphics I own, since their container will not destroy them: for( GRAPHICS::iterator it = graphics.begin(); it != graphics.end(); ++it ) for( GRAPHICS::iterator it = graphics.begin(); it != graphics.end(); ++it ) delete *it; delete *it; graphics.clear(); graphics.clear(); // delete PINs I own, since their container will not destroy them. for( PINS::iterator it = pins.begin(); it != pins.end(); ++it ) delete *it; pins.clear(); // @todo delete all properties, pins, and graphics // @todo delete all properties } } Loading
new/sch_part.h +68 −24 Original line number Original line Diff line number Diff line Loading @@ -7,10 +7,19 @@ //-----<temporary home for PART sub objects, move after stable>------------------ //-----<temporary home for PART sub objects, move after stable>------------------ typedef wxPoint POINT; #include <wx/gdicmn.h> #include <wx/gdicmn.h> #include <deque> #include <deque> #include <vector> #include <sweet_lexer.h> class POINT : public wxPoint { public: POINT( int x, int y ) : wxPoint( x, y ) {} POINT() : wxPoint() {} }; namespace SCH { namespace SCH { Loading @@ -36,7 +45,7 @@ public: typedef std::deque<POINT> POINTS; typedef std::deque<POINT> POINTS; class POLY_LINE : BASE_GRAPHIC class POLY_LINE : public BASE_GRAPHIC { { friend class PART; friend class PART; friend class SWEET_PARSER; friend class SWEET_PARSER; Loading @@ -52,7 +61,7 @@ public: {} {} }; }; class BEZIER : POLY_LINE class BEZIER : public POLY_LINE { { friend class PART; friend class PART; friend class SWEET_PARSER; friend class SWEET_PARSER; Loading @@ -63,7 +72,7 @@ public: {} {} }; }; class RECTANGLE : BASE_GRAPHIC class RECTANGLE : public BASE_GRAPHIC { { friend class PART; friend class PART; friend class SWEET_PARSER; friend class SWEET_PARSER; Loading @@ -81,16 +90,16 @@ public: }; }; class CIRCLE : BASE_GRAPHIC class CIRCLE : public BASE_GRAPHIC { { friend class PART; friend class PART; friend class SWEET_PARSER; friend class SWEET_PARSER; protected: protected: double lineWidth; int fillType; // T_none, T_filled, or T_transparent POINT center; POINT center; int radius; int radius; double lineWidth; int fillType; // T_none, T_filled, or T_transparent public: public: CIRCLE( PART* aOwner ) : CIRCLE( PART* aOwner ) : Loading @@ -99,15 +108,15 @@ public: }; }; class ARC : BASE_GRAPHIC class ARC : public BASE_GRAPHIC { { friend class PART; friend class PART; friend class SWEET_PARSER; friend class SWEET_PARSER; protected: protected: POINT pos; double lineWidth; double lineWidth; int fillType; // T_none, T_filled, or T_transparent int fillType; // T_none, T_filled, or T_transparent POINT pos; int radius; int radius; POINT start; POINT start; POINT end; POINT end; Loading @@ -119,7 +128,7 @@ public: }; }; class GR_TEXT : BASE_GRAPHIC class GR_TEXT : public BASE_GRAPHIC { { friend class PART; friend class PART; friend class SWEET_PARSER; friend class SWEET_PARSER; Loading @@ -127,24 +136,54 @@ class GR_TEXT : BASE_GRAPHIC protected: protected: POINT pos; POINT pos; float angle; float angle; int fillType; // T_none, T_filled, or T_transparent int fillType; ///< T_none, T_filled, or T_transparent int hjustify; // T_center, T_right, or T_left int hjustify; ///< T_center, T_right, or T_left int vjustify; // T_center, T_top, or T_bottom int vjustify; ///< T_center, T_top, or T_bottom bool isVisible; bool isVisible; wxString text; wxString text; // FONT font; // FONT font; public: public: GR_TEXT( PART* aOwner ) : GR_TEXT( PART* aOwner ) : BASE_GRAPHIC( aOwner ) BASE_GRAPHIC( aOwner ), /* , fillType( T_filled ), hjustify( T_left ), vjustify( T_bottom ), angle( 0 ), angle( 0 ), fillType( PR::T_filled ), hjustify( PR::T_left ), vjustify( PR::T_bottom ), isVisible( true ) {} }; class PIN : public BASE_GRAPHIC { friend class PART; friend class SWEET_PARSER; protected: POINT pos; float angle; int connectionType; ///< T_input, T_output, T_bidirectional, T_tristate, T_passive, T_unspecified, ///< T_power_in, T_power_out, T_open_collector, T_open_emitter, or T_unconnected. int shape; ///< T_none, T_line, T_inverted, T_clock, T_inverted_clk, T_input_low, T_clock_low, ///< T_falling_edge, T_non_logic. int length; ///< length of pin in internal units wxString name; wxString number; bool nameIsVisible; ///< name is visible bool numIsVisible; ///< number is visible bool isVisible; ///< pin is visible public: PIN( PART* aOwner ) : BASE_GRAPHIC( aOwner ), angle( 0 ), connectionType( PR::T_input ), shape( PR::T_line ), length( 0 ), nameIsVisible( true ), numIsVisible( true ), isVisible( true ) isVisible( true ) */ {} {} }; }; Loading @@ -156,7 +195,8 @@ public: namespace SCH { namespace SCH { typedef std::deque< BASE_GRAPHIC* > GRAPHICS; typedef std::vector< BASE_GRAPHIC* > GRAPHICS; typedef std::vector< PIN* > PINS; class LPID; class LPID; class SWEET_PARSER; class SWEET_PARSER; Loading Loading @@ -227,8 +267,12 @@ protected: // not likely to have C++ descendants, but protected none-the-le */ */ GRAPHICS graphics; GRAPHICS graphics; /// A pin list /** //PINS pins; * Member pins * owns all the PINs in pins. */ PINS pins; /// Alternate body forms. /// Alternate body forms. //ALTERNATES alternates; //ALTERNATES alternates; Loading
new/sch_sweet_parser.cpp +159 −30 Original line number Original line Diff line number Diff line Loading @@ -33,17 +33,19 @@ using namespace SCH; using namespace PR; using namespace PR; #define MAX_INHERITANCE_NESTING 6 // no problem going larger #define MAX_INHERITANCE_NESTING 6 ///< max depth of inheritance, no problem going larger #define INTERNAL_PER_LOGICAL 10000 ///< no. internal units per logical unit /** /** * Function log2int * Function log2int * converts a logical coordinate to an internal coordinate. Logical coordinates * converts a logical coordinate to an internal coordinate. Logical coordinates * are defined as the standard distance between pins being equal to one. * are defined as the standard distance between pins being equal to one. * Internal coordinates are 1000 times that. * Internal coordinates are currently INTERNAL_PER_LOGICAL times that. */ */ static inline int log2int( double aCoord ) static inline int log2int( double aCoord ) { { return int( aCoord * 1000 ); return int( aCoord * INTERNAL_PER_LOGICAL ); } } static inline int internal( const STRING& aCoord ) static inline int internal( const STRING& aCoord ) Loading Loading @@ -80,7 +82,6 @@ static inline const int PB( PartBit oneBitOnly ) } } void SWEET_PARSER::parseExtends( PART* me ) void SWEET_PARSER::parseExtends( PART* me ) { { PART* base; PART* base; Loading Loading @@ -280,6 +281,13 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E NeedRIGHT(); NeedRIGHT(); break; break; case T_pin: PIN* pin; pin = new PIN( me ); me->pins.push_back( pin ); parsePin( pin ); break; /* /* case T_keywords: case T_keywords: break; break; Loading @@ -293,9 +301,6 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E case T_property_del: case T_property_del: break; break; case T_pin: break; case T_pin_merge: case T_pin_merge: break; break; Loading Loading @@ -329,6 +334,130 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E } } void SWEET_PARSER::parseBool( bool* aBool ) { T tok = NeedSYMBOL(); switch( tok ) { case T_yes: case T_no: *aBool = (tok == T_yes); break; default: Expecting( "yes|no" ); } } void SWEET_PARSER::parsePin( PIN* me ) { /* (pin TYPE SHAPE (at X Y [ANGLE]) (length LENGTH) (name NAME (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD])(visible YES)) (number NUMBER (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD] (visible YES)) (visible YES) ) */ T tok; bool sawShape = false; bool sawType = false; bool sawAt = false; bool sawLen = false; bool sawName = false; bool sawNum = false; bool sawVis = false; while( ( tok = NextTok() ) != T_RIGHT ) { if( tok == T_LEFT ) { tok = NextTok(); switch( tok ) { case T_at: if( sawAt ) Duplicate( tok ); sawAt = true; parseAt( &me->pos, &me->angle ); break; case T_length: if( sawLen ) Duplicate( tok ); sawLen = true; NeedNUMBER( "length" ); me->length = internal( CurText() ); NeedRIGHT(); break; /* @todo and associated fonts case T_name: case T_number: break; */ case T_visible: if( sawVis ) Duplicate( tok ); parseBool( &me->isVisible ); NeedRIGHT(); sawVis = true; break; default: Unexpected( tok ); } } else // not wrapped in parentheses { switch( tok ) { case T_input: case T_output: case T_bidirectional: case T_tristate: case T_passive: case T_unspecified: case T_power_in: case T_power_out: case T_open_collector: case T_open_emitter: case T_unconnected: if( sawType ) Duplicate( tok ); sawType = true; me->connectionType = tok; break; case T_none: case T_line: case T_inverted: case T_clock: case T_inverted_clk: case T_input_low: case T_clock_low: case T_falling_edge: case T_non_logic: if( sawShape ) Duplicate( tok ); sawShape = true; me->shape = tok; break; default: Unexpected( tok ); } } } } void SWEET_PARSER::parsePolyLine( POLY_LINE* me ) void SWEET_PARSER::parsePolyLine( POLY_LINE* me ) { { T tok; T tok; Loading Loading @@ -646,6 +775,27 @@ void SWEET_PARSER::parseArc( ARC* me ) } } void SWEET_PARSER::parseAt( POINT* pos, float* angle ) { T tok; NeedNUMBER( "at x" ); pos->x = internal( CurText() ); NeedNUMBER( "at y" ); pos->y = internal( CurText() ); tok = NextTok(); if( angle && tok == T_NUMBER ) { *angle = strtod( CurText(), NULL ); tok = NextTok(); } if( tok != T_RIGHT ) Expecting( T_RIGHT ); } void SWEET_PARSER::parseText( GR_TEXT* me ) void SWEET_PARSER::parseText( GR_TEXT* me ) { { T tok; T tok; Loading @@ -670,19 +820,7 @@ void SWEET_PARSER::parseText( GR_TEXT* me ) case T_at: case T_at: if( sawAt ) if( sawAt ) Duplicate( tok ); Duplicate( tok ); NeedNUMBER( "at x" ); parseAt( &me->pos, &me->angle ); me->pos.x = internal( CurText() ); NeedNUMBER( "at y" ); me->pos.y = internal( CurText() ); tok = NextTok(); if( tok == T_NUMBER ) { me->angle = strtod( CurText(), NULL ); tok = NextTok(); } if( tok != T_RIGHT ) Expecting( T_RIGHT ); sawAt = true; sawAt = true; break; break; Loading Loading @@ -737,16 +875,7 @@ void SWEET_PARSER::parseText( GR_TEXT* me ) case T_visible: case T_visible: if( sawVis ) if( sawVis ) Duplicate( tok ); Duplicate( tok ); tok = NeedSYMBOL(); parseBool( &me->isVisible ); switch( tok ) { case T_yes: case T_no: me->isVisible = (tok == T_yes); break; default: Expecting( "yes|no" ); } NeedRIGHT(); NeedRIGHT(); sawVis = true; sawVis = true; break; break; Loading