28 #include <drc_rules_lexer.h> 32 using namespace DRCRULE_T;
36 DRC_RULES_LEXER( aSource.ToStdString(), aSourceDescr ),
37 m_requiredVersion( 0 ),
45 DRC_RULES_LEXER( aFile, aFilename ),
46 m_requiredVersion( 0 ),
56 wxString first = aMessage.BeforeFirst(
'|', &rest );
83 for( T token = NextTok(); token != T_EOF; token = NextTok() )
88 if( token == T_RIGHT )
99 bool haveVersion =
false;
104 for( T token = NextTok(); token != T_EOF; token = NextTok() )
106 if( token != T_LEFT )
111 if( !haveVersion && token != T_version )
137 msg.Printf(
_(
"Unrecognized item '%s'.| Expected version number" ),
144 msg.Printf(
_(
"Unrecognized item '%s'." ),
161 msg.Printf(
_(
"Unrecognized item '%s'.| Expected %s." ),
163 "'rule', 'version'" );
182 if( !IsSymbol( token ) )
185 rule->
m_Name = FromUTF8();
187 for( token = NextTok(); token != T_RIGHT && token != T_EOF; token = NextTok() )
189 if( token != T_LEFT )
209 if( IsSymbol( token ) )
216 msg.Printf(
_(
"Unrecognized item '%s'.| Expected quoted expression." ),
240 msg.Printf(
_(
"Unrecognized item '%s'.| Expected %s." ),
242 "'constraint', 'condition', 'disallow'" );
264 if( (
int) token ==
DSN_RIGHT || token == T_EOF )
266 msg.Printf(
_(
"Missing constraint type.| Expected %s." ),
267 "'clearance', 'hole_clearance', 'edge_clearance', 'hole', 'hole_to_hole', " 268 "'courtyard_clearance', 'silk_clearance', 'track_width', 'annular_width', " 269 "'disallow', 'length', 'skew', 'via_count', 'diff_pair_gap' or " 270 "'diff_pair_uncoupled'" );
293 msg.Printf(
_(
"Unrecognized item '%s'.| Expected %s." ),
295 "'clearance', 'hole_clearance', 'edge_clearance', 'hole', hole_to_hole'," 296 "'courtyard_clearance', 'silk_clearance', 'track_width', 'annular_width', " 297 "'disallow', 'length', 'skew', 'diff_pair_gap' or 'diff_pair_uncoupled'." );
303 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
306 token = GetCurStrAsToken();
326 msg.Printf(
_(
"Unrecognized item '%s'.| Expected %s." ),
328 "'track', 'via', 'micro_via', 'buried_via', 'pad', 'zone', 'text', " 329 "'graphic', 'hole' or 'footprint'." );
342 for( token = NextTok(); token != T_RIGHT && token != T_EOF; token = NextTok() )
344 if( token != T_LEFT )
419 msg.Printf(
_(
"Unrecognized item '%s'.| Expected %s." ),
421 "'min', 'max', 'opt'" );
436 auto errorHandler = [&](
const wxString& aMessage,
int aOffset )
439 wxString first = aMessage.BeforeFirst(
'|', &rest );
445 CurOffset() + aOffset,
458 CurOffset() + aOffset );
466 aResult = evaluator.
Result();
473 int token = NextTok();
480 else if( token == T_outer )
484 else if( token == T_inner )
490 wxString layerName = FromUTF8();
493 for(
unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
495 wxPGChoiceEntry& entry = layerMap[ii];
497 if( entry.GetText().Matches( layerName ) )
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
void reportError(const wxString &aMessage)
virtual bool HasMessage() const =0
Returns true if the reporter client is non-empty.
void SetErrorCallback(std::function< void(const wxString &aMessage, int aOffset)> aCallback)
DRC_RULE_CONDITION * m_Condition
static ENUM_MAP< T > & Instance()
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
#define DRC_RULE_FILE_VERSION
DRC_RULES_PARSER(const wxString &aSource, const wxString &aSourceDescr)
LSET is a set of PCB_LAYER_IDs.
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
void parseValueWithUnits(const wxString &aExpr, int &aResult)
DRC_RULE * parseDRC_RULE()
void Parse(std::vector< DRC_RULE * > &aRules, REPORTER *aReporter)
static LSET InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void parseConstraint(DRC_RULE *aRule)
void AddConstraint(DRC_CONSTRAINT &aConstraint)
bool Evaluate(const wxString &aExpr)
bool Compile(REPORTER *aReporter, int aSourceLine=0, int aSourceOffset=0)
PCB_LAYER_ID ToLAYER_ID(int aLayer)