|
KiCad PCB EDA Suite
|
#include <algorithm>#include <cctype>#include <string>#include <vector>#include <wx/intl.h>#include <dsnlexer.h>#include <ki_exception.h>#include <downgrade_target.h>#include <drc_rules_release_vocabulary.h>Go to the source code of this file.
Classes | |
| struct | DRC_CONSTRAINT_RENAME |
| A constraint kind renamed after a release. The release reads the same check by its old name. More... | |
| struct | DRC_RULES_FILTER_RESULT |
| struct | DRC_RULE_TOKEN |
| struct | DRC_RULE_BLOCK |
| A top-level block of the rules file, as byte span and token range. More... | |
Functions | |
| const DRC_RULE_VOCABULARY * | FindDrcRuleVocabulary (const DOWNGRADE_TARGET &aTarget) |
| The vocabulary a target release could parse, generated from its release tags by tools/generate_drc_rules_vocabulary.py. | |
| bool | DrcVocabularyHas (const char *const *aWords, size_t aCount, const std::string &aWord) |
| The generated arrays are sorted, so membership is a binary search. | |
| std::string | DrcConstraintKindForTarget (const std::string &aKind, const DRC_RULE_VOCABULARY &aVocabulary) |
| The name the target reads a constraint kind by. | |
| bool | TokenizeDrcRules (const std::string &aText, std::vector< DRC_RULE_TOKEN > &aTokens, wxString &aError) |
| Tokenize with the lexer the rule readers use, so comments, strings and symbols end exactly where they end for the readers. | |
| bool | SplitDrcRuleBlocks (const std::vector< DRC_RULE_TOKEN > &aTokens, std::vector< DRC_RULE_BLOCK > &aBlocks, wxString &aError) |
| Group the tokens into top-level blocks. | |
| bool | DrcRuleUnsupportedByTarget (const std::vector< DRC_RULE_TOKEN > &aTokens, const DRC_RULE_BLOCK &aBlock, const DRC_RULE_VOCABULARY &aVocabulary, std::vector< size_t > *aRenamed=nullptr) |
| True if the rule uses something the target's parser or evaluator cannot handle. | |
| std::string | CommentOutDrcBlock (const std::string &aBlock) |
| Prefix every line, so the target reads the whole block as comments. | |
| DRC_RULES_FILTER_RESULT | FilterDrcRulesForTarget (const wxString &aRulesText, const DOWNGRADE_TARGET &aTarget) |
| Filter a .kicad_dru file for the target. | |
Variables | |
| constexpr const char * | DRC_RULE_SEMANTIC_BREAKS [] |
| A function a release parses but answers differently, which the vocabulary cannot say. | |
| constexpr DRC_CONSTRAINT_RENAME | DRC_CONSTRAINT_RENAMES [] |
|
inline |
Prefix every line, so the target reads the whole block as comments.
Definition at line 495 of file drc_rules_downgrade.h.
Referenced by FilterDrcRulesForTarget().
|
inline |
The name the target reads a constraint kind by.
Definition at line 83 of file drc_rules_downgrade.h.
References DRC_CONSTRAINT_RENAMES, DrcVocabularyHas(), DRC_RULE_VOCABULARY::m_tokenCount, and DRC_RULE_VOCABULARY::m_tokens.
Referenced by DrcRuleUnsupportedByTarget(), and FilterDrcRulesForTarget().
|
inline |
True if the rule uses something the target's parser or evaluator cannot handle.
Constraint kinds the target reads by an older name are added to aRenamed as token indices.
Definition at line 248 of file drc_rules_downgrade.h.
References DRC_RULE_SEMANTIC_BREAKS, DrcConstraintKindForTarget(), DrcVocabularyHas(), DSN_COMMENT, DSN_LEFT, DSN_NUMBER, DSN_RIGHT, DSN_STRING, DSN_SYMBOL, end, DRC_RULE_BLOCK::m_first, DRC_RULE_VOCABULARY::m_functionCount, DRC_RULE_VOCABULARY::m_functions, DRC_RULE_BLOCK::m_last, DRC_RULE_VOCABULARY::m_properties, DRC_RULE_VOCABULARY::m_propertyCount, DRC_RULE_TOKEN::m_text, DRC_RULE_VOCABULARY::m_textVariables, DRC_RULE_VOCABULARY::m_tokenCount, DRC_RULE_VOCABULARY::m_tokens, DRC_RULE_TOKEN::m_type, DRC_RULE_VOCABULARY::m_unitCount, DRC_RULE_VOCABULARY::m_units, and next().
Referenced by FilterDrcRulesForTarget().
|
inline |
The generated arrays are sorted, so membership is a binary search.
Definition at line 62 of file drc_rules_downgrade.h.
Referenced by DrcConstraintKindForTarget(), and DrcRuleUnsupportedByTarget().
|
inline |
Filter a .kicad_dru file for the target.
Kept rules stay byte-identical except for renamed constraint kinds, unsupported rules become comments and are listed by name. On a syntax error m_error is set, write nothing.
Definition at line 514 of file drc_rules_downgrade.h.
References _, CommentOutDrcBlock(), DrcConstraintKindForTarget(), DrcRuleUnsupportedByTarget(), FindDrcRuleVocabulary(), DOWNGRADE_TARGET::m_name, DRC_RULE_TOKEN::m_offset, DRC_RULE_TOKEN::m_text, result, SplitDrcRuleBlocks(), text, and TokenizeDrcRules().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), ClassifyProjectForDowngrade(), and ExportProjectForDowngrade().
|
inline |
The vocabulary a target release could parse, generated from its release tags by tools/generate_drc_rules_vocabulary.py.
A release without one cannot be exported to.
Definition at line 42 of file drc_rules_downgrade.h.
References DRC_RULE_VOCABULARIES, and DOWNGRADE_TARGET::m_id.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and FilterDrcRulesForTarget().
|
inline |
Group the tokens into top-level blocks.
Anything but a comment outside a block is invalid for the readers, and so is a comment that does not start its line.
Definition at line 166 of file drc_rules_downgrade.h.
References _, DSN_COMMENT, DSN_LEFT, DSN_RIGHT, DSN_SYMBOL, DRC_RULE_BLOCK::m_first, DRC_RULE_BLOCK::m_head, DRC_RULE_BLOCK::m_name, DRC_RULE_TOKEN::m_offset, DRC_RULE_BLOCK::m_start, DRC_RULE_TOKEN::m_text, DRC_RULE_TOKEN::m_type, and name.
Referenced by FilterDrcRulesForTarget().
|
inline |
Tokenize with the lexer the rule readers use, so comments, strings and symbols end exactly where they end for the readers.
Comments stay as tokens so every byte of the source is placed.
Definition at line 128 of file drc_rules_downgrade.h.
References DSNLEXER::CurLineNumber(), DSNLEXER::CurOffset(), DSNLEXER::CurText(), DSN_EOF, DSN_STRING, DSNLEXER::NextTok(), IO_ERROR::Problem(), and DSNLEXER::SetCommentsAreTokens().
Referenced by FilterDrcRulesForTarget().
|
inlineconstexpr |
Definition at line 76 of file drc_rules_downgrade.h.
Referenced by DrcConstraintKindForTarget().
|
inlineconstexpr |
A function a release parses but answers differently, which the vocabulary cannot say.
Definition at line 55 of file drc_rules_downgrade.h.
Referenced by BOOST_AUTO_TEST_CASE(), and DrcRuleUnsupportedByTarget().