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 );
60 wxString msg =
wxString::Format(
_(
"ERROR: <a href='%d:%d'>%s</a>%s" ), CurLineNumber(),
61 CurOffset(), first, rest );
78 for( T token = NextTok(); token != T_EOF; token = NextTok() )
83 if( token == T_RIGHT )
94 bool haveVersion =
false;
99 for( T token = NextTok(); token != T_EOF; token = NextTok() )
101 if( token != T_LEFT )
106 if( !haveVersion && token != T_version )
132 msg.Printf(
_(
"Unrecognized item '%s'.| Expected version number." ),
139 msg.Printf(
_(
"Unrecognized item '%s'." ),
156 msg.Printf(
_(
"Unrecognized item '%s'.| Expected %s." ), FromUTF8(),
157 wxT(
"rule or version" ) );
176 if( !IsSymbol( token ) )
179 rule->
m_Name = FromUTF8();
181 for( token = NextTok(); token != T_RIGHT && token != T_EOF; token = NextTok() )
183 if( token != T_LEFT )
203 if( IsSymbol( token ) )
210 msg.Printf(
_(
"Unrecognized item '%s'.| Expected quoted expression." ),
233 msg.Printf(
_(
"Unrecognized item '%s'.| Expected %s." ), FromUTF8(),
234 wxT(
"constraint, condition, or disallow" ) );
255 if( (
int) token ==
DSN_RIGHT || token == T_EOF )
257 msg.Printf(
_(
"Missing constraint type.| Expected %s." ),
258 wxT(
"clearance, hole_clearance, edge_clearance, hole, hole_to_hole, " 259 "courtyard_clearance, silk_clearance, track_width, annular_width, " 260 "via_diameter, disallow, length, skew, via_count, diff_pair_gap, or " 261 "diff_pair_uncoupled" ) );
286 msg.Printf(
_(
"Unrecognized item '%s'.| Expected %s." ), FromUTF8(),
287 wxT(
"clearance, hole_clearance, edge_clearance, hole_size, hole_to_hole, " 288 "courtyard_clearance, silk_clearance, track_width, annular_width, " 289 "via_diameter, disallow, length, skew, diff_pair_gap, or " 290 "diff_pair_uncoupled" ) );
296 msg.Printf(
_(
"Rule already has a '%s' constraint." ), FromUTF8() );
302 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
305 token = GetCurStrAsToken();
325 msg.Printf(
_(
"Unrecognized item '%s'.| Expected %s." ), FromUTF8(),
326 wxT(
"track, via, micro_via, buried_via, pad, zone, text, graphic, " 327 "hole, or footprint." ) );
340 for( token = NextTok(); token != T_RIGHT && token != T_EOF; token = NextTok() )
342 if( token != T_LEFT )
414 msg.Printf(
_(
"Unrecognized item '%s'.| Expected %s." ),
416 wxT(
"min, max, or opt" ) );
431 auto errorHandler = [&](
const wxString& aMessage,
int aOffset )
434 wxString first = aMessage.BeforeFirst(
'|', &rest );
439 CurLineNumber(), CurOffset() + aOffset, first, rest );
448 CurOffset() + aOffset );
456 aResult = evaluator.
Result();
463 int token = NextTok();
470 else if( token == T_outer )
474 else if( token == T_inner )
480 wxString layerName = FromUTF8();
483 for(
unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
485 wxPGChoiceEntry& entry = layerMap[ii];
487 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.
OPT< DRC_CONSTRAINT > FindConstraint(DRC_CONSTRAINT_T aType)
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)