2020-05-15 23:25:33 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 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 <fctsys.h>
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_board_item.h>
|
2020-07-30 11:24:29 +00:00
|
|
|
|
|
|
|
#include <drc/drc_rule_parser.h>
|
|
|
|
#include <drc_rules_lexer.h>
|
2020-07-21 15:49:55 +00:00
|
|
|
#include <pcb_expr_evaluator.h>
|
2020-07-30 11:24:29 +00:00
|
|
|
#include <reporter.h>
|
2020-05-15 23:25:33 +00:00
|
|
|
|
|
|
|
using namespace DRCRULE_T;
|
|
|
|
|
|
|
|
|
2020-06-10 10:57:35 +00:00
|
|
|
DRC_RULES_PARSER::DRC_RULES_PARSER( BOARD* aBoard, const wxString& aSource,
|
|
|
|
const wxString& aSourceDescr ) :
|
2020-06-10 12:41:45 +00:00
|
|
|
DRC_RULES_LEXER( aSource.ToStdString(), aSourceDescr ),
|
2020-06-10 10:57:35 +00:00
|
|
|
m_requiredVersion( 0 ),
|
2020-07-30 11:24:29 +00:00
|
|
|
m_tooRecent( false ),
|
|
|
|
m_reporter( nullptr )
|
2020-06-10 10:57:35 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-15 23:25:33 +00:00
|
|
|
DRC_RULES_PARSER::DRC_RULES_PARSER( BOARD* aBoard, FILE* aFile, const wxString& aFilename ) :
|
|
|
|
DRC_RULES_LEXER( aFile, aFilename ),
|
|
|
|
m_requiredVersion( 0 ),
|
2020-07-30 11:24:29 +00:00
|
|
|
m_tooRecent( false ),
|
|
|
|
m_reporter( nullptr )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DRC_RULES_PARSER::reportError( const wxString& aMessage )
|
|
|
|
{
|
|
|
|
wxString rest;
|
|
|
|
wxString first = aMessage.BeforeFirst( '|', &rest );
|
|
|
|
wxString msg = wxString::Format( _( "ERROR: <a href='%d:%d'>%s</a>%s" ),
|
|
|
|
CurLineNumber(),
|
|
|
|
CurOffset(),
|
|
|
|
first,
|
|
|
|
rest );
|
|
|
|
|
|
|
|
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DRC_RULES_PARSER::parseUnknown()
|
2020-06-10 10:57:35 +00:00
|
|
|
{
|
2020-07-30 11:24:29 +00:00
|
|
|
int depth = 1;
|
|
|
|
|
|
|
|
for( T token = NextTok(); token != T_EOF; token = NextTok() )
|
|
|
|
{
|
|
|
|
if( token == T_LEFT )
|
|
|
|
depth++;
|
|
|
|
|
|
|
|
if( token == T_RIGHT )
|
|
|
|
{
|
|
|
|
if( --depth == 0 )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-05-15 23:25:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-30 11:24:29 +00:00
|
|
|
void DRC_RULES_PARSER::Parse( std::vector<DRC_RULE*>& aRules, REPORTER* aReporter )
|
2020-05-15 23:25:33 +00:00
|
|
|
{
|
2020-07-30 11:24:29 +00:00
|
|
|
bool haveVersion = false;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
m_reporter = aReporter;
|
2020-05-15 23:25:33 +00:00
|
|
|
|
2020-05-17 14:44:44 +00:00
|
|
|
for( T token = NextTok(); token != T_EOF; token = NextTok() )
|
2020-05-15 23:25:33 +00:00
|
|
|
{
|
|
|
|
if( token != T_LEFT )
|
2020-07-30 11:24:29 +00:00
|
|
|
reportError( _( "Missing '('." ) );
|
2020-05-15 23:25:33 +00:00
|
|
|
|
|
|
|
token = NextTok();
|
|
|
|
|
2020-05-17 14:44:44 +00:00
|
|
|
if( !haveVersion && token != T_version )
|
2020-07-30 11:24:29 +00:00
|
|
|
{
|
|
|
|
reportError( _( "Missing version statement." ) );
|
|
|
|
haveVersion = true; // don't keep on reporting it
|
|
|
|
}
|
2020-05-17 14:44:44 +00:00
|
|
|
|
2020-05-15 23:25:33 +00:00
|
|
|
switch( token )
|
|
|
|
{
|
2020-05-17 14:44:44 +00:00
|
|
|
case T_version:
|
|
|
|
haveVersion = true;
|
2020-07-30 11:24:29 +00:00
|
|
|
token = NextTok();
|
|
|
|
|
|
|
|
if( (int) token == DSN_RIGHT )
|
|
|
|
{
|
|
|
|
reportError( _( "Missing version number." ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( (int) token == DSN_NUMBER )
|
|
|
|
{
|
|
|
|
m_requiredVersion = (int)strtol( CurText(), NULL, 10 );
|
|
|
|
m_tooRecent = ( m_requiredVersion > DRC_RULE_FILE_VERSION );
|
|
|
|
token = NextTok();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Unrecognized item '%s'.| Expected version number" ), FromUTF8() );
|
|
|
|
reportError( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( (int) token != DSN_RIGHT )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Unrecognized item '%s'." ), FromUTF8() );
|
|
|
|
reportError( msg );
|
|
|
|
parseUnknown();
|
|
|
|
}
|
|
|
|
|
2020-05-17 14:44:44 +00:00
|
|
|
break;
|
|
|
|
|
2020-05-15 23:25:33 +00:00
|
|
|
case T_rule:
|
|
|
|
aRules.push_back( parseDRC_RULE() );
|
|
|
|
break;
|
|
|
|
|
2020-08-14 19:42:21 +00:00
|
|
|
case T_EOF:
|
|
|
|
reportError( _( "Incomplete statement." ) );
|
|
|
|
break;
|
|
|
|
|
2020-05-15 23:25:33 +00:00
|
|
|
default:
|
2020-08-09 18:38:25 +00:00
|
|
|
msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ),
|
|
|
|
FromUTF8(), "'rule', 'version'" );
|
2020-07-30 11:24:29 +00:00
|
|
|
reportError( msg );
|
|
|
|
parseUnknown();
|
2020-05-15 23:25:33 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-30 11:24:29 +00:00
|
|
|
|
2020-08-06 11:54:15 +00:00
|
|
|
if( !m_reporter->HasMessage() )
|
|
|
|
m_reporter->Report( _( "No errors found." ), RPT_SEVERITY_INFO );
|
|
|
|
|
2020-07-30 11:24:29 +00:00
|
|
|
m_reporter = nullptr;
|
2020-05-15 23:25:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DRC_RULE* DRC_RULES_PARSER::parseDRC_RULE()
|
|
|
|
{
|
|
|
|
DRC_RULE* rule = new DRC_RULE();
|
2020-05-25 00:15:08 +00:00
|
|
|
T token = NextTok();
|
2020-07-30 11:24:29 +00:00
|
|
|
wxString msg;
|
2020-05-25 00:15:08 +00:00
|
|
|
|
|
|
|
if( !IsSymbol( token ) )
|
2020-07-30 11:24:29 +00:00
|
|
|
reportError( _( "Missing rule name." ) );
|
2020-05-15 23:25:33 +00:00
|
|
|
|
|
|
|
rule->m_Name = FromUTF8();
|
|
|
|
|
2020-08-14 19:42:21 +00:00
|
|
|
for( token = NextTok(); token != T_RIGHT && token != T_EOF; token = NextTok() )
|
2020-05-15 23:25:33 +00:00
|
|
|
{
|
|
|
|
if( token != T_LEFT )
|
2020-07-30 11:24:29 +00:00
|
|
|
reportError( _( "Missing '('." ) );
|
2020-05-15 23:25:33 +00:00
|
|
|
|
|
|
|
token = NextTok();
|
|
|
|
|
|
|
|
switch( token )
|
|
|
|
{
|
2020-05-23 21:48:24 +00:00
|
|
|
case T_constraint:
|
|
|
|
parseConstraint( rule );
|
|
|
|
break;
|
2020-05-15 23:25:33 +00:00
|
|
|
|
2020-05-23 21:48:24 +00:00
|
|
|
case T_condition:
|
2020-07-30 11:24:29 +00:00
|
|
|
token = NextTok();
|
2020-07-19 21:22:49 +00:00
|
|
|
|
2020-07-30 11:24:29 +00:00
|
|
|
if( (int) token == DSN_RIGHT )
|
2020-07-19 21:22:49 +00:00
|
|
|
{
|
2020-07-30 11:24:29 +00:00
|
|
|
reportError( _( "Missing condition expression." ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( IsSymbol( token ) )
|
|
|
|
{
|
|
|
|
rule->m_Condition.m_Expression = FromUTF8();
|
|
|
|
rule->m_Condition.Compile( m_reporter, CurLineNumber(), CurOffset() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Unrecognized item '%s'.| Expected quoted expression." ),
|
|
|
|
FromUTF8() );
|
|
|
|
reportError( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( (int) NextTok() != DSN_RIGHT )
|
|
|
|
{
|
|
|
|
reportError( wxString::Format( _( "Unrecognized item '%s'." ), FromUTF8() ) );
|
|
|
|
parseUnknown();
|
2020-07-19 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
2020-05-15 23:25:33 +00:00
|
|
|
break;
|
|
|
|
|
2020-07-29 11:26:27 +00:00
|
|
|
case T_layer:
|
|
|
|
rule->m_LayerCondition = parseLayer();
|
|
|
|
break;
|
|
|
|
|
2020-08-14 19:42:21 +00:00
|
|
|
case T_EOF:
|
|
|
|
reportError( _( "Incomplete statement." ) );
|
|
|
|
return rule;
|
|
|
|
|
2020-05-23 21:48:24 +00:00
|
|
|
default:
|
2020-08-09 18:38:25 +00:00
|
|
|
msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ),
|
|
|
|
FromUTF8(),
|
|
|
|
"'constraint', 'condition', 'disallow'" );
|
2020-07-30 11:24:29 +00:00
|
|
|
reportError( msg );
|
|
|
|
parseUnknown();
|
2020-05-23 21:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 19:42:21 +00:00
|
|
|
if( (int) CurTok() != DSN_RIGHT )
|
|
|
|
reportError( _( "Missing ')'." ) );
|
|
|
|
|
2020-05-23 21:48:24 +00:00
|
|
|
return rule;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DRC_RULES_PARSER::parseConstraint( DRC_RULE* aRule )
|
|
|
|
{
|
2020-08-07 20:18:33 +00:00
|
|
|
aRule->m_Constraints.emplace_back( DRC_CONSTRAINT() );
|
|
|
|
|
|
|
|
DRC_CONSTRAINT& constraint = aRule->m_Constraints.back();
|
|
|
|
int value;
|
|
|
|
wxString msg;
|
2020-07-30 11:24:29 +00:00
|
|
|
|
2020-08-07 20:18:33 +00:00
|
|
|
T token = NextTok();
|
2020-07-30 11:24:29 +00:00
|
|
|
|
2020-08-14 19:42:21 +00:00
|
|
|
if( (int) token == DSN_RIGHT || token == T_EOF )
|
2020-07-30 11:24:29 +00:00
|
|
|
{
|
2020-08-09 18:38:25 +00:00
|
|
|
msg.Printf( _( "Missing constraint type.| Expected %s." ),
|
|
|
|
"'clearance', 'track_width', 'annulus_width', 'hole', 'disallow'" );
|
|
|
|
reportError( msg );
|
2020-07-30 11:24:29 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-05-23 21:48:24 +00:00
|
|
|
|
2020-07-30 11:24:29 +00:00
|
|
|
switch( token )
|
2020-05-23 21:48:24 +00:00
|
|
|
{
|
2020-08-07 20:18:33 +00:00
|
|
|
case T_clearance: constraint.m_Type = DRC_RULE_ID_CLEARANCE; break;
|
|
|
|
case T_track_width: constraint.m_Type = DRC_RULE_ID_TRACK; break;
|
|
|
|
case T_annulus_width: constraint.m_Type = DRC_RULE_ID_ANNULUS; break;
|
|
|
|
case T_hole: constraint.m_Type = DRC_RULE_ID_HOLE_SIZE; break;
|
|
|
|
case T_disallow: constraint.m_Type = DRC_RULE_ID_DISALLOW; break;
|
2020-07-30 11:24:29 +00:00
|
|
|
default:
|
2020-08-09 18:38:25 +00:00
|
|
|
msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ),
|
|
|
|
FromUTF8(),
|
|
|
|
"'clearance', 'track_width', 'annulus_width', 'hole', 'disallow'."
|
|
|
|
);
|
2020-07-30 11:24:29 +00:00
|
|
|
reportError( msg );
|
2020-05-23 21:48:24 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 20:18:33 +00:00
|
|
|
if( constraint.m_Type == DRC_RULE_ID_DISALLOW )
|
|
|
|
{
|
|
|
|
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
|
|
|
|
{
|
|
|
|
if( (int) token == DSN_STRING )
|
|
|
|
token = GetCurStrAsToken();
|
|
|
|
|
|
|
|
switch( token )
|
|
|
|
{
|
|
|
|
case T_track: constraint.m_DisallowFlags |= DISALLOW_TRACKS; break;
|
|
|
|
case T_via: constraint.m_DisallowFlags |= DISALLOW_VIAS; break;
|
|
|
|
case T_micro_via: constraint.m_DisallowFlags |= DISALLOW_MICRO_VIAS; break;
|
|
|
|
case T_buried_via: constraint.m_DisallowFlags |= DISALLOW_BB_VIAS; break;
|
|
|
|
case T_pad: constraint.m_DisallowFlags |= DISALLOW_PADS; break;
|
|
|
|
case T_zone: constraint.m_DisallowFlags |= DISALLOW_ZONES; break;
|
|
|
|
case T_text: constraint.m_DisallowFlags |= DISALLOW_TEXTS; break;
|
|
|
|
case T_graphic: constraint.m_DisallowFlags |= DISALLOW_GRAPHICS; break;
|
|
|
|
case T_hole: constraint.m_DisallowFlags |= DISALLOW_HOLES; break;
|
|
|
|
case T_footprint: constraint.m_DisallowFlags |= DISALLOW_FOOTPRINTS; break;
|
2020-08-14 19:42:21 +00:00
|
|
|
|
|
|
|
case T_EOF:
|
|
|
|
reportError( _( "Missing ')'." ) );
|
|
|
|
return;
|
|
|
|
|
2020-08-07 20:18:33 +00:00
|
|
|
default:
|
2020-08-09 18:38:25 +00:00
|
|
|
msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ),
|
|
|
|
FromUTF8(),
|
|
|
|
"'track', 'via', 'micro_via', "
|
|
|
|
"'blind_via', 'pad', 'zone', 'text', 'graphic', 'hole'."
|
|
|
|
);
|
2020-08-07 20:18:33 +00:00
|
|
|
reportError( msg );
|
2020-08-14 19:42:21 +00:00
|
|
|
break;
|
2020-08-07 20:18:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 19:42:21 +00:00
|
|
|
if( (int) CurTok() != DSN_RIGHT )
|
|
|
|
reportError( _( "Missing ')'." ) );
|
|
|
|
|
2020-08-07 20:18:33 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-05-25 17:46:06 +00:00
|
|
|
|
2020-08-14 19:42:21 +00:00
|
|
|
for( token = NextTok(); token != T_RIGHT && token != T_EOF; token = NextTok() )
|
2020-05-23 21:48:24 +00:00
|
|
|
{
|
|
|
|
if( token != T_LEFT )
|
2020-07-30 11:24:29 +00:00
|
|
|
reportError( _( "Missing '('." ) );
|
2020-05-23 21:48:24 +00:00
|
|
|
|
|
|
|
token = NextTok();
|
|
|
|
|
|
|
|
switch( token )
|
|
|
|
{
|
|
|
|
case T_min:
|
2020-07-30 11:24:29 +00:00
|
|
|
token = NextTok();
|
|
|
|
|
|
|
|
if( (int) token == DSN_RIGHT )
|
|
|
|
{
|
|
|
|
reportError( _( "Missing min value." ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-07-21 15:49:55 +00:00
|
|
|
parseValueWithUnits( FromUTF8(), value );
|
2020-08-07 20:18:33 +00:00
|
|
|
constraint.m_Value.SetMin( value );
|
2020-05-15 23:25:33 +00:00
|
|
|
|
2020-07-30 11:24:29 +00:00
|
|
|
if( (int) NextTok() != DSN_RIGHT )
|
|
|
|
{
|
|
|
|
reportError( wxString::Format( _( "Unrecognized item '%s'." ), FromUTF8() ) );
|
|
|
|
parseUnknown();
|
|
|
|
}
|
|
|
|
|
2020-05-15 23:25:33 +00:00
|
|
|
break;
|
|
|
|
|
2020-05-23 21:48:24 +00:00
|
|
|
case T_max:
|
2020-07-30 11:24:29 +00:00
|
|
|
token = NextTok();
|
|
|
|
|
|
|
|
if( (int) token == DSN_RIGHT )
|
|
|
|
{
|
|
|
|
reportError( _( "Missing max value." ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-07-21 15:49:55 +00:00
|
|
|
parseValueWithUnits( FromUTF8(), value );
|
2020-08-07 20:18:33 +00:00
|
|
|
constraint.m_Value.SetMax( value );
|
2020-05-15 23:25:33 +00:00
|
|
|
|
2020-07-30 11:24:29 +00:00
|
|
|
if( (int) NextTok() != DSN_RIGHT )
|
|
|
|
{
|
|
|
|
reportError( wxString::Format( _( "Unrecognized item '%s'." ), FromUTF8() ) );
|
|
|
|
parseUnknown();
|
|
|
|
}
|
|
|
|
|
2020-05-15 23:25:33 +00:00
|
|
|
break;
|
|
|
|
|
2020-05-23 21:48:24 +00:00
|
|
|
case T_opt:
|
2020-07-30 11:24:29 +00:00
|
|
|
token = NextTok();
|
|
|
|
|
|
|
|
if( (int) token == DSN_RIGHT )
|
|
|
|
{
|
|
|
|
reportError( _( "Missing opt value." ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-07-21 15:49:55 +00:00
|
|
|
parseValueWithUnits( FromUTF8(), value );
|
2020-08-07 20:18:33 +00:00
|
|
|
constraint.m_Value.SetOpt( value );
|
2020-05-15 23:25:33 +00:00
|
|
|
|
2020-07-30 11:24:29 +00:00
|
|
|
if( (int) NextTok() != DSN_RIGHT )
|
|
|
|
{
|
|
|
|
reportError( wxString::Format( _( "Unrecognized item '%s'." ), FromUTF8() ) );
|
|
|
|
parseUnknown();
|
|
|
|
}
|
|
|
|
|
2020-05-15 23:25:33 +00:00
|
|
|
break;
|
|
|
|
|
2020-08-14 19:42:21 +00:00
|
|
|
case T_EOF:
|
|
|
|
reportError( _( "Incomplete statement." ) );
|
|
|
|
return;
|
|
|
|
|
2020-05-15 23:25:33 +00:00
|
|
|
default:
|
2020-08-09 18:38:25 +00:00
|
|
|
msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ),
|
|
|
|
FromUTF8(), "'min', 'max', 'opt'" );
|
2020-07-30 11:24:29 +00:00
|
|
|
reportError( msg );
|
|
|
|
parseUnknown();
|
2020-05-15 23:25:33 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-14 19:42:21 +00:00
|
|
|
|
|
|
|
if( (int) CurTok() != DSN_RIGHT )
|
|
|
|
reportError( _( "Missing ')'." ) );
|
2020-05-15 23:25:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-21 15:49:55 +00:00
|
|
|
void DRC_RULES_PARSER::parseValueWithUnits( const wxString& aExpr, int& aResult )
|
2020-05-15 23:25:33 +00:00
|
|
|
{
|
2020-08-13 17:47:41 +00:00
|
|
|
auto errorHandler = [&]( const wxString& aMessage, int aOffset )
|
|
|
|
{
|
|
|
|
wxString rest;
|
|
|
|
wxString first = aMessage.BeforeFirst( '|', &rest );
|
|
|
|
wxString msg = wxString::Format( _( "ERROR: <a href='%d:%d'>%s</a>%s" ),
|
|
|
|
CurLineNumber(),
|
|
|
|
CurOffset() + aOffset,
|
|
|
|
first,
|
|
|
|
rest );
|
|
|
|
|
|
|
|
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
|
|
|
|
};
|
|
|
|
|
2020-08-11 13:33:16 +00:00
|
|
|
PCB_EXPR_EVALUATOR evaluator;
|
2020-08-13 17:47:41 +00:00
|
|
|
evaluator.SetErrorCallback( errorHandler );
|
2020-08-11 13:33:16 +00:00
|
|
|
|
2020-07-30 11:24:29 +00:00
|
|
|
evaluator.Evaluate( aExpr );
|
2020-07-21 15:49:55 +00:00
|
|
|
aResult = evaluator.Result();
|
2020-07-29 11:26:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LSET DRC_RULES_PARSER::parseLayer()
|
|
|
|
{
|
|
|
|
LSET retVal;
|
2020-07-30 11:24:29 +00:00
|
|
|
int token = NextTok();
|
2020-07-29 11:26:27 +00:00
|
|
|
|
2020-07-30 11:24:29 +00:00
|
|
|
if( (int) token == DSN_RIGHT )
|
|
|
|
{
|
|
|
|
reportError( _( "Missing layer name or type." ) );
|
|
|
|
return LSET::AllCuMask();
|
|
|
|
}
|
|
|
|
else if( token == T_outer )
|
2020-07-29 11:26:27 +00:00
|
|
|
{
|
|
|
|
retVal = LSET::ExternalCuMask();
|
|
|
|
}
|
2020-07-30 11:24:29 +00:00
|
|
|
else if( token == T_inner )
|
2020-07-29 11:26:27 +00:00
|
|
|
{
|
|
|
|
retVal = LSET::InternalCuMask();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxString layerName = FromUTF8();
|
|
|
|
PCB_LAYER_ID layer = ENUM_MAP<PCB_LAYER_ID>::Instance().ToEnum( layerName );
|
|
|
|
|
|
|
|
if( layer == UNDEFINED_LAYER )
|
2020-07-30 11:24:29 +00:00
|
|
|
reportError( wxString::Format( _( "Unrecognized layer '%s' " ), layerName ) );
|
2020-07-29 11:26:27 +00:00
|
|
|
|
|
|
|
retVal.set( layer );
|
|
|
|
}
|
|
|
|
|
2020-07-30 11:24:29 +00:00
|
|
|
if( (int) NextTok() != DSN_RIGHT )
|
|
|
|
{
|
|
|
|
reportError( wxString::Format( _( "Unrecognized item '%s'." ), FromUTF8() ) );
|
|
|
|
parseUnknown();
|
|
|
|
}
|
|
|
|
|
2020-07-29 11:26:27 +00:00
|
|
|
return retVal;
|
|
|
|
}
|