|
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_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. | |
| 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) |
| 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. | |
|
inline |
Prefix every line, so the target reads the whole block as comments.
Definition at line 456 of file drc_rules_downgrade.h.
Referenced by FilterDrcRulesForTarget().
|
inline |
True if the rule uses something the target's parser or evaluator cannot handle.
Definition at line 216 of file drc_rules_downgrade.h.
References DRC_RULE_SEMANTIC_BREAKS, 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 61 of file drc_rules_downgrade.h.
Referenced by DrcRuleUnsupportedByTarget().
|
inline |
Filter a .kicad_dru file for the target.
Kept rules stay byte-identical, unsupported rules become comments and are listed by name. On a syntax error m_error is set, write nothing.
Definition at line 474 of file drc_rules_downgrade.h.
References _, CommentOutDrcBlock(), DrcRuleUnsupportedByTarget(), FindDrcRuleVocabulary(), DOWNGRADE_TARGET::m_name, 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(), 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 41 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 135 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 97 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 |
A function a release parses but answers differently, which the vocabulary cannot say.
Definition at line 54 of file drc_rules_downgrade.h.
Referenced by BOOST_AUTO_TEST_CASE(), and DrcRuleUnsupportedByTarget().