Add layer to rule grammar.
This commit is contained in:
parent
cdaa866428
commit
5a1b1c544a
|
@ -8,6 +8,8 @@ disallow
|
||||||
footprint
|
footprint
|
||||||
graphic
|
graphic
|
||||||
hole
|
hole
|
||||||
|
inner
|
||||||
|
layer
|
||||||
match_area
|
match_area
|
||||||
match_layer
|
match_layer
|
||||||
match_netclass
|
match_netclass
|
||||||
|
@ -17,6 +19,7 @@ micro_via
|
||||||
min
|
min
|
||||||
npth
|
npth
|
||||||
opt
|
opt
|
||||||
|
outer
|
||||||
pad
|
pad
|
||||||
pth
|
pth
|
||||||
rule
|
rule
|
||||||
|
|
|
@ -150,8 +150,9 @@ void PANEL_SETUP_RULES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
|
||||||
m_textEditor->AutoCompCancel();
|
m_textEditor->AutoCompCancel();
|
||||||
sexprs.push( partial );
|
sexprs.push( partial );
|
||||||
|
|
||||||
if( sexprs.size()
|
if( sexprs.size() && ( sexprs.top() == "constraint"
|
||||||
&& ( sexprs.top() == "constraint" || sexprs.top() == "disallow" ) )
|
|| sexprs.top() == "disallow"
|
||||||
|
|| sexprs.top() == "layer" ) )
|
||||||
{
|
{
|
||||||
partial = wxEmptyString;
|
partial = wxEmptyString;
|
||||||
context = SEXPR_TOKEN;
|
context = SEXPR_TOKEN;
|
||||||
|
@ -174,7 +175,7 @@ void PANEL_SETUP_RULES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
|
||||||
if( sexprs.empty() )
|
if( sexprs.empty() )
|
||||||
tokens = "rule version";
|
tokens = "rule version";
|
||||||
else if( sexprs.top() == "rule" )
|
else if( sexprs.top() == "rule" )
|
||||||
tokens = "condition constraint disallow";
|
tokens = "condition constraint disallow layer";
|
||||||
else if( sexprs.top() == "constraint" )
|
else if( sexprs.top() == "constraint" )
|
||||||
tokens = "max min opt";
|
tokens = "max min opt";
|
||||||
}
|
}
|
||||||
|
@ -186,6 +187,8 @@ void PANEL_SETUP_RULES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
|
||||||
tokens = "annulus_width clearance hole track_width";
|
tokens = "annulus_width clearance hole track_width";
|
||||||
else if( sexprs.top() == "disallow" )
|
else if( sexprs.top() == "disallow" )
|
||||||
tokens = "buried_via graphic hole micro_via pad text track via zone";
|
tokens = "buried_via graphic hole micro_via pad text track via zone";
|
||||||
|
else if( sexprs.top() == "layer" )
|
||||||
|
tokens = "inner outer \"x\"";
|
||||||
}
|
}
|
||||||
else if( context == STRING && expr_context == STRUCT_REF )
|
else if( context == STRING && expr_context == STRUCT_REF )
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,6 +89,7 @@ public:
|
||||||
LIBEVAL::ERROR_STATUS GetCompilationError();
|
LIBEVAL::ERROR_STATUS GetCompilationError();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
LSET m_LayerCondition;
|
||||||
wxString m_Expression;
|
wxString m_Expression;
|
||||||
wxString m_TargetRuleName;
|
wxString m_TargetRuleName;
|
||||||
|
|
||||||
|
@ -129,6 +130,7 @@ public:
|
||||||
MINOPTMAX m_TrackConstraint;
|
MINOPTMAX m_TrackConstraint;
|
||||||
int m_MinHole;
|
int m_MinHole;
|
||||||
|
|
||||||
|
LSET m_LayerCondition;
|
||||||
DRC_RULE_CONDITION m_Condition;
|
DRC_RULE_CONDITION m_Condition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ DRC_RULES_PARSER::DRC_RULES_PARSER( BOARD* aBoard, const wxString& aSource,
|
||||||
m_requiredVersion( 0 ),
|
m_requiredVersion( 0 ),
|
||||||
m_tooRecent( false )
|
m_tooRecent( false )
|
||||||
{
|
{
|
||||||
initLayerMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,20 +48,6 @@ DRC_RULES_PARSER::DRC_RULES_PARSER( BOARD* aBoard, FILE* aFile, const wxString&
|
||||||
m_requiredVersion( 0 ),
|
m_requiredVersion( 0 ),
|
||||||
m_tooRecent( false )
|
m_tooRecent( false )
|
||||||
{
|
{
|
||||||
initLayerMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DRC_RULES_PARSER::initLayerMap()
|
|
||||||
{
|
|
||||||
for( LAYER_NUM layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer )
|
|
||||||
{
|
|
||||||
std::string untranslated = TO_UTF8( wxString( LSET::Name( PCB_LAYER_ID( layer ) ) ) );
|
|
||||||
m_layerMap[ untranslated ] = PCB_LAYER_ID( layer );
|
|
||||||
|
|
||||||
std::string userName = m_board->GetLayerName( PCB_LAYER_ID( layer ) ).ToStdString();
|
|
||||||
m_layerMap[ userName ] = PCB_LAYER_ID( layer );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +80,7 @@ void DRC_RULES_PARSER::Parse( std::vector<DRC_RULE*>& aRules )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Expecting( "selector or rule" );
|
Expecting( "rule" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,6 +144,10 @@ DRC_RULE* DRC_RULES_PARSER::parseDRC_RULE()
|
||||||
NeedRIGHT();
|
NeedRIGHT();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_layer:
|
||||||
|
rule->m_LayerCondition = parseLayer();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Expecting( "disallow, constraint or condition" );
|
Expecting( "disallow, constraint or condition" );
|
||||||
}
|
}
|
||||||
|
@ -258,4 +247,36 @@ void DRC_RULES_PARSER::parseValueWithUnits( const wxString& aExpr, int& aResult
|
||||||
}
|
}
|
||||||
|
|
||||||
aResult = evaluator.Result();
|
aResult = evaluator.Result();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LSET DRC_RULES_PARSER::parseLayer()
|
||||||
|
{
|
||||||
|
LSET retVal;
|
||||||
|
int tok = NextTok();
|
||||||
|
|
||||||
|
if( tok == T_outer )
|
||||||
|
{
|
||||||
|
retVal = LSET::ExternalCuMask();
|
||||||
|
}
|
||||||
|
else if( tok == T_inner )
|
||||||
|
{
|
||||||
|
retVal = LSET::InternalCuMask();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString layerName = FromUTF8();
|
||||||
|
PCB_LAYER_ID layer = ENUM_MAP<PCB_LAYER_ID>::Instance().ToEnum( layerName );
|
||||||
|
|
||||||
|
if( layer == UNDEFINED_LAYER )
|
||||||
|
{
|
||||||
|
wxString msg = wxString::Format( _( "Unrecognized layer '%s' " ), layerName );
|
||||||
|
THROW_PARSE_ERROR( msg, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
|
||||||
|
}
|
||||||
|
|
||||||
|
retVal.set( layer );
|
||||||
|
}
|
||||||
|
|
||||||
|
NeedRIGHT();
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
|
@ -46,19 +46,16 @@ public:
|
||||||
void Parse( std::vector<DRC_RULE*>& aRules );
|
void Parse( std::vector<DRC_RULE*>& aRules );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initLayerMap();
|
|
||||||
|
|
||||||
DRC_RULE* parseDRC_RULE();
|
DRC_RULE* parseDRC_RULE();
|
||||||
|
|
||||||
void parseConstraint( DRC_RULE* aRule );
|
void parseConstraint( DRC_RULE* aRule );
|
||||||
void parseValueWithUnits( const wxString& aExpr, int& aResult );
|
void parseValueWithUnits( const wxString& aExpr, int& aResult );
|
||||||
|
LSET parseLayer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOARD* m_board;
|
BOARD* m_board;
|
||||||
int m_requiredVersion;
|
int m_requiredVersion;
|
||||||
bool m_tooRecent;
|
bool m_tooRecent;
|
||||||
|
|
||||||
std::unordered_map<std::string, PCB_LAYER_ID> m_layerMap;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DRC_RULE_PARSER_H
|
#endif // DRC_RULE_PARSER_H
|
||||||
|
|
Loading…
Reference in New Issue