Commit a2359ebc authored by Dick Hollenbeck's avatar Dick Hollenbeck

more free software

parent ae6ef8c5
...@@ -13,19 +13,46 @@ ...@@ -13,19 +13,46 @@
#include <sweet_lexer.h> #include <sweet_lexer.h>
namespace SCH {
class PART;
class SWEET_PARSER;
};
class POINT : public wxPoint class POINT : public wxPoint
{ {
public: public:
POINT( int x, int y ) : wxPoint( x, y ) {} POINT( int x, int y ) :
POINT() : wxPoint() {} wxPoint( x, y )
{}
POINT() :
wxPoint()
{}
}; };
namespace SCH { namespace SCH {
class PART; class GR_FONT
class SWEET_PARSER; {
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 class BASE_GRAPHIC
{ {
...@@ -187,6 +214,7 @@ public: ...@@ -187,6 +214,7 @@ public:
{} {}
}; };
} // namespace SCH } // namespace SCH
......
...@@ -148,7 +148,6 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E ...@@ -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 // Caller may not have read the first two tokens out of the
// stream: T_LEFT and T_part, so ignore them if seen here. // 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. // The 1st two tokens T_LEFT and T_part are then optional in the grammar.
if( (tok = NextTok() ) == T_LEFT ) if( (tok = NextTok() ) == T_LEFT )
{ {
if( ( tok = NextTok() ) != T_part ) if( ( tok = NextTok() ) != T_part )
...@@ -163,7 +162,7 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E ...@@ -163,7 +162,7 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E
Expecting( T_part ); Expecting( T_part );
#endif #endif
NeedSYMBOLorNUMBER(); // read in part NAME_HINT, and toss NeedSYMBOLorNUMBER(); // toss NAME_HINT
tok = NextTok(); tok = NextTok();
// extends must be _first_ thing, if it is present at all, after NAME_HINT // extends must be _first_ thing, if it is present at all, after NAME_HINT
...@@ -231,7 +230,7 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E ...@@ -231,7 +230,7 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E
break; break;
case T_arc: case T_arc:
ARC* arc; ARC* arc;
arc = new ARC( me ); arc = new ARC( me );
me->graphics.push_back( arc ); me->graphics.push_back( arc );
parseArc( arc ); parseArc( arc );
...@@ -334,6 +333,77 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E ...@@ -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 ) void SWEET_PARSER::parseBool( bool* aBool )
{ {
T tok = NeedSYMBOL(); T tok = NeedSYMBOL();
...@@ -460,16 +530,29 @@ void SWEET_PARSER::parsePin( PIN* me ) ...@@ -460,16 +530,29 @@ void SWEET_PARSER::parsePin( PIN* me )
void SWEET_PARSER::parsePolyLine( POLY_LINE* 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; T tok;
int count = 0; int count = 0;
bool sawWidth = false; bool sawWidth = false;
bool sawFill = false; bool sawFill = false;
NeedLEFT();
while( ( tok = NextTok() ) != T_RIGHT ) while( ( tok = NextTok() ) != T_RIGHT )
{ {
if( tok == T_LEFT ) if( tok != T_LEFT )
tok = NextTok(); Expecting( T_LEFT );
tok = NextTok();
switch( tok ) switch( tok )
{ {
...@@ -541,17 +624,22 @@ void SWEET_PARSER::parseBezier( BEZIER* me ) ...@@ -541,17 +624,22 @@ void SWEET_PARSER::parseBezier( BEZIER* me )
void SWEET_PARSER::parseRectangle( RECTANGLE* me ) void SWEET_PARSER::parseRectangle( RECTANGLE* me )
{ {
/*
(rectangle (start X Y) (end X Y) (line_width WIDTH) (fill FILL_TYPE))
*/
T tok; T tok;
bool sawStart = false; bool sawStart = false;
bool sawEnd = false; bool sawEnd = false;
bool sawWidth = false; bool sawWidth = false;
bool sawFill = false; bool sawFill = false;
NeedLEFT();
while( ( tok = NextTok() ) != T_RIGHT ) while( ( tok = NextTok() ) != T_RIGHT )
{ {
if( tok == T_LEFT ) if( tok != T_LEFT )
tok = NextTok(); Expecting( T_LEFT );
tok = NextTok();
switch( tok ) switch( tok )
{ {
...@@ -613,17 +701,27 @@ void SWEET_PARSER::parseRectangle( RECTANGLE* me ) ...@@ -613,17 +701,27 @@ void SWEET_PARSER::parseRectangle( RECTANGLE* me )
void SWEET_PARSER::parseCircle( CIRCLE* 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; T tok;
bool sawCenter = false; bool sawCenter = false;
bool sawRadius = false; bool sawRadius = false;
bool sawWidth = false; bool sawWidth = false;
bool sawFill = false; bool sawFill = false;
NeedLEFT();
while( ( tok = NextTok() ) != T_RIGHT ) while( ( tok = NextTok() ) != T_RIGHT )
{ {
if( tok == T_LEFT ) if( tok != T_LEFT )
tok = NextTok(); Expecting( T_LEFT );
tok = NextTok();
switch( tok ) switch( tok )
{ {
...@@ -683,6 +781,13 @@ void SWEET_PARSER::parseCircle( CIRCLE* me ) ...@@ -683,6 +781,13 @@ void SWEET_PARSER::parseCircle( CIRCLE* me )
void SWEET_PARSER::parseArc( ARC* 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; T tok;
bool sawPos = false; bool sawPos = false;
bool sawStart = false; bool sawStart = false;
...@@ -691,11 +796,12 @@ void SWEET_PARSER::parseArc( ARC* me ) ...@@ -691,11 +796,12 @@ void SWEET_PARSER::parseArc( ARC* me )
bool sawWidth = false; bool sawWidth = false;
bool sawFill = false; bool sawFill = false;
NeedLEFT();
while( ( tok = NextTok() ) != T_RIGHT ) while( ( tok = NextTok() ) != T_RIGHT )
{ {
if( tok == T_LEFT ) if( tok != T_LEFT )
tok = NextTok(); Expecting( T_LEFT );
tok = NextTok();
switch( tok ) switch( tok )
{ {
...@@ -798,6 +904,19 @@ void SWEET_PARSER::parseAt( POINT* pos, float* angle ) ...@@ -798,6 +904,19 @@ void SWEET_PARSER::parseAt( POINT* pos, float* angle )
void SWEET_PARSER::parseText( GR_TEXT* me ) 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; T tok;
bool sawAt = false; bool sawAt = false;
bool sawFill = false; bool sawFill = false;
...@@ -808,12 +927,12 @@ void SWEET_PARSER::parseText( GR_TEXT* me ) ...@@ -808,12 +927,12 @@ void SWEET_PARSER::parseText( GR_TEXT* me )
NeedSYMBOLorNUMBER(); NeedSYMBOLorNUMBER();
me->text = FROM_UTF8( CurText() ); me->text = FROM_UTF8( CurText() );
NeedLEFT();
while( ( tok = NextTok() ) != T_RIGHT ) while( ( tok = NextTok() ) != T_RIGHT )
{ {
if( tok == T_LEFT ) if( tok != T_LEFT )
tok = NextTok(); Expecting( T_LEFT );
tok = NextTok();
switch( tok ) switch( tok )
{ {
......
...@@ -35,6 +35,7 @@ namespace SCH { ...@@ -35,6 +35,7 @@ namespace SCH {
class LIB_TABLE; class LIB_TABLE;
class PART; class PART;
// GRAPHICS // GRAPHICS
class POLY_LINE; class POLY_LINE;
class RECTANGLE; class RECTANGLE;
...@@ -43,6 +44,7 @@ class ARC; ...@@ -43,6 +44,7 @@ class ARC;
class BEZIER; class BEZIER;
class GR_TEXT; class GR_TEXT;
class PIN; class PIN;
class GR_FONT;
/** /**
...@@ -71,6 +73,7 @@ class SWEET_PARSER : public SWEET_LEXER ...@@ -71,6 +73,7 @@ class SWEET_PARSER : public SWEET_LEXER
void parsePin( PIN* me ); void parsePin( PIN* me );
void parseAt( POINT* pos, float* angle ); void parseAt( POINT* pos, float* angle );
void parseBool( bool* aBool ); void parseBool( bool* aBool );
void parseFont( GR_FONT* me );
public: public:
......
...@@ -4,6 +4,7 @@ arc ...@@ -4,6 +4,7 @@ arc
at at
bezier bezier
bidirectional bidirectional
bold
bottom bottom
center center
circle circle
...@@ -23,6 +24,7 @@ input ...@@ -23,6 +24,7 @@ input
input_low input_low
inverted inverted
inverted_clk inverted_clk
italic
justify justify
keywords keywords
left left
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment