Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
39194ef6
Commit
39194ef6
authored
Apr 03, 2011
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more free software, Format()ing works now, only a few more items to Parse()
parent
16e9ddc2
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
667 additions
and
241 deletions
+667
-241
make-dir-lib-source-test-data.sh
new/make-dir-lib-source-test-data.sh
+3
-3
sch_part.cpp
new/sch_part.cpp
+340
-9
sch_part.h
new/sch_part.h
+258
-92
sch_sweet_parser.cpp
new/sch_sweet_parser.cpp
+59
-127
sch_sweet_parser.h
new/sch_sweet_parser.h
+0
-9
test_sch_lib_table.cpp
new/test_sch_lib_table.cpp
+7
-1
No files found.
new/make-dir-lib-source-test-data.sh
View file @
39194ef6
...
@@ -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
...
...
new/sch_part.cpp
View file @
39194ef6
This diff is collapsed.
Click to expand it.
new/sch_part.h
View file @
39194ef6
This diff is collapsed.
Click to expand it.
new/sch_sweet_parser.cpp
View file @
39194ef6
...
@@ -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
();
if
(
tok
==
T_LEFT
)
{
tok
=
NextTok
();
if
(
tok
!=
T_effects
)
Expecting
(
T_effects
);
parseTextEffects
(
&
me
->
value
.
effects
);
NeedRIGHT
();
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
;
...
...
new/sch_sweet_parser.h
View file @
39194ef6
...
@@ -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
{
...
...
new/test_sch_lib_table.cpp
View file @
39194ef6
...
@@ -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
()
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment