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"
REFERENCE="
(reference U
(reference U?
(effects (at 12 13 180)(font (size .7 1))(visible yes))
)"
......@@ -71,7 +71,7 @@ for C in ${CATEGORIES}; do
for P in ${PARTS}; 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
$LINE
$RECT
......@@ -86,7 +86,7 @@ for C in ${CATEGORIES}; do
)" > $BASEDIR/$C/$P.part.$R
done
# 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
$LINE
$RECT
......
This diff is collapsed.
This diff is collapsed.
......@@ -36,20 +36,9 @@ using namespace PR;
#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 )
{
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 )
*/
enum PartBit
{
PARSED, ///< have parsed this part already, otherwise 'body' text must be parsed
EXTENDS, ///< saw "extends" keyword, inheriting from another PART
VALUE,
ANCHOR,
REFERENCE,
FOOTPRINT,
DATASHEET,
MODEL,
KEYWORDS,
parsed, ///< have parsed this part already, otherwise 'body' text must be parsed
extends, ///< saw "extends" keyword, inheriting from another PART
value,
anchor,
reference,
footprint,
datasheet,
model,
keywords,
};
......@@ -86,7 +75,7 @@ void SWEET_PARSER::parseExtends( PART* me )
PART* base;
int offset;
if( contains & PB(EXTENDS) )
if( contains & PB(extends) )
Duplicate( T_extends );
NeedSYMBOLorNUMBER();
......@@ -129,7 +118,7 @@ void SWEET_PARSER::parseExtends( PART* me )
me->inherit( *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
{
if( tok == T_LEFT )
{
PROPERTY* prop;
tok = NextTok();
// 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
break;
case T_anchor:
if( contains & PB(ANCHOR) )
if( contains & PB(anchor) )
Duplicate( tok );
NeedNUMBER( "anchor x" );
me->anchor.x = internal( CurText() );
NeedNUMBER( "anchor y" );
me->anchor.y = internal( CurText() );
contains |= PB(ANCHOR);
contains |= PB(anchor);
break;
case T_line:
......@@ -247,130 +238,71 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E
parseText( text );
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);
case T_property:
prop = new PROPERTY( me );
// @todo check for uniqueness
me->properties.push_back( prop );
NeedSYMBOLorNUMBER();
me->reference.text = FromUTF8();
prop->name = FromUTF8();
L_prop:
NeedSYMBOLorNUMBER();
prop->text = FromUTF8();
tok = NextTok();
if( tok == T_LEFT )
{
tok = NextTok();
if( tok != T_effects )
Expecting( T_effects );
parseTextEffects( &me->reference.effects );
parseTextEffects( prop->EffectsLookup() );
NeedRIGHT();
}
else if( tok != T_RIGHT )
Expecting( ") | effects" );
break;
case T_value:
if( contains & PB(VALUE) )
Duplicate( tok );
contains |= PB(VALUE);
case T_property_del:
NeedSYMBOLorNUMBER();
me->value.text = FromUTF8();
tok = NextTok();
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" );
me->PropertyDelete( FromUTF8() );
NeedRIGHT();
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:
if( contains & PB(FOOTPRINT) )
if( contains & PB(footprint) )
Duplicate( tok );
contains |= PB(FOOTPRINT);
NeedSYMBOLorNUMBER();
me->footprint.text = FromUTF8();
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;
contains |= PB(footprint);
prop = me->FieldLookup( PART::FOOTPRINT );
goto L_prop;
case T_datasheet:
if( contains & PB(MODEL) )
if( contains & PB(datasheet) )
Duplicate( tok );
contains |= PB(MODEL);
NeedSYMBOLorNUMBER();
me->datasheet.text = FromUTF8();
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;
contains |= PB(datasheet);
prop = me->FieldLookup( PART::DATASHEET );
goto L_prop;
case T_model:
if( contains & PB(MODEL) )
if( contains & PB(model) )
Duplicate( tok );
contains |= PB(MODEL);
NeedSYMBOLorNUMBER();
me->model.text = FromUTF8();
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;
contains |= PB(model);
prop = me->FieldLookup( PART::MODEL );
goto L_prop;
case T_pin:
PIN* pin;
......@@ -404,7 +336,6 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E
case T_route_pin_swap:
break;
*/
}
}
......@@ -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;
}
......@@ -804,6 +735,7 @@ void SWEET_PARSER::parsePolyLine( POLY_LINE* me )
if( sawWidth )
Duplicate( tok );
NeedNUMBER( "line_width" );
// @todo Use logical units?
me->lineWidth = strtod( CurText(), NULL );
NeedRIGHT();
sawWidth = true;
......
......@@ -29,15 +29,6 @@
#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;
namespace SCH {
......
......@@ -25,6 +25,7 @@
#include <sch_lib_table.h>
#include <sch_lib_table_lexer.h>
#include <sch_lpid.h>
#include <sch_part.h>
using namespace SCH;
......@@ -86,7 +87,12 @@ void LIB_TABLE::Test()
// find a part
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