Loading new/sch_part.h +32 −4 Original line number Diff line number Diff line Loading @@ -13,19 +13,46 @@ #include <sweet_lexer.h> namespace SCH { class PART; class SWEET_PARSER; }; class POINT : public wxPoint { public: POINT( int x, int y ) : wxPoint( x, y ) {} POINT() : wxPoint() {} POINT( int x, int y ) : wxPoint( x, y ) {} POINT() : wxPoint() {} }; namespace SCH { class PART; class SWEET_PARSER; class GR_FONT { friend class PART; friend class SWEET_PARSER; protected: wxString name; ///< name or other id such as number, TBD wxSize size; bool italic; bool bold; public: GR_FONT() : italic( false ), bold( false ) {} }; class BASE_GRAPHIC { Loading Loading @@ -187,6 +214,7 @@ public: {} }; } // namespace SCH Loading new/sch_sweet_parser.cpp +138 −19 Original line number Diff line number Diff line Loading @@ -148,7 +148,6 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E // Caller may not have read the first two tokens out of the // stream: T_LEFT and T_part, so ignore them if seen here. // The 1st two tokens T_LEFT and T_part are then optional in the grammar. if( (tok = NextTok() ) == T_LEFT ) { if( ( tok = NextTok() ) != T_part ) Loading @@ -163,7 +162,7 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E Expecting( T_part ); #endif NeedSYMBOLorNUMBER(); // read in part NAME_HINT, and toss NeedSYMBOLorNUMBER(); // toss NAME_HINT tok = NextTok(); // extends must be _first_ thing, if it is present at all, after NAME_HINT Loading Loading @@ -334,6 +333,77 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E } void SWEET_PARSER::parseFont( GR_FONT* me ) { /* # The FONT value needs to be defined. Currently, EESchema does not support # different fonts. In the future this feature may be implemented and at # that time FONT will have to be defined. Initially, only the font size and # style are required. Italic and bold styles are optional. The font size # height and width are in units yet to be determined. (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD]) */ // handle the [FONT] position dependently, i.e. first T tok = NextTok(); bool sawBold = false; bool sawItalic = false; bool sawSize = false; if( IsSymbol( tok ) ) { me->name = FromUTF8(); tok = NextTok(); } while( tok != T_RIGHT ) { if( tok == T_LEFT ) { tok = NextTok(); if( tok != T_size ) Expecting( T_size ); if( sawSize ) Duplicate( T_size ); sawSize = true; NeedNUMBER( "size height" ); me->size.SetHeight( internal( CurText() ) ); NeedNUMBER( "size width" ); me->size.SetWidth( internal( CurText() ) ); NeedRIGHT(); } else { if( tok == T_bold ) { if( sawBold ) Duplicate( T_bold ); sawBold = true; me->bold = true; } else if( tok == T_italic ) { if( sawItalic ) Duplicate( T_italic ); sawItalic = true; me->italic = true; } else Unexpected( tok ); } tok = NextTok(); } } void SWEET_PARSER::parseBool( bool* aBool ) { T tok = NeedSYMBOL(); Loading Loading @@ -460,15 +530,28 @@ void SWEET_PARSER::parsePin( PIN* me ) void SWEET_PARSER::parsePolyLine( POLY_LINE* me ) { /* (polyline|line (pts (xy X Y) (xy X Y) (xy X Y) (xy X Y) (xy X Y)) # Line widths are in units as defined above. (line_width WIDTH) # Valid fill types are none, filled, and transparent. (fill FILL_TYPE) ) */ T tok; int count = 0; bool sawWidth = false; bool sawFill = false; NeedLEFT(); while( ( tok = NextTok() ) != T_RIGHT ) { if( tok == T_LEFT ) if( tok != T_LEFT ) Expecting( T_LEFT ); tok = NextTok(); switch( tok ) Loading Loading @@ -541,16 +624,21 @@ void SWEET_PARSER::parseBezier( BEZIER* me ) void SWEET_PARSER::parseRectangle( RECTANGLE* me ) { /* (rectangle (start X Y) (end X Y) (line_width WIDTH) (fill FILL_TYPE)) */ T tok; bool sawStart = false; bool sawEnd = false; bool sawWidth = false; bool sawFill = false; NeedLEFT(); while( ( tok = NextTok() ) != T_RIGHT ) { if( tok == T_LEFT ) if( tok != T_LEFT ) Expecting( T_LEFT ); tok = NextTok(); switch( tok ) Loading Loading @@ -613,16 +701,26 @@ void SWEET_PARSER::parseRectangle( RECTANGLE* me ) void SWEET_PARSER::parseCircle( CIRCLE* me ) { /* (circle (center X Y) # Radius length is in units if defined or mils. (radius LENGTH) (line_width WIDTH) (fill FILL_TYPE) ) */ T tok; bool sawCenter = false; bool sawRadius = false; bool sawWidth = false; bool sawFill = false; NeedLEFT(); while( ( tok = NextTok() ) != T_RIGHT ) { if( tok == T_LEFT ) if( tok != T_LEFT ) Expecting( T_LEFT ); tok = NextTok(); switch( tok ) Loading Loading @@ -683,6 +781,13 @@ void SWEET_PARSER::parseCircle( CIRCLE* me ) void SWEET_PARSER::parseArc( ARC* me ) { /* (arc (pos X Y) (radius RADIUS) (start X Y) (end X Y) (line_width WIDTH) (fill FILL_TYPE) ) */ T tok; bool sawPos = false; bool sawStart = false; Loading @@ -691,10 +796,11 @@ void SWEET_PARSER::parseArc( ARC* me ) bool sawWidth = false; bool sawFill = false; NeedLEFT(); while( ( tok = NextTok() ) != T_RIGHT ) { if( tok == T_LEFT ) if( tok != T_LEFT ) Expecting( T_LEFT ); tok = NextTok(); switch( tok ) Loading Loading @@ -798,6 +904,19 @@ void SWEET_PARSER::parseAt( POINT* pos, float* angle ) void SWEET_PARSER::parseText( GR_TEXT* me ) { /* (text "This is the text that gets drawn." (at X Y [ANGLE]) # Valid horizontal justification values are center, right, and left. Valid # vertical justification values are center, top, bottom. (justify HORIZONTAL_JUSTIFY VERTICAL_JUSTIFY) (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD]) (visible YES) (fill FILL_TYPE) ) */ T tok; bool sawAt = false; bool sawFill = false; Loading @@ -808,11 +927,11 @@ void SWEET_PARSER::parseText( GR_TEXT* me ) NeedSYMBOLorNUMBER(); me->text = FROM_UTF8( CurText() ); NeedLEFT(); while( ( tok = NextTok() ) != T_RIGHT ) { if( tok == T_LEFT ) if( tok != T_LEFT ) Expecting( T_LEFT ); tok = NextTok(); switch( tok ) Loading new/sch_sweet_parser.h +3 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ namespace SCH { class LIB_TABLE; class PART; // GRAPHICS class POLY_LINE; class RECTANGLE; Loading @@ -43,6 +44,7 @@ class ARC; class BEZIER; class GR_TEXT; class PIN; class GR_FONT; /** Loading Loading @@ -71,6 +73,7 @@ class SWEET_PARSER : public SWEET_LEXER void parsePin( PIN* me ); void parseAt( POINT* pos, float* angle ); void parseBool( bool* aBool ); void parseFont( GR_FONT* me ); public: Loading new/sweet.keywords +2 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ arc at bezier bidirectional bold bottom center circle Loading @@ -23,6 +24,7 @@ input input_low inverted inverted_clk italic justify keywords left Loading Loading
new/sch_part.h +32 −4 Original line number Diff line number Diff line Loading @@ -13,19 +13,46 @@ #include <sweet_lexer.h> namespace SCH { class PART; class SWEET_PARSER; }; class POINT : public wxPoint { public: POINT( int x, int y ) : wxPoint( x, y ) {} POINT() : wxPoint() {} POINT( int x, int y ) : wxPoint( x, y ) {} POINT() : wxPoint() {} }; namespace SCH { class PART; class SWEET_PARSER; class GR_FONT { friend class PART; friend class SWEET_PARSER; protected: wxString name; ///< name or other id such as number, TBD wxSize size; bool italic; bool bold; public: GR_FONT() : italic( false ), bold( false ) {} }; class BASE_GRAPHIC { Loading Loading @@ -187,6 +214,7 @@ public: {} }; } // namespace SCH Loading
new/sch_sweet_parser.cpp +138 −19 Original line number Diff line number Diff line Loading @@ -148,7 +148,6 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E // Caller may not have read the first two tokens out of the // stream: T_LEFT and T_part, so ignore them if seen here. // The 1st two tokens T_LEFT and T_part are then optional in the grammar. if( (tok = NextTok() ) == T_LEFT ) { if( ( tok = NextTok() ) != T_part ) Loading @@ -163,7 +162,7 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E Expecting( T_part ); #endif NeedSYMBOLorNUMBER(); // read in part NAME_HINT, and toss NeedSYMBOLorNUMBER(); // toss NAME_HINT tok = NextTok(); // extends must be _first_ thing, if it is present at all, after NAME_HINT Loading Loading @@ -334,6 +333,77 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E } void SWEET_PARSER::parseFont( GR_FONT* me ) { /* # The FONT value needs to be defined. Currently, EESchema does not support # different fonts. In the future this feature may be implemented and at # that time FONT will have to be defined. Initially, only the font size and # style are required. Italic and bold styles are optional. The font size # height and width are in units yet to be determined. (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD]) */ // handle the [FONT] position dependently, i.e. first T tok = NextTok(); bool sawBold = false; bool sawItalic = false; bool sawSize = false; if( IsSymbol( tok ) ) { me->name = FromUTF8(); tok = NextTok(); } while( tok != T_RIGHT ) { if( tok == T_LEFT ) { tok = NextTok(); if( tok != T_size ) Expecting( T_size ); if( sawSize ) Duplicate( T_size ); sawSize = true; NeedNUMBER( "size height" ); me->size.SetHeight( internal( CurText() ) ); NeedNUMBER( "size width" ); me->size.SetWidth( internal( CurText() ) ); NeedRIGHT(); } else { if( tok == T_bold ) { if( sawBold ) Duplicate( T_bold ); sawBold = true; me->bold = true; } else if( tok == T_italic ) { if( sawItalic ) Duplicate( T_italic ); sawItalic = true; me->italic = true; } else Unexpected( tok ); } tok = NextTok(); } } void SWEET_PARSER::parseBool( bool* aBool ) { T tok = NeedSYMBOL(); Loading Loading @@ -460,15 +530,28 @@ void SWEET_PARSER::parsePin( PIN* me ) void SWEET_PARSER::parsePolyLine( POLY_LINE* me ) { /* (polyline|line (pts (xy X Y) (xy X Y) (xy X Y) (xy X Y) (xy X Y)) # Line widths are in units as defined above. (line_width WIDTH) # Valid fill types are none, filled, and transparent. (fill FILL_TYPE) ) */ T tok; int count = 0; bool sawWidth = false; bool sawFill = false; NeedLEFT(); while( ( tok = NextTok() ) != T_RIGHT ) { if( tok == T_LEFT ) if( tok != T_LEFT ) Expecting( T_LEFT ); tok = NextTok(); switch( tok ) Loading Loading @@ -541,16 +624,21 @@ void SWEET_PARSER::parseBezier( BEZIER* me ) void SWEET_PARSER::parseRectangle( RECTANGLE* me ) { /* (rectangle (start X Y) (end X Y) (line_width WIDTH) (fill FILL_TYPE)) */ T tok; bool sawStart = false; bool sawEnd = false; bool sawWidth = false; bool sawFill = false; NeedLEFT(); while( ( tok = NextTok() ) != T_RIGHT ) { if( tok == T_LEFT ) if( tok != T_LEFT ) Expecting( T_LEFT ); tok = NextTok(); switch( tok ) Loading Loading @@ -613,16 +701,26 @@ void SWEET_PARSER::parseRectangle( RECTANGLE* me ) void SWEET_PARSER::parseCircle( CIRCLE* me ) { /* (circle (center X Y) # Radius length is in units if defined or mils. (radius LENGTH) (line_width WIDTH) (fill FILL_TYPE) ) */ T tok; bool sawCenter = false; bool sawRadius = false; bool sawWidth = false; bool sawFill = false; NeedLEFT(); while( ( tok = NextTok() ) != T_RIGHT ) { if( tok == T_LEFT ) if( tok != T_LEFT ) Expecting( T_LEFT ); tok = NextTok(); switch( tok ) Loading Loading @@ -683,6 +781,13 @@ void SWEET_PARSER::parseCircle( CIRCLE* me ) void SWEET_PARSER::parseArc( ARC* me ) { /* (arc (pos X Y) (radius RADIUS) (start X Y) (end X Y) (line_width WIDTH) (fill FILL_TYPE) ) */ T tok; bool sawPos = false; bool sawStart = false; Loading @@ -691,10 +796,11 @@ void SWEET_PARSER::parseArc( ARC* me ) bool sawWidth = false; bool sawFill = false; NeedLEFT(); while( ( tok = NextTok() ) != T_RIGHT ) { if( tok == T_LEFT ) if( tok != T_LEFT ) Expecting( T_LEFT ); tok = NextTok(); switch( tok ) Loading Loading @@ -798,6 +904,19 @@ void SWEET_PARSER::parseAt( POINT* pos, float* angle ) void SWEET_PARSER::parseText( GR_TEXT* me ) { /* (text "This is the text that gets drawn." (at X Y [ANGLE]) # Valid horizontal justification values are center, right, and left. Valid # vertical justification values are center, top, bottom. (justify HORIZONTAL_JUSTIFY VERTICAL_JUSTIFY) (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD]) (visible YES) (fill FILL_TYPE) ) */ T tok; bool sawAt = false; bool sawFill = false; Loading @@ -808,11 +927,11 @@ void SWEET_PARSER::parseText( GR_TEXT* me ) NeedSYMBOLorNUMBER(); me->text = FROM_UTF8( CurText() ); NeedLEFT(); while( ( tok = NextTok() ) != T_RIGHT ) { if( tok == T_LEFT ) if( tok != T_LEFT ) Expecting( T_LEFT ); tok = NextTok(); switch( tok ) Loading
new/sch_sweet_parser.h +3 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ namespace SCH { class LIB_TABLE; class PART; // GRAPHICS class POLY_LINE; class RECTANGLE; Loading @@ -43,6 +44,7 @@ class ARC; class BEZIER; class GR_TEXT; class PIN; class GR_FONT; /** Loading Loading @@ -71,6 +73,7 @@ class SWEET_PARSER : public SWEET_LEXER void parsePin( PIN* me ); void parseAt( POINT* pos, float* angle ); void parseBool( bool* aBool ); void parseFont( GR_FONT* me ); public: Loading
new/sweet.keywords +2 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ arc at bezier bidirectional bold bottom center circle Loading @@ -23,6 +24,7 @@ input input_low inverted inverted_clk italic justify keywords left Loading