72 return SPECCTRA_LEXER::TokenName( aTok );
88 for(
int kiNdx = layerCount - 1, pcbNdx=
FIRST_LAYER; kiNdx >= 0; --kiNdx, ++pcbNdx )
90 int kilayer = (kiNdx>0 && kiNdx==layerCount-1) ?
F_Cu : kiNdx;
93 pcbLayer2kicad[pcbNdx] = kilayer;
94 kicadLayer2pcb[kilayer] = pcbNdx;
105 if( i < layerCount-1 )
127 for(
int i = 0; i < int(
m_layerIds.size() ); ++i )
129 if( 0 == aLayerName.compare(
m_layerIds[i] ) )
141 static const char pin_def[] =
"<pin_reference>::=<component_id>-<pin_id>";
143 if( !IsSymbol( (T) CurTok() ) )
144 Expecting( pin_def );
148 if( CurTok() != T_STRING )
150 const char* toktext = CurText();
151 const char* dash = strchr( toktext,
'-' );
154 Expecting( pin_def );
156 while( toktext != dash )
157 *component_id += *toktext++;
162 *pin_id += *toktext++;
166 *component_id = CurText();
171 Expecting( pin_def );
185 static const char time_toks[] =
"<month> <day> <hour> : <minute> : <second> <year>";
187 static const char* months[] = {
188 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
189 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
nullptr
194 const char* ptok = CurText();
198 for(
int m = 0; months[m]; ++m )
200 if( !strcasecmp( months[m], ptok ) )
209 if( tok != T_NUMBER )
210 Expecting( time_toks );
212 mytime.tm_mday = atoi( CurText() );
216 if( tok != T_NUMBER )
217 Expecting( time_toks );
219 mytime.tm_hour = atoi( CurText() );
224 if( *CurText() !=
':' || strlen( CurText() )!=1 )
225 Expecting( time_toks );
229 if( tok != T_NUMBER )
230 Expecting( time_toks );
232 mytime.tm_min = atoi( CurText() );
237 if( *CurText() !=
':' || strlen( CurText() )!=1 )
238 Expecting( time_toks );
242 if( tok != T_NUMBER )
243 Expecting( time_toks );
245 mytime.tm_sec = atoi( CurText() );
249 if( tok != T_NUMBER )
250 Expecting( time_toks );
252 mytime.tm_year = atoi( CurText() ) - 1900;
254 *time_stamp = mktime( &mytime );
262 PushReader( &curr_reader );
264 if( NextTok() != T_LEFT )
267 if( NextTok() != T_pcb )
281 PushReader( &curr_reader );
283 if( NextTok() != T_LEFT )
286 if( NextTok() != T_session )
287 Expecting( T_session );
327 while( (tok = NextTok()) != T_RIGHT )
401 Unexpected( CurText() );
434 while( (tok = NextTok()) != T_RIGHT )
446 if( tok != T_QUOTE_DEF )
447 Expecting( T_QUOTE_DEF );
449 SetStringDelimiter( (
unsigned char) *CurText() );
455 case T_space_in_quoted_tokens:
458 if( tok!=T_on && tok!=T_off )
459 Expecting(
"on|off" );
461 SetSpaceInQuotedTokens( tok==T_on );
473 NeedSYMBOLorNUMBER();
479 NeedSYMBOLorNUMBER();
481 NeedSYMBOLorNUMBER();
488 case T_write_resolution:
489 while( (tok = NextTok()) != T_RIGHT )
492 Expecting( T_SYMBOL );
497 Expecting( T_NUMBER );
504 case T_routes_include:
505 while( (tok = NextTok()) != T_RIGHT )
515 case T_image_conductor:
519 Expecting(
"testpoint|guides|image_conductor" );
525 case T_wires_include:
528 if( tok != T_testpoint )
529 Expecting( T_testpoint );
535 case T_case_sensitive:
538 if( tok!=T_on && tok!=T_off )
539 Expecting(
"on|off" );
545 case T_via_rotate_first:
548 if( tok!=T_on && tok!=T_off )
549 Expecting(
"on|off" );
555 case T_generated_by_freeroute:
561 Unexpected( CurText() );
581 Expecting(
"inch|mil|cm|mm|um" );
586 if( tok != T_NUMBER )
587 Expecting( T_NUMBER );
589 growth->
value = atoi( CurText() );
609 Expecting(
"inch|mil|cm|mm|um" );
624 if( NextTok() != T_NUMBER )
625 Expecting( T_NUMBER );
638 while( ( tok = NextTok() ) != T_RIGHT )
643 if( NextTok() != T_layer_pair )
644 Expecting( T_layer_pair );
657 while( ( tok = NextTok() ) != T_RIGHT )
682 case T_layer_noise_weight:
690 case T_place_boundary:
715 growth->
planes.push_back( plane );
721 region =
new REGION( growth );
722 growth->
regions.push_back( region );
728 stringprop =
new STRINGPROP( growth, T_snap_angle );
729 growth->
Append( stringprop );
737 growth->
via =
new VIA( growth );
751 layer =
new LAYER( growth );
752 growth->
layers.push_back( layer );
760 growth->
rules =
new RULE( growth, T_rule );
773 case T_place_keepout:
777 case T_elongate_keepout:
779 keepout =
new KEEPOUT( growth, tok );
780 growth->
keepouts.push_back( keepout );
792 Unexpected( CurText() );
810 while( tok != T_RIGHT )
821 layer =
new LAYER( growth );
822 growth->
layers.push_back( layer );
830 growth->
rules =
new RULE( growth, T_rule );
835 Unexpected( CurText() );
849 growth->
name = CurText();
856 while( tok != T_RIGHT )
865 case T_sequence_number:
866 if( NextTok() != T_NUMBER )
867 Expecting( T_NUMBER );
877 growth->
rules =
new RULE( growth, T_rule );
905 case T_polyline_path:
928 window =
new WINDOW( growth );
929 growth->
windows.push_back( window );
934 Unexpected( CurText() );
953 while( tok != T_RIGHT )
964 while( ( tok = NextTok() ) != T_RIGHT && tok != T_EOF )
969 Unexpected( CurText() );
981 while( tok != T_RIGHT )
1006 case T_polyline_path:
1015 growth->
shape =
new PATH( growth, tok );
1028 Unexpected( CurText() );
1041 Expecting( T_LEFT );
1047 if( growth->
paths.size() )
1048 Unexpected(
"rect when path already encountered" );
1054 else if( tok == T_path )
1057 Unexpected(
"path when rect already encountered" );
1062 Expecting( T_path );
1070 if( tok == T_RIGHT )
1081 Expecting(
"rect|path" );
1090 if( !IsSymbol( tok ) && tok != T_NUMBER )
1091 Expecting(
"layer_id" );
1095 if( NextTok() != T_NUMBER )
1096 Expecting(
"aperture_width" );
1106 if( tok != T_NUMBER )
1107 Expecting( T_NUMBER );
1109 ptTemp.
x = strtod( CurText(),
nullptr );
1111 if( NextTok() != T_NUMBER )
1112 Expecting( T_NUMBER );
1114 ptTemp.
y = strtod( CurText(),
nullptr );
1116 growth->
points.push_back( ptTemp );
1118 }
while( ( tok = NextTok() ) != T_RIGHT && tok != T_LEFT );
1122 if( NextTok() != T_aperture_type )
1123 Expecting( T_aperture_type );
1127 if( tok!=T_round && tok!=T_square )
1128 Expecting(
"round|square" );
1142 if( NextTok() != T_NUMBER )
1143 Expecting( T_NUMBER );
1145 growth->
point0.
x = strtod( CurText(),
nullptr );
1147 if( NextTok() != T_NUMBER )
1148 Expecting( T_NUMBER );
1150 growth->
point0.
y = strtod( CurText(),
nullptr );
1152 if( NextTok() != T_NUMBER )
1153 Expecting( T_NUMBER );
1155 growth->
point1.
x = strtod( CurText(),
nullptr );
1157 if( NextTok() != T_NUMBER )
1158 Expecting( T_NUMBER );
1160 growth->
point1.
y = strtod( CurText(),
nullptr );
1170 NeedSYMBOLorNUMBER();
1173 if( NextTok() != T_NUMBER )
1174 Expecting( T_NUMBER );
1176 growth->
diameter = strtod( CurText(), 0 );
1180 if( tok == T_NUMBER )
1182 growth->
vertex.
x = strtod( CurText(), 0 );
1184 if( NextTok() != T_NUMBER )
1185 Expecting( T_NUMBER );
1187 growth->
vertex.
y = strtod( CurText(), 0 );
1192 if( tok != T_RIGHT )
1193 Expecting( T_RIGHT );
1202 if( NextTok() != T_NUMBER )
1203 Expecting( T_NUMBER );
1207 for(
int i = 0; i < 3; ++i )
1209 if( NextTok() != T_NUMBER )
1210 Expecting( T_NUMBER );
1212 growth->
vertex[i].
x = strtod( CurText(), 0 );
1214 if( NextTok() != T_NUMBER )
1215 Expecting( T_NUMBER );
1217 growth->
vertex[i].
y = strtod( CurText(), 0 );
1227 growth->
value = CurText();
1237 Unexpected( CurText() );
1239 growth->
value = tok;
1249 while( ( tok = NextTok() ) != T_RIGHT )
1253 if( NextTok() != T_spare )
1254 Expecting( T_spare );
1256 while( (tok = NextTok()) != T_RIGHT )
1258 if( !IsSymbol( tok ) )
1259 Expecting( T_SYMBOL );
1261 growth->
spares.push_back( CurText() );
1264 else if( IsSymbol( tok ) )
1266 growth->
padstacks.push_back( CurText() );
1270 Unexpected( CurText() );
1280 while( (tok = NextTok()) != T_RIGHT )
1283 Expecting( T_LEFT );
1292 if( tok!=T_on && tok!=T_off )
1293 Expecting(
"on|off" );
1300 case T_route_to_fanout_only:
1301 case T_force_to_terminal_point:
1302 case T_same_net_checking:
1303 case T_checking_trim_by_pin:
1304 case T_noise_calculation:
1305 case T_noise_accumulation:
1306 case T_include_pins_in_crosstalk:
1308 case T_average_pair_length:
1309 case T_crosstalk_model:
1310 case T_roundoff_rotation:
1312 case T_reroute_order_viols:
1314 tokprop =
new TOKPROP( growth, tok );
1315 growth->
Append( tokprop );
1320 Unexpected( CurText() );
1331 while( ( tok = NextTok() ) != T_RIGHT )
1334 Expecting( T_LEFT );
1336 NeedSYMBOLorNUMBER();
1337 property.name = CurText();
1339 NeedSYMBOLorNUMBER();
1340 property.value = CurText();
1342 growth->push_back( property );
1353 if( !IsSymbol( tok ) )
1354 Expecting( T_SYMBOL );
1356 growth->
name = CurText();
1358 while( ( tok = NextTok() ) != T_RIGHT )
1361 Expecting( T_LEFT );
1370 if( tok != T_signal && tok != T_power && tok != T_mixed && tok != T_jumper )
1371 Expecting(
"signal|power|mixed|jumper" );
1375 if( NextTok()!=T_RIGHT )
1381 growth->
rules =
new RULE( growth, T_rule );
1397 case T_positive_diagonal:
1398 case T_negative_diagonal:
1405 if( !strcmp(
"hori", CurText() ) )
1410 else if( !strcmp(
"vert", CurText() ) )
1416 Expecting(
"horizontal|vertical|orthogonal|positive_diagonal|negative_diagonal|"
1420 if( NextTok() != T_RIGHT )
1421 Expecting( T_RIGHT );
1440 growth->
cost = -atoi( CurText() );
1443 Expecting(
"forbidden|high|medium|low|free|<positive_integer>|-1" );
1450 if( NextTok() != T_type )
1451 Unexpected( CurText() );
1455 if( tok!=T_length && tok!=T_way )
1456 Expecting(
"length|way" );
1460 if( NextTok()!=T_RIGHT )
1461 Expecting( T_RIGHT );
1466 if( tok != T_RIGHT )
1467 Expecting( T_RIGHT );
1472 while( ( tok = NextTok() ) != T_RIGHT )
1474 if( !IsSymbol( tok ) )
1475 Expecting( T_SYMBOL );
1477 growth->
use_net.push_back( CurText() );
1483 Unexpected( CurText() );
1491 std::string builder;
1492 int bracketNesting = 1;
1495 while( bracketNesting != 0 && tok != T_EOF )
1501 else if( tok==T_RIGHT )
1504 if( bracketNesting >= 1 )
1506 if( PrevTok() != T_LEFT && tok != T_RIGHT && ( tok != T_LEFT || bracketNesting > 2 ) )
1509 if( tok == T_STRING )
1512 builder += CurText();
1514 if( tok == T_STRING )
1521 if( bracketNesting == 1 )
1523 growth->
rules.push_back( builder );
1529 Unexpected( T_EOF );
1534void SPECCTRA_DB::doPLACE_RULE( PLACE_RULE* growth,
bool expect_object_type )
1547 Expecting( T_LEFT );
1551 if( tok == T_object_type )
1553 if( !expect_object_type )
1568 growth->object_type = tok;
1581 growth->object_type = tok;
1584 Unexpected( CurText() );
1590 Unexpected( CurText() );
1599 if( tok != T_image_type )
1600 Expecting( T_image_type );
1604 if( tok!=T_smd && tok!=T_pin )
1605 Expecting(
"smd|pin" );
1612 if( tok != T_RIGHT )
1613 Expecting( T_RIGHT );
1631 if( IsSymbol( tok ) )
1640 Expecting( T_LEFT );
1663 case T_region_class:
1666 growth->
Append( stringprop );
1670 case T_region_class_class:
1673 growth->
Append( class_class );
1681 growth->
rules =
new RULE( growth, T_rule );
1686 Unexpected( CurText() );
1691 if( tok == T_RIGHT )
1693 if( !growth->
rules )
1694 Expecting( T_rule );
1707 Expecting( T_LEFT );
1709 while( ( tok = NextTok() ) != T_RIGHT )
1723 if( growth->
Type() == T_region_class_class )
1727 rule =
new RULE( growth, T_rule );
1734 if( growth->
Type() == T_region_class_class )
1739 growth->
Append( layer_rule );
1756 if( !IsSymbol( tok ) )
1757 Expecting(
"class_id" );
1759 growth->
class_ids.push_back( CurText() );
1765 if( !IsSymbol( tok ) )
1766 Expecting(
"class_id" );
1768 growth->
class_ids.push_back( CurText() );
1770 }
while( ( tok = NextTok() ) != T_RIGHT );
1787 if( NextTok() != T_NUMBER )
1788 Expecting( T_NUMBER );
1790 growth->
dimension = strtod( CurText(), 0 );
1795 while( ( tok = NextTok() ) != T_RIGHT )
1797 if( tok == T_direction )
1804 if( tok != T_x && tok != T_y )
1805 Unexpected( CurText() );
1809 if( NextTok() != T_RIGHT )
1812 else if( tok == T_offset )
1817 if( NextTok() != T_NUMBER )
1818 Expecting( T_NUMBER );
1820 growth->
offset = strtod( CurText(), 0 );
1822 if( NextTok() != T_RIGHT )
1823 Expecting( T_RIGHT );
1825 else if( tok == T_image_type )
1832 if( tok != T_smd && tok != T_pin )
1833 Unexpected( CurText() );
1837 if( NextTok() != T_RIGHT )
1838 Expecting( T_RIGHT );
1859 growth->
layer_ids.push_back( CurText() );
1861 }
while( IsSymbol( tok = NextTok() ) );
1864 Expecting( T_LEFT );
1866 if( NextTok() != T_rule )
1867 Expecting( T_rule );
1869 growth->
rule =
new RULE( growth, T_rule );
1880 if( !IsSymbol( tok ) )
1881 Expecting(
"component_id" );
1887 if( tok == T_NUMBER )
1891 point.
x = strtod( CurText(), 0 );
1893 if( NextTok() != T_NUMBER )
1894 Expecting( T_NUMBER );
1896 point.
y = strtod( CurText(), 0 );
1902 if( tok != T_front && tok != T_back )
1903 Expecting(
"front|back" );
1907 if( NextTok() != T_NUMBER )
1908 Expecting(
"rotation" );
1913 while( ( tok = NextTok() ) != T_RIGHT )
1916 Expecting( T_LEFT );
1925 if( tok == T_x || tok == T_y || tok == T_xy || tok == T_off )
1928 Expecting(
"x|y|xy|off" );
1935 if( tok==T_added || tok==T_deleted || tok==T_substituted )
1938 Expecting(
"added|deleted|substituted");
1942 case T_logical_part:
1948 if( !IsSymbol( tok ) )
1949 Expecting(
"logical_part_id");
1972 if( tok == T_position || tok == T_gate || tok == T_subgate || tok == T_pin )
1975 Expecting(
"position|gate|subgate|pin" );
1983 growth->
rules =
new RULE( growth, T_rule );
1999 NeedSYMBOLorNUMBER();
2015 if( !IsSymbol( tok ) && tok != T_NUMBER )
2016 Expecting(
"image_id" );
2020 while( ( tok = NextTok() ) != T_RIGHT )
2023 Expecting( T_LEFT );
2031 place =
new PLACE( growth );
2032 growth->
places.push_back( place );
2047 while( ( tok = NextTok() ) != T_RIGHT )
2050 Unexpected( T_EOF );
2053 Expecting( T_LEFT );
2063 if( tok == T_resolution )
2069 case T_place_control:
2073 if( tok != T_flip_style )
2074 Expecting( T_flip_style );
2078 if( tok == T_mirror_first || tok == T_rotate_first )
2081 Expecting(
"mirror_first|rotate_first" );
2120 if( !IsSymbol( tok ) && tok != T_NUMBER )
2121 Expecting(
"padstack_id" );
2125 while( ( tok = NextTok() ) != T_RIGHT )
2128 Expecting( T_LEFT );
2145 if( tok != T_on && tok != T_off )
2146 Expecting(
"on|off" );
2155 if( tok != T_on && tok != T_off )
2156 Expecting(
"on|off" );
2164 shape =
new SHAPE( growth );
2172 if( tok != T_off && tok != T_on )
2173 Expecting(
"off|on" );
2180 if( NextTok() != T_use_via )
2181 Expecting( T_use_via );
2184 growth->
via_id = CurText();
2202 growth->
rules =
new RULE( growth, T_rule );
2207 Unexpected( CurText() );
2223 while( ( tok = NextTok() ) != T_RIGHT )
2226 Expecting( T_LEFT );
2232 case T_polyline_path:
2249 if( !strcmp(
"circ", CurText() ) )
2270 growth->
shape =
new PATH( growth, tok );
2281 if( tok!=T_on && tok!=T_off )
2282 Expecting(
"on|off" );
2289 window =
new WINDOW( growth );
2290 growth->
windows.push_back( window );
2295 Unexpected( CurText() );
2322 if( !IsSymbol( tok ) && tok != T_NUMBER )
2323 Expecting(
"image_id" );
2327 while( ( tok = NextTok() ) != T_RIGHT )
2330 Expecting( T_LEFT );
2347 if( tok != T_front && tok != T_back && tok != T_both )
2348 Expecting(
"front|back|both" );
2356 outline =
new SHAPE( growth, T_outline );
2357 growth->
Append( outline );
2364 growth->
pins.push_back(
pin );
2372 growth->
rules =
new RULE( growth, tok );
2385 case T_place_keepout:
2387 case T_wire_keepout:
2388 case T_bend_keepout:
2389 case T_elongate_keepout:
2391 keepout =
new KEEPOUT( growth, tok );
2392 growth->
keepouts.push_back( keepout );
2397 Unexpected( CurText() );
2413 if( !IsSymbol( tok ) && tok!=T_NUMBER )
2414 Expecting(
"padstack_id" );
2418 while( ( tok = NextTok() ) != T_RIGHT )
2424 if( tok != T_rotate )
2425 Expecting( T_rotate );
2427 if( NextTok() != T_NUMBER )
2428 Expecting( T_NUMBER );
2435 if( !IsSymbol( tok ) && tok != T_NUMBER )
2436 Expecting(
"pin_id" );
2438 growth->
pin_id = CurText();
2440 if( NextTok() != T_NUMBER )
2441 Expecting( T_NUMBER );
2443 growth->
vertex.
x = strtod( CurText(), 0 );
2445 if( NextTok() != T_NUMBER )
2446 Expecting( T_NUMBER );
2448 growth->
vertex.
y = strtod( CurText(), 0 );
2472 while( ( tok = NextTok() ) != T_RIGHT )
2475 Expecting( T_LEFT );
2504 Unexpected( CurText() );
2536 if( !IsSymbol( tok ) )
2537 Expecting(
"net_id" );
2539 growth->
net_id = CurText();
2541 while( ( tok = NextTok() ) != T_RIGHT )
2544 Expecting( T_LEFT );
2556 if( NextTok() != T_NUMBER )
2557 Expecting( T_NUMBER );
2566 pin_refs = &growth->
pins;
2570 pin_refs = &growth->
expose;
2578 pin_refs = &growth->
source;
2582 pin_refs = &growth->
load;
2593 while( ( tok = NextTok() ) != T_RIGHT )
2596 pin_refs->push_back(
empty );
2598 PIN_REF* pin_ref = &pin_refs->back();
2617 if( tok!=T_fix && tok!=T_normal )
2618 Expecting(
"fix|normal" );
2633 growth->
rules =
new RULE( growth, T_rule );
2646 fromto =
new FROMTO( growth );
2647 growth->
fromtos.push_back( fromto );
2652 Unexpected( CurText() );
2667 while( ( tok = NextTok() ) != T_RIGHT )
2670 Expecting( T_LEFT );
2678 fromto =
new FROMTO( growth );
2679 growth->
fromtos.push_back( fromto );
2691 Unexpected( CurText() );
2716 while( IsSymbol( tok = NextTok() ) )
2718 growth->
net_ids.push_back( CurText() );
2722 while( tok != T_RIGHT )
2725 Expecting( T_LEFT );
2735 growth->
rules =
new RULE( growth, T_rule );
2756 std::string builder;
2757 int bracketNesting = 1;
2760 while( bracketNesting != 0 && tok != T_EOF )
2766 else if( tok == T_RIGHT )
2769 if( bracketNesting >= 1 )
2771 T previousTok = (T) PrevTok();
2773 if( previousTok != T_LEFT && previousTok != T_circuit && tok != T_RIGHT )
2776 if( tok == T_STRING )
2779 builder += CurText();
2781 if( tok == T_STRING )
2787 if( bracketNesting == 0 )
2789 growth->
circuit.push_back( builder );
2795 Unexpected( T_EOF );
2801 Unexpected( CurText() );
2826 while( ( tok = NextTok() ) != T_RIGHT )
2829 Expecting( T_LEFT );
2837 net =
new NET( growth );
2838 growth->
nets.push_back( net );
2844 myclass =
new CLASS( growth );
2845 growth->
classes.push_back( myclass );
2850 Unexpected( CurText() );
2864 while( IsSymbol( tok = NextTok() ) )
2869 if( tok != T_RIGHT )
2870 Expecting( T_RIGHT );
2895 char old = SetStringDelimiter( 0 );
2897 if( !IsSymbol(NextTok() ) )
2899 SetStringDelimiter( old );
2900 Expecting( T_SYMBOL );
2905 if( !IsSymbol(NextTok() ) )
2907 SetStringDelimiter( old );
2908 Expecting( T_SYMBOL );
2911 growth->
toText = CurText();
2913 SetStringDelimiter( old );
2915 while( ( tok = NextTok() ) != T_RIGHT )
2918 Expecting( T_LEFT );
2927 if( tok != T_fix && tok != T_normal && tok != T_soft )
2928 Expecting(
"fix|normal|soft" );
2938 growth->
rules =
new RULE( growth, T_rule );
2950 if( growth->
net_id.size() )
2954 growth->
net_id = CurText();
2961 Unexpected( CurText() );
2988 while( ( tok = NextTok() ) != T_RIGHT )
2991 Expecting( T_LEFT );
3013 case T_polyline_path:
3022 growth->
shape =
new PATH( growth, tok );
3035 NeedSYMBOLorNUMBER();
3036 growth->
net_id = CurText();
3041 if( NextTok() != T_NUMBER )
3042 Expecting( T_NUMBER );
3044 growth->
turret = atoi( CurText() );
3051 if( tok != T_fix && tok != T_route && tok != T_normal && tok != T_protect )
3052 Expecting(
"fix|route|normal|protect" );
3061 if( tok != T_test && tok != T_fanout && tok != T_bus && tok != T_jumper )
3062 Expecting(
"test|fanout|bus|jumper" );
3070 growth->
shield = CurText();
3076 window =
new WINDOW( growth );
3077 growth->
windows.push_back( window );
3095 Unexpected( CurText() );
3125 while( ( tok = NextTok() ) == T_NUMBER )
3127 point.
x = strtod( CurText(), 0 );
3129 if( NextTok() != T_NUMBER )
3130 Expecting(
"vertex.y" );
3132 point.
y = strtod( CurText(), 0 );
3134 growth->
vertexes.push_back( point );
3137 while( tok != T_RIGHT )
3140 Expecting( T_LEFT );
3148 growth->
net_id = CurText();
3153 if( NextTok() != T_NUMBER )
3154 Expecting(
"<via#>" );
3163 if( tok != T_fix && tok != T_route && tok != T_normal && tok != T_protect )
3164 Expecting(
"fix|route|normal|protect" );
3173 if( tok != T_test && tok != T_fanout && tok != T_jumper && tok != T_virtual_pin )
3174 Expecting(
"test|fanout|jumper|virtual_pin" );
3178 if( tok == T_virtual_pin )
3191 while( IsSymbol( tok ) )
3197 if( tok != T_RIGHT )
3198 Expecting( T_RIGHT );
3208 Unexpected( CurText() );
3229 while( ( tok = NextTok() ) != T_RIGHT )
3232 Expecting( T_LEFT );
3256 wire =
new WIRE( growth );
3257 growth->
wires.push_back( wire );
3264 growth->
wire_vias.push_back( wire_via );
3269 Unexpected( CurText() );
3287 while( ( tok = NextTok() ) != T_RIGHT )
3290 Expecting( T_LEFT );
3296 case T_created_time:
3308 Unexpected( CurText() );
3322 while( ( tok = NextTok() ) != T_RIGHT )
3325 Expecting( T_LEFT );
3334 growth->
ancestors.push_back( ancestor );
3339 while( ( tok = NextTok() ) != T_RIGHT )
3342 Expecting( T_LEFT );
3348 case T_created_time:
3355 growth->
comments.push_back( CurText() );
3360 Unexpected( CurText() );
3367 Unexpected( CurText() );
3394 while( ( tok = NextTok() ) != T_RIGHT )
3397 Expecting( T_LEFT );
3450 Unexpected( CurText() );
3467 while( ( tok = NextTok() ) != T_RIGHT )
3470 Expecting( T_LEFT );
3491 Unexpected( CurText() );
3512 while( ( tok = NextTok() ) != T_RIGHT )
3515 Expecting( T_LEFT );
3544 case T_structure_out:
3561 while( ( tok = NextTok() ) != T_RIGHT )
3564 Expecting( T_LEFT );
3569 Unexpected( CurText() );
3572 net_out =
new NET_OUT( growth );
3574 growth->
net_outs.push_back( net_out );
3581 Unexpected( CurText() );
3601 NeedSYMBOLorNUMBER();
3602 growth->
net_id = CurText();
3604 while( ( tok = NextTok() ) != T_RIGHT )
3607 Expecting( T_LEFT );
3616 if( tok!= T_NUMBER )
3617 Expecting( T_NUMBER );
3627 growth->
rules =
new RULE( growth, tok );
3633 wire =
new WIRE( growth );
3634 growth->
wires.push_back( wire );
3641 growth->
wire_vias.push_back( wire_via );
3653 Unexpected( CurText() );
3669 growth->
net_id = CurText();
3671 while( ( tok = NextTok() ) != T_RIGHT )
3681 else if( tok == T_LEFT )
3688 growth->
net_id = CurText();
3692 Unexpected( CurText() );
3762 return SPECCTRA_DB::TokenName(
type );
3776 out->
Print( nestLevel,
"(%s\n",
Name() );
3780 out->
Print( nestLevel,
")\n" );
3786 for(
int i = 0; i <
Length(); ++i )
3795 for(
unsigned i = 0; i <
kids.size(); ++i )
3799 if( repeats == instanceNum )
3819 if( !lhs->
hash.size() )
3822 if( !rhs->
hash.size() )
3825 int result = lhs->
hash.compare( rhs->
hash );
3840 if( !lhs->
hash.size() )
3843 if( !rhs->
hash.size() )
3846 int result = lhs->
hash.compare( rhs->
hash );
3867 ELEM( T_parser, aParent )
3890 out->
Print( nestLevel,
"(host_cad \"%s\")\n",
host_cad.c_str() );
3895 const std::string& s1 = *i++;
3896 const std::string& s2 = *i++;
3900 out->
Print( nestLevel,
"(constant %s%s%s %s%s%s)\n",
3901 q1, s1.c_str(), q1, q2, s2.c_str(), q2 );
3906 out->
Print( nestLevel,
"(routes_include%s%s%s)\n",
3913 out->
Print( nestLevel,
"(wires_include testpoint)\n" );
3916 out->
Print( nestLevel,
"(via_rotate_first off)\n" );
3931 useMultiLine =
true;
3934 out->
Print( nestLevel+1,
"%s",
"" );
3938 useMultiLine =
false;
3950 const char* space =
" ";
3967 out->
Print( 0,
"%s(logical_part %s%s%s)", space, quote,
logical_part.c_str(), quote );
3973 out->
Print( 0,
"\n" );
3982 out->
Print( nestLevel + 1,
"(property \n" );
3985 i->Format( out, nestLevel + 2 );
3987 out->
Print( nestLevel + 1,
")\n" );
4002 out->
Print( nestLevel + 1,
"(PN %s%s%s)\n", quote,
part_number.c_str(), quote );
4016 out->
Print( 0,
"%s(PN %s%s%s)", space, quote,
part_number.c_str(), quote );
4020 out->
Print( 0,
")\n" );
wxString GetBuildVersion()
Get the full KiCad version string.
Information pertinent to a Pcbnew printed circuit board.
int GetCopperLayerCount() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
The <class_descriptor> in the specctra spec.
STRINGS circuit
circuit descriptor list
Implement a <component_descriptor> in the specctra dsn spec.
The <component_order_descriptor>.
A <plane_descriptor> in the specctra dsn spec.
int FindElem(DSN_T aType, int instanceNum=0)
Find a particular instance number of a given type of ELEM.
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
ELEM_ARRAY kids
ELEM pointers.
ELEM * At(int aIndex) const
int Length() const
Return the number of ELEMs in this holder.
A base class for any DSN element class.
std::string makeHash()
Return a string which uniquely represents this ELEM among other ELEMs of the same derived class as "t...
const char * Name() const
virtual void Format(OUTPUTFORMATTER *out, int nestLevel)
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
virtual UNIT_RES * GetUnits() const
Return the units for this section.
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel)
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
ELEM(DSN_T aType, ELEM *aParent=0)
static STRING_FORMATTER sf
DSN_T direction
T_x | T_y | -1 for both.
DSN_T grid_type
T_via | T_wire | T_via_keepout | T_place | T_snap.
std::string hash
a hash string used by Compare(), not Format()ed/exported.
static int Compare(IMAGE *lhs, IMAGE *rhs)
Compare two objects of this type and returns <0, 0, or >0.
Used for <keepout_descriptor> and <plane_descriptor>.
SPECCTRA_LAYER_PAIRS layer_pairs
DSN_T layer_type
one of: T_signal, T_power, T_mixed, T_jumper
int cost_type
T_length | T_way.
int direction
[forbidden | high | medium | low | free | <positive_integer> | -1]
A <library_descriptor> in the specctra dsn specification.
void AddPadstack(PADSTACK *aPadstack)
A <net_out_descriptor> of the specctra dsn spec.
A <net_descriptor> in the DSN spec.
DSN_T pins_type
T_pins | T_order, type of field 'pins' below.
DSN_T type
T_fix | T_normal.
Hold either a via or a pad definition.
static int Compare(PADSTACK *lhs, PADSTACK *rhs)
Compare two objects of this type and returns <0, 0, or >0.
std::string hash
a hash string used by Compare(), not Format()ed/exported.
A configuration record per the SPECCTRA DSN file spec.
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
bool routes_include_image_conductor
bool routes_include_guides
bool wires_include_testpoint
STRINGS constants
This holds pairs of strings, one pair for each constant definition.
bool routes_include_testpoint
bool generated_by_freeroute
bool space_in_quoted_tokens
Support both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
void SetRotation(double aRotation)
Implement a <placement_reference> in the specctra dsn spec.
void SetVertex(const POINT &aVertex)
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
std::string component_id
reference designator
void SetRotation(double aRotation)
POINT point0
one of two opposite corners
STRUCTURE_OUT * structure_out
A <rule_descriptor> in the specctra dsn spec.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
STRINGS rules
rules are saved in std::string form.
A <session_file_descriptor> in the specctra dsn spec.
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
A "(shape ..)" element in the specctra dsn spec.
void doUNIT(UNIT_RES *growth)
void doCOMPONENT(COMPONENT *growth)
void doWAS_IS(WAS_IS *growth)
void doPLACEMENT(PLACEMENT *growth)
void doNET_OUT(NET_OUT *growth)
void buildLayerMaps(BOARD *aBoard)
Create a few data translation structures for layer name and number mapping between the DSN::PCB struc...
void doCLASS(CLASS *growth)
void SetSESSION(SESSION *aSession)
Delete any existing SESSION and replaces it with the given one.
void doSTRUCTURE_OUT(STRUCTURE_OUT *growth)
void doCIRCLE(CIRCLE *growth)
void doANCESTOR(ANCESTOR *growth)
void doLAYER_NOISE_WEIGHT(LAYER_NOISE_WEIGHT *growth)
void ExportPCB(const wxString &aFilename, bool aNameChange=false)
Write the internal PCB instance out as a SPECTRA DSN format file.
void doCLASS_CLASS(CLASS_CLASS *growth)
void doSESSION(SESSION *growth)
void doWINDOW(WINDOW *growth)
void doSHAPE(SHAPE *growth)
void doQARC(QARC *growth)
void doRESOLUTION(UNIT_RES *growth)
void LoadPCB(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "design" file.
void doSTRINGPROP(STRINGPROP *growth)
STRINGS m_layerIds
indexed by PCB layer number
void doBOUNDARY(BOUNDARY *growth)
void doSPECCTRA_LAYER_PAIR(SPECCTRA_LAYER_PAIR *growth)
void doRECTANGLE(RECTANGLE *growth)
void doREGION(REGION *growth)
void ExportSESSION(const wxString &aFilename)
Write the internal #SESSION instance out as a #SPECTRA DSN format file.
void doWIRE(WIRE *growth)
void SetPCB(PCB *aPcb)
Delete any existing PCB and replaces it with the given one.
void doTOKPROP(TOKPROP *growth)
void doIMAGE(IMAGE *growth)
void doCONNECT(CONNECT *growth)
void doCOMP_ORDER(COMP_ORDER *growth)
static PCB * MakePCB()
Make a PCB with all the default ELEMs and parts on the heap.
void doTOPOLOGY(TOPOLOGY *growth)
void doKEEPOUT(KEEPOUT *growth)
void doRULE(RULE *growth)
void doPATH(PATH *growth)
std::vector< PCB_LAYER_ID > m_pcbLayer2kicad
maps PCB layer number to BOARD layer numbers
void doSUPPLY_PIN(SUPPLY_PIN *growth)
void doLAYER(LAYER *growth)
void LoadSESSION(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "session" file.
void doLIBRARY(LIBRARY *growth)
std::vector< int > m_kicadLayer2pcb
maps BOARD layer number to PCB layer numbers
void doFROMTO(FROMTO *growth)
void doPLACE(PLACE *growth)
void doGRID(GRID *growth)
void doLAYER_RULE(LAYER_RULE *growth)
void doWIRE_VIA(WIRE_VIA *growth)
void doCLASSES(CLASSES *growth)
void readCOMPnPIN(std::string *component_id, std::string *pid_id)
Read a <pin_reference> and splits it into the two parts which are on either side of the hyphen.
void doPARSER(PARSER *growth)
void doNETWORK(NETWORK *growth)
void doSTRUCTURE(STRUCTURE *growth)
int findLayerName(const std::string &aLayerName) const
Return the PCB layer index for a given layer name, within the specctra sessionfile.
void doROUTE(ROUTE *growth)
void readTIME(time_t *time_stamp)
Read a <time_stamp> which consists of 8 lexer tokens: "month date hour : minute : second year".
void doPADSTACK(PADSTACK *growth)
void doWIRING(WIRING *growth)
void doHISTORY(HISTORY *growth)
void doCONTROL(CONTROL *growth)
void doPROPERTIES(PROPERTIES *growth)
A container for a single property whose value is a string.
BOUNDARY * place_boundary
LAYER_NOISE_WEIGHT * layer_noise_weight
A <supply_pin_descriptor> in the specctra dsn spec.
A container for a single property whose value is another DSN_T token.
A holder for either a T_unit or T_resolution object which are usually mutually exclusive in the dsn g...
static UNIT_RES Default
A static instance which holds the default units of T_inch and 2540000.
A <via_descriptor> in the specctra dsn spec.
A <was_is_descriptor> in the specctra dsn spec.
A <wire_via_descriptor> in the specctra dsn spec.
std::string virtual_pin_name
A <wire_shape_descriptor> in the specctra dsn spec.
A <wiring_descriptor> in the specctra dsn spec.
A LINE_READER that reads from an open file.
static bool empty(const wxTextEntryBase *aCtrl)
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
This source file implements export and import capabilities to the specctra dsn file format.
std::vector< PIN_REF > PIN_REFS
const char * GetTokenText(T aTok)
The DSN namespace and returns the C string representing a SPECCTRA_DB::keyword.
std::vector< PROPERTY > PROPERTIES
@ NET
This item represents a net.
Used within the WAS_IS class below to hold a pair of PIN_REFs and corresponds to the (pins was is) co...
A <pin_reference> definition in the specctra dsn spec.
A point in the SPECCTRA DSN coordinate system.