forked from KiCad/kicad-source-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sch_sweet_parser.cpp
1561 lines (1298 loc) · 39.5 KB
/
sch_sweet_parser.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
* Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <sch_sweet_parser.h>
#include <sch_part.h>
#include <sch_lib_table.h>
#include <sch_lpid.h>
#include <macros.h>
using namespace SCH;
using namespace PR;
#define MAX_INHERITANCE_NESTING 6 ///< max depth of inheritance, no problem going larger
static inline int internal( const STRING& aCoord )
{
return LogicalToInternal( strtod( aCoord.c_str(), NULL ) );
}
static inline int fromWidth( const STRING& aWidth )
{
return WidthToInternal( strtod( aWidth.c_str(), NULL ) );
}
static inline int fromFontz( const STRING& aFontSize )
{
return FontzToInternal( strtod( aFontSize.c_str(), NULL ) );
}
/**
* Enum PartBit
* is a set of bit positions that can be used to create flag bits within
* PART::contains to indicate what state the PART is in and what it contains, i.e.
* whether the PART has been parsed, and what the PART contains, categorically.
*/
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,
};
/// Function PB
/// is a PartBit shifter for PART::contains field.
static inline const int PB( PartBit oneBitOnly )
{
return ( 1 << oneBitOnly );
}
void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_ERROR )
{
T tok;
libs = aTable;
// empty everything out, could be re-parsing this object and it may not be empty.
me->clear();
#if 0
// Be flexible regarding the starting point of the stream.
// 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 )
Expecting( T_part );
}
#else
// "( part" are not optional
NeedLEFT();
if( ( tok = NextTok() ) != T_part )
Expecting( T_part );
#endif
NeedSYMBOLorNUMBER(); // toss NAME_HINT
tok = NextTok();
// extends must be _first_ thing, if it is present at all, after NAME_HINT
if( tok == T_extends )
{
parseExtends( me );
tok = NextTok();
}
for( ; tok!=T_RIGHT; tok = NextTok() )
{
if( tok == T_LEFT )
{
PROPERTY* prop;
tok = NextTok();
// because exceptions are thrown, any 'new' allocation has to be stored
// somewhere other than on the stack, ASAP.
switch( tok )
{
default:
// describe what we expect at this level
Expecting(
"anchor|value|footprint|model|keywords|alternates\n"
"|property\n"
" |property_del\n"
"|pin\n"
" |pin_merge|pin_swap|pin_renum|pin_rename|route_pin_swap\n"
"|polyline|line|rectangle|circle|arc|bezier|text"
);
break;
case T_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);
break;
case T_line:
case T_polyline:
POLY_LINE* pl;
pl = new POLY_LINE( me );
me->graphics.push_back( pl );
parsePolyLine( pl );
break;
case T_rectangle:
RECTANGLE* rect;
rect = new RECTANGLE( me );
me->graphics.push_back( rect );
parseRectangle( rect );
break;
case T_circle:
CIRCLE* circ;
circ = new CIRCLE( me );
me->graphics.push_back( circ );
parseCircle( circ );
break;
case T_arc:
ARC* arc;
arc = new ARC( me );
me->graphics.push_back( arc );
parseArc( arc );
break;
case T_bezier:
BEZIER* bezier;
bezier = new BEZIER( me );
me->graphics.push_back( bezier );
parseBezier( bezier );
break;
case T_text:
GR_TEXT* text;
text = new GR_TEXT( me );
me->graphics.push_back( text );
parseText( text );
break;
case T_property:
prop = new PROPERTY( me );
// @todo check for uniqueness
me->properties.push_back( prop );
NeedSYMBOLorNUMBER();
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( prop->EffectsLookup() );
NeedRIGHT();
}
else if( tok != T_RIGHT )
Expecting( ") | effects" );
break;
case T_property_del:
parsePropertyDel( me );
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) )
Duplicate( tok );
contains |= PB(footprint);
prop = me->FieldLookup( PART::FOOTPRINT );
goto L_prop;
case T_datasheet:
if( contains & PB(datasheet) )
Duplicate( tok );
contains |= PB(datasheet);
prop = me->FieldLookup( PART::DATASHEET );
goto L_prop;
case T_model:
if( contains & PB(model) )
Duplicate( tok );
contains |= PB(model);
prop = me->FieldLookup( PART::MODEL );
goto L_prop;
case T_keywords:
parseKeywords( me );
break;
case T_alternates:
// @todo: do we want to inherit alternates?
parseAlternates( me );
break;
case T_pin:
// @todo PADNAMEs must be unique
PIN* pin;
pin = new PIN( me );
me->pins.push_back( pin );
parsePin( pin );
break;
case T_pin_del:
parsePinDel( me );
break;
case T_pin_swap:
parsePinSwap( me );
break;
case T_pin_renum:
parsePinRenum( me );
break;
case T_pin_rename:
parsePinRename( me );
break;
case T_pin_merge:
parsePinMerge( me );
break;
/*
@todo
case T_route_pin_swap:
break;
*/
}
}
else
{
switch( tok )
{
default:
Unexpected( tok );
}
}
}
contains |= PB(parsed);
me->contains |= contains;
}
void SWEET_PARSER::parseExtends( PART* me )
{
PART* base;
int offset;
if( contains & PB(extends) )
Duplicate( T_extends );
NeedSYMBOLorNUMBER();
me->setExtends( new LPID() );
offset = me->extends->Parse( CurText() );
if( offset > -1 ) // -1 is success
THROW_PARSE_ERROR( _("invalid extends LPID"),
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() + offset );
base = libs->LookupPart( *me->extends, me->Owner() );
// we could be going in circles here, recursively, or too deep, set limits
// and disallow extending from self (even indirectly)
int extendsDepth = 0;
for( const PART* ancestor = base; ancestor && extendsDepth<MAX_INHERITANCE_NESTING;
++extendsDepth, ancestor = ancestor->base )
{
if( ancestor == me )
{
THROW_PARSE_ERROR( _("'extends' may not have self as any ancestor"),
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
}
if( extendsDepth == MAX_INHERITANCE_NESTING )
{
THROW_PARSE_ERROR( _("max allowed extends depth exceeded"),
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
me->inherit( *base );
me->base = base;
contains |= PB(extends);
}
void SWEET_PARSER::parseAlternates( PART* me )
{
T tok;
PART_REF lpid;
int offset;
while( ( tok = NextTok() ) != T_RIGHT )
{
if( !IsSymbol( tok ) && tok != T_NUMBER )
Expecting( "lpid" );
// lpid.clear(); Parse does this
offset = lpid.Parse( CurText() );
if( offset > -1 )
THROW_PARSE_ERROR( _("invalid alternates LPID"),
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() + offset );
// PART_REF assignment should be OK, it contains no ownership
me->alternates.push_back( lpid );
}
}
void SWEET_PARSER::parseKeywords( PART* me )
{
T tok;
while( ( tok = NextTok() ) != T_RIGHT )
{
if( !IsSymbol( tok ) && tok!=T_NUMBER )
Expecting( "symbol|number" );
// just insert them, duplicates are silently removed and tossed.
me->keywords.insert( FromUTF8() );
}
}
void SWEET_PARSER::parseFont( 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();
}
for( ; tok != T_RIGHT; tok = NextTok() )
{
if( tok == T_LEFT )
{
tok = NextTok();
switch( tok )
{
case T_size:
if( sawSize )
Duplicate( T_size );
sawSize = true;
NeedNUMBER( "size height" );
me->size.height = fromFontz( CurText() );
NeedNUMBER( "size width" );
me->size.width = fromFontz( CurText() );
NeedRIGHT();
break;
default:
Expecting( "size" );
}
}
else
{
switch( tok )
{
case T_bold:
if( sawBold )
Duplicate( T_bold );
sawBold = true;
me->bold = true;
break;
case T_italic:
if( sawItalic )
Duplicate( T_italic );
sawItalic = true;
me->italic = true;
break;
default:
Unexpected( "bold|italic" );
}
}
}
}
void SWEET_PARSER::parseBool( bool* aBool )
{
T tok = NeedSYMBOL();
switch( tok )
{
case T_yes:
case T_no:
*aBool = (tok == T_yes);
break;
default:
Expecting( "yes|no" );
}
}
void SWEET_PARSER::parseStroke( STROKE* me )
{
/*
(stroke [WIDTH] [(style [(dashed...)]...)])
future place holder for arrow heads, dashed lines, all line glamour
*/
NeedNUMBER( "stroke" );
*me = fromWidth( CurText() );
NeedRIGHT();
}
void SWEET_PARSER::parsePinText( PINTEXT* me )
{
/* either:
(signal SIGNAL (font [FONT] (size HEIGHT WIDTH) [italic] [bold])(visible YES))
or
(pad PADNAME (font [FONT] (size HEIGHT WIDTH) [italic] [bold])(visible YES))
*/
T tok;
bool sawFont = false;
bool sawVis = false;
// pad or signal text
NeedSYMBOLorNUMBER();
me->text = FromUTF8();
while( ( tok = NextTok() ) != T_RIGHT )
{
if( tok == T_LEFT )
{
tok = NextTok();
switch( tok )
{
case T_font:
if( sawFont )
Duplicate( tok );
sawFont = true;
parseFont( &me->font );
break;
case T_visible:
if( sawVis )
Duplicate( tok );
sawVis = true;
parseBool( &me->isVisible );
NeedRIGHT();
break;
default:
Expecting( "font" );
}
}
else
{
switch( tok )
{
default:
Expecting( T_LEFT );
}
}
}
}
void SWEET_PARSER::parsePin( PIN* me )
{
/*
(pin TYPE SHAPE
(at X Y [ANGLE])
(length LENGTH)
(signal NAME (font [FONT] (size HEIGHT WIDTH) [italic] [bold])(visible YES))
(pad NUMBER (font [FONT] (size HEIGHT WIDTH) [italic] [bold] (visible YES))
(visible YES)
)
*/
T tok;
bool sawShape = false;
bool sawType = false;
bool sawAt = false;
bool sawLen = false;
bool sawSignal = false;
bool sawPad = false;
bool sawVis = false;
while( ( tok = NextTok() ) != T_RIGHT )
{
if( tok == T_LEFT )
{
tok = NextTok();
switch( tok )
{
case T_at:
if( sawAt )
Duplicate( tok );
sawAt = true;
parseAt( &me->pos, &me->angle );
break;
case T_length:
if( sawLen )
Duplicate( tok );
sawLen = true;
NeedNUMBER( "length" );
me->length = internal( CurText() );
NeedRIGHT();
break;
case T_signal:
if( sawSignal )
Duplicate( tok );
sawSignal = true;
parsePinText( &me->signal );
break;
case T_pad:
if( sawPad )
Duplicate( tok );
sawPad = true;
parsePinText( &me->pad );
break;
case T_visible:
if( sawVis )
Duplicate( tok );
sawVis = true;
parseBool( &me->isVisible );
NeedRIGHT();
break;
default:
Unexpected( tok );
}
}
else // not wrapped in parentheses
{
switch( tok )
{
case T_in:
case T_out:
case T_inout:
case T_tristate:
case T_passive:
case T_unspecified:
case T_power_in:
case T_power_out:
case T_open_collector:
case T_open_emitter:
case T_unconnected:
if( sawType )
Duplicate( tok );
sawType = true;
me->connectionType = tok;
break;
case T_none:
case T_line:
case T_inverted:
case T_clock:
case T_inverted_clk:
case T_input_low:
case T_clock_low:
case T_falling_edge:
case T_non_logic:
if( sawShape )
Duplicate( tok );
sawShape = true;
me->shape = tok;
break;
default:
Unexpected( tok );
}
}
}
}
void SWEET_PARSER::parsePinDel( PART* me )
{
wxString pad;
// we do this somewhat unorthodoxically because we want to avoid doing two lookups,
// which would need to be done to 1) find pin, and 2) delete pin. Only one
// lookup is needed with this scheme.
NeedSYMBOLorNUMBER();
pad = FromUTF8();
// lookup now while CurOffset() is still meaningful.
PINS::iterator it = me->pinFindByPad( pad );
if( it == me->pins.end() )
{
THROW_PARSE_ERROR( _("undefined pin"),
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
/* enable in future, but not now while testing
if( (*it)->birthplace == me )
{
THROW_PARSE_ERROR( _("pin_del allowed for inherited pins only"),
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
*/
NeedRIGHT();
delete *it; // good thing I'm a friend.
me->pins.erase( it );
}
void SWEET_PARSER::parsePinSwap( PART* me )
{
PIN* pin1;
PIN* pin2;
wxString pad;
NeedSYMBOLorNUMBER();
pad = FromUTF8();
// lookup now while CurOffset() is still meaningful.
pin1 = me->PinFindByPad( pad );
if( !pin1 )
{
THROW_PARSE_ERROR( _("undefined pin"),
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
NeedSYMBOLorNUMBER();
pad = FromUTF8();
pin2 = me->PinFindByPad( pad );
if( !pin2 )
{
THROW_PARSE_ERROR( _("undefined pin"),
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
NeedRIGHT();
// swap only the text, but might want to swap entire PIN_TEXTs
pin2->pad.text = pin1->pad.text;
pin1->pad.text = pad;
}
void SWEET_PARSER::parsePinRenum( PART* me )
{
PIN* pin;
wxString oldPad;
wxString newPad;
NeedSYMBOLorNUMBER();
oldPad = FromUTF8();
// lookup now while CurOffset() is still meaningful.
pin = me->PinFindByPad( oldPad );
if( !pin )
{
THROW_PARSE_ERROR( _("undefined pin"),
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
NeedSYMBOLorNUMBER();
newPad = FromUTF8();
NeedRIGHT();
// @todo: check for pad legalities
pin->pad.text = newPad;
}
void SWEET_PARSER::parsePinRename( PART* me )
{
PIN* pin;
wxString pad;
wxString newSignal;
NeedSYMBOLorNUMBER();
pad = FromUTF8();
// lookup now while CurOffset() is still meaningful.
pin = me->PinFindByPad( pad );
if( !pin )
{
THROW_PARSE_ERROR( _("undefined pin"),
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
NeedSYMBOLorNUMBER();
newSignal = FromUTF8();
NeedRIGHT();
pin->signal.text = newSignal;
}
void SWEET_PARSER::parsePinMerge( PART* me )
{
T tok;
wxString pad;
wxString signal;
wxString msg;
NeedSYMBOLorNUMBER();
wxString anchorPad = FromUTF8();
// lookup now while CurOffset() is still good.
PINS::iterator pit = me->pinFindByPad( anchorPad );
if( pit == me->pins.end() )
{
msg.Printf( _( "undefined pin %s" ), anchorPad.GetData() );
THROW_PARSE_ERROR( msg,
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
if( !(*pit)->pin_merge.IsEmpty() && anchorPad != (*pit)->pin_merge )
{
msg.Printf( _( "pin %s already in pin_merge group %s" ),
anchorPad.GetData(), (*pit)->pin_merge.GetData() );
THROW_PARSE_ERROR( msg,
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
(*pit)->isVisible = true;
(*pit)->pin_merge = anchorPad;
// allocate or find a MERGE_SET;
MERGE_SET& ms = me->pin_merges[anchorPad];
while( ( tok = NextTok() ) != T_RIGHT )
{
if( tok == T_LEFT )
{
tok = NextTok();
switch( tok )
{
case T_signals:
{
PINS sigPins; // no ownership
while( ( tok = NextTok() ) != T_RIGHT )
{
if( !IsSymbol( tok ) && tok != T_NUMBER )
Expecting( "signal" );
signal = FromUTF8();
sigPins.clear();
me->PinsFindBySignal( &sigPins, signal );
if( !sigPins.size() )
{
msg.Printf( _( "no pins with signal %s" ), signal.GetData() );
THROW_PARSE_ERROR( msg,
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
for( pit = sigPins.begin(); pit != sigPins.end(); ++pit )
{
if( !(*pit)->pin_merge.IsEmpty() && anchorPad != (*pit)->pin_merge )
{
msg.Printf( _( "signal pin %s already in pin_merge group %s" ),
pad.GetData(), (*pit)->pin_merge.GetData() );
THROW_PARSE_ERROR( msg,
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
(*pit)->isVisible = true;
(*pit)->pin_merge = anchorPad;
ms.insert( pad );
}
}
}
break;
case T_pads:
while( ( tok = NextTok() ) != T_RIGHT )
{
if( !IsSymbol( tok ) && tok != T_NUMBER )
Expecting( "pad" );
pad = FromUTF8();
D(printf("pad=%s\n", TO_UTF8( pad ) );)
// find the PIN and mark it as being in this MERGE_SET or throw
// error if already in another MERGET_SET.
pit = me->pinFindByPad( pad );
if( pit == me->pins.end() )
{
msg.Printf( _( "undefined pin %s" ), pad.GetData() );
THROW_PARSE_ERROR( msg,
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
if( !(*pit)->pin_merge.IsEmpty() /* && anchorPad != (*pit)->pin_merge */ )
{
msg.Printf( _( "pin %s already in pin_merge group %s" ),
pad.GetData(), (*pit)->pin_merge.GetData() );
THROW_PARSE_ERROR( msg,
CurSource(),
CurLine(),
CurLineNumber(),
CurOffset() );
}
(*pit)->isVisible = false;
(*pit)->pin_merge = anchorPad;
ms.insert( pad );
}
break;
default:
Expecting( "pads|signals" );
break;
}
}
else
{
Expecting( T_LEFT );
}
}
}
void SWEET_PARSER::parsePropertyDel( PART* me )
{
NeedSYMBOLorNUMBER();
wxString propertyName = FromUTF8();
if( !me->PropDelete( propertyName ) )
{
wxString msg;
msg.Printf( _( "Unable to find property: %s" ), propertyName.GetData() );
THROW_IO_ERROR( msg );
}