Commit 39194ef6 authored by Dick Hollenbeck's avatar Dick Hollenbeck

more free software, Format()ing works now, only a few more items to Parse()

parent 16e9ddc2
...@@ -10,7 +10,7 @@ REVS="rev1 rev5 rev10" ...@@ -10,7 +10,7 @@ REVS="rev1 rev5 rev10"
REFERENCE=" REFERENCE="
(reference U (reference U?
(effects (at 12 13 180)(font (size .7 1))(visible yes)) (effects (at 12 13 180)(font (size .7 1))(visible yes))
)" )"
...@@ -71,7 +71,7 @@ for C in ${CATEGORIES}; do ...@@ -71,7 +71,7 @@ for C in ${CATEGORIES}; do
for P in ${PARTS}; do for P in ${PARTS}; do
for R in ${REVS}; do for R in ${REVS}; do
echo "(part $C/$P (value 22)(footprint SM0805)(model Airplane) echo "(part $C/$P (value 22)(footprint SM0805)(model Airplane)(datasheet http://favorite.pdf)
$REFERENCE $REFERENCE
$LINE $LINE
$RECT $RECT
...@@ -86,7 +86,7 @@ for C in ${CATEGORIES}; do ...@@ -86,7 +86,7 @@ for C in ${CATEGORIES}; do
)" > $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:
echo "(part $C/$P (value 22)(footprint SM0805)(model Airplane) echo "(part $C/$P (value 22)(footprint SM0805)(model Airplane)(datasheet http://favorite.pdf)
$REFERENCE $REFERENCE
$LINE $LINE
$RECT $RECT
......
This diff is collapsed.
This diff is collapsed.
...@@ -36,20 +36,9 @@ using namespace PR; ...@@ -36,20 +36,9 @@ using namespace PR;
#define MAX_INHERITANCE_NESTING 6 ///< max depth of inheritance, no problem going larger #define MAX_INHERITANCE_NESTING 6 ///< max depth of inheritance, no problem going larger
/**
* Function log2int
* converts a logical coordinate to an internal coordinate. Logical coordinates
* are defined as the standard distance between pins being equal to one.
* Internal coordinates are currently INTERNAL_PER_LOGICAL times that.
*/
static inline int log2int( double aCoord )
{
return int( aCoord * INTERNAL_PER_LOGICAL );
}
static inline int internal( const STRING& aCoord ) static inline int internal( const STRING& aCoord )
{ {
return log2int( strtod( aCoord.c_str(), NULL ) ); return LogicalToInternal( strtod( aCoord.c_str(), NULL ) );
} }
...@@ -61,15 +50,15 @@ static inline int internal( const STRING& aCoord ) ...@@ -61,15 +50,15 @@ static inline int internal( const STRING& aCoord )
*/ */
enum PartBit enum PartBit
{ {
PARSED, ///< have parsed this part already, otherwise 'body' text must be parsed parsed, ///< have parsed this part already, otherwise 'body' text must be parsed
EXTENDS, ///< saw "extends" keyword, inheriting from another PART extends, ///< saw "extends" keyword, inheriting from another PART
VALUE, value,
ANCHOR, anchor,
REFERENCE, reference,
FOOTPRINT, footprint,
DATASHEET, datasheet,
MODEL, model,
KEYWORDS, keywords,
}; };
...@@ -86,7 +75,7 @@ void SWEET_PARSER::parseExtends( PART* me ) ...@@ -86,7 +75,7 @@ void SWEET_PARSER::parseExtends( PART* me )
PART* base; PART* base;
int offset; int offset;
if( contains & PB(EXTENDS) ) if( contains & PB(extends) )
Duplicate( T_extends ); Duplicate( T_extends );
NeedSYMBOLorNUMBER(); NeedSYMBOLorNUMBER();
...@@ -129,7 +118,7 @@ void SWEET_PARSER::parseExtends( PART* me ) ...@@ -129,7 +118,7 @@ void SWEET_PARSER::parseExtends( PART* me )
me->inherit( *base ); me->inherit( *base );
me->base = base; me->base = base;
contains |= PB(EXTENDS); contains |= PB(extends);
} }
...@@ -175,6 +164,8 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E ...@@ -175,6 +164,8 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E
{ {
if( tok == T_LEFT ) if( tok == T_LEFT )
{ {
PROPERTY* prop;
tok = NextTok(); tok = NextTok();
// because exceptions are thrown, any 'new' allocation has to be stored // because exceptions are thrown, any 'new' allocation has to be stored
...@@ -195,13 +186,13 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E ...@@ -195,13 +186,13 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E
break; break;
case T_anchor: case T_anchor:
if( contains & PB(ANCHOR) ) if( contains & PB(anchor) )
Duplicate( tok ); Duplicate( tok );
NeedNUMBER( "anchor x" ); NeedNUMBER( "anchor x" );
me->anchor.x = internal( CurText() ); me->anchor.x = internal( CurText() );
NeedNUMBER( "anchor y" ); NeedNUMBER( "anchor y" );
me->anchor.y = internal( CurText() ); me->anchor.y = internal( CurText() );
contains |= PB(ANCHOR); contains |= PB(anchor);
break; break;
case T_line: case T_line:
...@@ -247,130 +238,71 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E ...@@ -247,130 +238,71 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E
parseText( text ); parseText( text );
break; break;
// reference in a PART is incomplete, it is just the prefix of an case T_property:
// unannotated reference. Only components have full reference designators. prop = new PROPERTY( me );
case T_reference: // @todo check for uniqueness
if( contains & PB(REFERENCE) ) me->properties.push_back( prop );
Duplicate( tok );
contains |= PB(REFERENCE);
NeedSYMBOLorNUMBER(); NeedSYMBOLorNUMBER();
me->reference.text = FromUTF8(); prop->name = FromUTF8();
L_prop:
NeedSYMBOLorNUMBER();
prop->text = FromUTF8();
tok = NextTok(); tok = NextTok();
if( tok == T_LEFT ) if( tok == T_LEFT )
{ {
tok = NextTok(); tok = NextTok();
if( tok != T_effects ) if( tok != T_effects )
Expecting( T_effects ); Expecting( T_effects );
parseTextEffects( &me->reference.effects ); parseTextEffects( prop->EffectsLookup() );
NeedRIGHT(); NeedRIGHT();
} }
else if( tok != T_RIGHT ) else if( tok != T_RIGHT )
Expecting( ") | effects" ); Expecting( ") | effects" );
break; break;
case T_value: case T_property_del:
if( contains & PB(VALUE) )
Duplicate( tok );
contains |= PB(VALUE);
NeedSYMBOLorNUMBER(); NeedSYMBOLorNUMBER();
me->value.text = FromUTF8(); me->PropertyDelete( FromUTF8() );
tok = NextTok(); NeedRIGHT();
if( tok == T_LEFT )
{
tok = NextTok();
if( tok != T_effects )
Expecting( T_effects );
parseTextEffects( &me->value.effects );
NeedRIGHT();
}
else if( tok != T_RIGHT )
Expecting( ") | effects" );
break; break;
// reference in a PART is incomplete, it is just the prefix of an
// unannotated reference. Only components have full reference designators.
case T_reference:
if( contains & PB(reference) )
Duplicate( tok );
contains |= PB(reference);
prop = me->FieldLookup( PART::REFERENCE );
goto L_prop;
case T_value:
if( contains & PB(value) )
Duplicate( tok );
contains |= PB(value);
prop = me->FieldLookup( PART::VALUE );
goto L_prop;
case T_footprint: case T_footprint:
if( contains & PB(FOOTPRINT) ) if( contains & PB(footprint) )
Duplicate( tok ); Duplicate( tok );
contains |= PB(FOOTPRINT); contains |= PB(footprint);
NeedSYMBOLorNUMBER(); prop = me->FieldLookup( PART::FOOTPRINT );
me->footprint.text = FromUTF8(); goto L_prop;
tok = NextTok();
if( tok == T_LEFT )
{
tok = NextTok();
if( tok != T_effects )
Expecting( T_effects );
parseTextEffects( &me->footprint.effects );
NeedRIGHT();
}
else if( tok != T_RIGHT )
Expecting( ") | effects" );
break;
case T_datasheet: case T_datasheet:
if( contains & PB(MODEL) ) if( contains & PB(datasheet) )
Duplicate( tok ); Duplicate( tok );
contains |= PB(MODEL); contains |= PB(datasheet);
NeedSYMBOLorNUMBER(); prop = me->FieldLookup( PART::DATASHEET );
me->datasheet.text = FromUTF8(); goto L_prop;
tok = NextTok();
if( tok == T_LEFT )
{
tok = NextTok();
if( tok != T_effects )
Expecting( T_effects );
parseTextEffects( &me->datasheet.effects );
NeedRIGHT();
}
else if( tok != T_RIGHT )
Expecting( ") | effects" );
break;
case T_model: case T_model:
if( contains & PB(MODEL) ) if( contains & PB(model) )
Duplicate( tok ); Duplicate( tok );
contains |= PB(MODEL); contains |= PB(model);
NeedSYMBOLorNUMBER(); prop = me->FieldLookup( PART::MODEL );
me->model.text = FromUTF8(); goto L_prop;
tok = NextTok();
if( tok == T_LEFT )
{
tok = NextTok();
if( tok != T_effects )
Expecting( T_effects );
parseTextEffects( &me->model.effects );
NeedRIGHT();
}
else if( tok != T_RIGHT )
Expecting( ") | effects" );
break;
case T_property:
PROPERTY* property;
property = new PROPERTY( me );
// @todo check for uniqueness
me->properties.push_back( property );
NeedSYMBOLorNUMBER();
property->name = FromUTF8();
NeedSYMBOLorNUMBER();
property->text = FromUTF8();
tok = NextTok();
if( tok == T_LEFT )
{
tok = NextTok();
if( tok != T_effects )
Expecting( T_effects );
parseTextEffects( &property->effects );
NeedRIGHT();
}
else if( tok != T_RIGHT )
Expecting( ") | effects" );
break;
case T_property_del:
NeedSYMBOLorNUMBER();
me->PropertyDelete( FromUTF8() );
NeedRIGHT();
break;
case T_pin: case T_pin:
PIN* pin; PIN* pin;
...@@ -404,7 +336,6 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E ...@@ -404,7 +336,6 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E
case T_route_pin_swap: case T_route_pin_swap:
break; break;
*/ */
} }
} }
...@@ -419,7 +350,7 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E ...@@ -419,7 +350,7 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E
} }
} }
contains |= PB(PARSED); contains |= PB(parsed);
me->contains |= contains; me->contains |= contains;
} }
...@@ -804,6 +735,7 @@ void SWEET_PARSER::parsePolyLine( POLY_LINE* me ) ...@@ -804,6 +735,7 @@ void SWEET_PARSER::parsePolyLine( POLY_LINE* me )
if( sawWidth ) if( sawWidth )
Duplicate( tok ); Duplicate( tok );
NeedNUMBER( "line_width" ); NeedNUMBER( "line_width" );
// @todo Use logical units?
me->lineWidth = strtod( CurText(), NULL ); me->lineWidth = strtod( CurText(), NULL );
NeedRIGHT(); NeedRIGHT();
sawWidth = true; sawWidth = true;
......
...@@ -29,15 +29,6 @@ ...@@ -29,15 +29,6 @@
#include <sweet_lexer.h> #include <sweet_lexer.h>
#define INTERNAL_PER_LOGICAL 10000 ///< no. internal units per logical unit
static inline double InternalToLogical( int aCoord )
{
return double( aCoord ) / INTERNAL_PER_LOGICAL;
}
class POINT; class POINT;
namespace SCH { namespace SCH {
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <sch_lib_table.h> #include <sch_lib_table.h>
#include <sch_lib_table_lexer.h> #include <sch_lib_table_lexer.h>
#include <sch_lpid.h> #include <sch_lpid.h>
#include <sch_part.h>
using namespace SCH; using namespace SCH;
...@@ -86,7 +87,12 @@ void LIB_TABLE::Test() ...@@ -86,7 +87,12 @@ void LIB_TABLE::Test()
// find a part // find a part
LPID lpid( "meparts:tigers/ears" ); LPID lpid( "meparts:tigers/ears" );
LookupPart( lpid ); PART* part = LookupPart( lpid );
sf.Clear();
part->Format( &sf, 0, 0 );
printf( "%s", sf.GetString().c_str() );
} }
......
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