Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions src/odb/src/lefin/lefTechLayerCutEnclosureParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool lefTechLayerCutEnclosureRuleParser::parseSubRule(const std::string& s,
{
odb::dbTechLayerCutEnclosureRule* rule
= odb::dbTechLayerCutEnclosureRule::create(layer);
qi::rule<std::string::const_iterator, space_type> EOL
qi::rule<std::string::const_iterator, space_type> eol_rule
= (lit("EOL")[boost::bind(
&odb::dbTechLayerCutEnclosureRule::setType,
rule,
Expand Down Expand Up @@ -135,7 +135,7 @@ bool lefTechLayerCutEnclosureRuleParser::parseSubRule(const std::string& s,
rule,
&odb::dbTechLayerCutEnclosureRule::setExtension)])));

qi::rule<std::string::const_iterator, space_type> DEFAULT
qi::rule<std::string::const_iterator, space_type> default_rule
= (double_[boost::bind(
&lefTechLayerCutEnclosureRuleParser::setInt,
this,
Expand All @@ -152,7 +152,7 @@ bool lefTechLayerCutEnclosureRuleParser::parseSubRule(const std::string& s,
rule,
odb::dbTechLayerCutEnclosureRule::ENC_TYPE::DEFAULT)];

qi::rule<std::string::const_iterator, space_type> ENDSIDE
qi::rule<std::string::const_iterator, space_type> endside_rule
= (-lit("OFFCENTERLINE")[boost::bind(
&odb::dbTechLayerCutEnclosureRule::setOffCenterLine, rule, true)]
>> lit("END") >> double_[boost::bind(
Expand All @@ -171,7 +171,7 @@ bool lefTechLayerCutEnclosureRuleParser::parseSubRule(const std::string& s,
rule,
odb::dbTechLayerCutEnclosureRule::ENC_TYPE::ENDSIDE)];

qi::rule<std::string::const_iterator, space_type> HORZ_AND_VERT
qi::rule<std::string::const_iterator, space_type> horz_and_vert_rule
= (lit("HORIZONTAL") >> double_[boost::bind(
&lefTechLayerCutEnclosureRuleParser::setInt,
this,
Expand All @@ -189,7 +189,7 @@ bool lefTechLayerCutEnclosureRuleParser::parseSubRule(const std::string& s,
rule,
odb::dbTechLayerCutEnclosureRule::ENC_TYPE::HORZ_AND_VERT)];

qi::rule<std::string::const_iterator, space_type> WIDTH_
qi::rule<std::string::const_iterator, space_type> width_rule
= (lit("WIDTH")[boost::bind(
&odb::dbTechLayerCutEnclosureRule::setWidthValid, rule, true)]
>> double_[boost::bind(&lefTechLayerCutEnclosureRuleParser::setInt,
Expand All @@ -216,7 +216,7 @@ bool lefTechLayerCutEnclosureRuleParser::parseSubRule(const std::string& s,
rule,
true)])));

qi::rule<std::string::const_iterator, space_type> LENGTH
qi::rule<std::string::const_iterator, space_type> length_rule
= (lit("LENGTH")[boost::bind(
&odb::dbTechLayerCutEnclosureRule::setLengthValid, rule, true)]
>> double_[boost::bind(
Expand All @@ -226,13 +226,13 @@ bool lefTechLayerCutEnclosureRuleParser::parseSubRule(const std::string& s,
rule,
&odb::dbTechLayerCutEnclosureRule::setMinLength)]);

qi::rule<std::string::const_iterator, space_type> EXTRACUT
qi::rule<std::string::const_iterator, space_type> extra_cut_rule
= (lit("EXTRACUT")[boost::bind(
&odb::dbTechLayerCutEnclosureRule::setExtraCutValid, rule, true)]
>> -lit("EXTRAONLY")[boost::bind(
&odb::dbTechLayerCutEnclosureRule::setExtraOnly, rule, true)]);

qi::rule<std::string::const_iterator, space_type> REDUNDANTCUT
qi::rule<std::string::const_iterator, space_type> redundant_cut_rule
= (lit("REDUNDANTCUT")[boost::bind(
&odb::dbTechLayerCutEnclosureRule::setRedundantCutValid,
rule,
Expand All @@ -244,7 +244,7 @@ bool lefTechLayerCutEnclosureRuleParser::parseSubRule(const std::string& s,
rule,
&odb::dbTechLayerCutEnclosureRule::setCutWithin)]);

qi::rule<std::string::const_iterator, space_type> PARALLEL
qi::rule<std::string::const_iterator, space_type> parallel_rule
= (lit("PARALLEL")[boost::bind(
&odb::dbTechLayerCutEnclosureRule::setConcaveCornersValid,
rule,
Expand Down Expand Up @@ -284,15 +284,15 @@ bool lefTechLayerCutEnclosureRuleParser::parseSubRule(const std::string& s,
rule,
&odb::dbTechLayerCutEnclosureRule::setBelowEnclosure)]));

qi::rule<std::string::const_iterator, space_type> CONCAVECORNERS
qi::rule<std::string::const_iterator, space_type> concave_corners_rule
= (lit("CONCAVECORNERS")[boost::bind(
&odb::dbTechLayerCutEnclosureRule::setConcaveCornersValid,
rule,
true)]
>> int_[boost::bind(
&odb::dbTechLayerCutEnclosureRule::setNumCorners, rule, _1)]);

qi::rule<std::string::const_iterator, space_type> CUTCLASS
qi::rule<std::string::const_iterator, space_type> cut_class_rule
= (-(lit("CUTCLASS") >> _string)[boost::bind(
&lefTechLayerCutEnclosureRuleParser::setCutClass,
this,
Expand All @@ -303,18 +303,20 @@ bool lefTechLayerCutEnclosureRuleParser::parseSubRule(const std::string& s,
&odb::dbTechLayerCutEnclosureRule::setAbove, rule, true)]
| lit("BELOW")[boost::bind(
&odb::dbTechLayerCutEnclosureRule::setBelow, rule, true)]));
qi::rule<std::string::const_iterator, space_type> ENCLOSURE
= (lit("ENCLOSURE") >> CUTCLASS
>> (EOL | DEFAULT | ENDSIDE | HORZ_AND_VERT) >> -WIDTH_ >> -LENGTH
>> -EXTRACUT >> -REDUNDANTCUT >> -PARALLEL >> -CONCAVECORNERS
qi::rule<std::string::const_iterator, space_type> enclosure_rule
= (lit("ENCLOSURE") >> cut_class_rule
>> (eol_rule | default_rule | endside_rule | horz_and_vert_rule)
>> -width_rule >> -length_rule >> -extra_cut_rule
>> -redundant_cut_rule >> -parallel_rule >> -concave_corners_rule
>> lit(";"));
auto first = s.begin();
auto last = s.end();
bool valid = qi::phrase_parse(first, last, ENCLOSURE, space) && first == last;
bool valid
= qi::phrase_parse(first, last, enclosure_rule, space) && first == last;
Comment on lines +314 to +315
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line break before the assignment operator is unconventional and harms readability. It's better to keep the declaration and assignment on one line. If the line is too long, it should be broken after an operator like &&, which is the pattern used in other files in this PR.

  bool valid = qi::phrase_parse(first, last, enclosure_rule, space) && first == last;

if (!valid) {
odb::dbTechLayerCutEnclosureRule::destroy(rule);
}
return valid;
}

} // namespace odb
} // namespace odb
34 changes: 18 additions & 16 deletions src/odb/src/lefin/lefTechLayerCutSpacingParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ bool parse(
odb::lefinReader* lefinReader,
std::vector<std::pair<odb::dbObject*, std::string>>& incomplete_props)
{
qi::rule<std::string::const_iterator, space_type> LAYER_CUTCLASS
qi::rule<std::string::const_iterator, space_type> layer_cut_class_rule
= (lit("CUTCLASS")
>> _string[boost::bind(&setCutClass, _1, parser, layer)] >> -(
lit("SHORTEDGEONLY")[boost::bind(
Expand Down Expand Up @@ -376,7 +376,7 @@ bool parse(
parser,
&odb::dbTechLayerCutSpacingRule::setWrongDirection,
true)]));
qi::rule<std::string::const_iterator, space_type> LAYER
qi::rule<std::string::const_iterator, space_type> layer_rule
= (lit("LAYER") >> _string[boost::bind(
&addLayerSubRule, _1, parser, layer, boost::ref(incomplete_props))]
>> -(
Expand All @@ -386,9 +386,9 @@ bool parse(
true)]
| lit("ORTHOGONALSPACING") >> double_[boost::bind(
&setOrthogonalSpacing, _1, parser, lefinReader)]
| LAYER_CUTCLASS));
| layer_cut_class_rule));

qi::rule<std::string::const_iterator, space_type> ADJACENTCUTS
qi::rule<std::string::const_iterator, space_type> adjacent_cuts_rule
= (lit("ADJACENTCUTS") >> (string("1") | string("2") | string("3"))
>> -(lit("EXACTALIGNED") >> int_)
>> -(lit("TWOCUTS") >> int_ >> -lit("SAMECUT")[boost::bind(
Expand All @@ -406,12 +406,13 @@ bool parse(
>> -string("SAMEMASK"))[boost::bind(
&addAdjacentCutsSubRule, _1, parser, layer, lefinReader)];

qi::rule<std::string::const_iterator, space_type> PARALLELOVERLAP
qi::rule<std::string::const_iterator, space_type> parallel_overlap_rule
= (lit("PARALLELOVERLAP")
>> -(string("EXCEPTSAMENET") | string("EXCEPTSAMEMETAL")
| string("EXCEPTSAMEVIA") | string("EXCEPTSAMEMETALOVERLAP")))
[boost::bind(&addParallelOverlapSubRule, _1, parser)];
qi::rule<std::string::const_iterator, space_type> PARALLELWITHIN_CUTCLASS
qi::rule<std::string::const_iterator, space_type>
parallel_within_cut_class_rule
= (lit("CUTCLASS")
Comment on lines +414 to 416
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This formatting is unconventional. A more standard way to break long declaration lines is to place the = on the same line as the variable name and indent the following lines.

Suggested change
qi::rule<std::string::const_iterator, space_type>
parallel_within_cut_class_rule
= (lit("CUTCLASS")
qi::rule<std::string::const_iterator, space_type>
parallel_within_cut_class_rule =
(lit("CUTCLASS")

>> _string[boost::bind(&setCutClass, _1, parser, layer)]
>> -(lit("LONGEDGEONLY")[boost::bind(
Expand All @@ -424,23 +425,23 @@ bool parse(
>> double_ >> lit("WITHIN") >> double_)[boost::bind(
&setParWithinEnclosure, _1, parser, lefinReader)]));

qi::rule<std::string::const_iterator, space_type> PARALLELWITHIN
qi::rule<std::string::const_iterator, space_type> parallel_within_rule
= ((lit("PARALLELWITHIN") >> double_
>> -string("EXCEPTSAMENET"))[boost::bind(
&addParallelWithinSubRule, _1, parser, lefinReader)]
>> -PARALLELWITHIN_CUTCLASS);
>> -parallel_within_cut_class_rule);

qi::rule<std::string::const_iterator, space_type> SAMEMETALSHAREDEDGE
qi::rule<std::string::const_iterator, space_type> same_metal_shared_edge_rule
= (lit("SAMEMETALSHAREDEDGE") >> double_ >> -string("ABOVE")
>> -(lit("CUTCLASS") >> _string) >> -string("EXCEPTTWOEDGES")
>> -(lit("EXCEPTSAMEVIA") >> int_))[boost::bind(
&addSameMetalSharedEdgeSubRule, _1, parser, layer, lefinReader)];

qi::rule<std::string::const_iterator, space_type> AREA
qi::rule<std::string::const_iterator, space_type> area_rule
= (lit("AREA")
>> double_)[boost::bind(&addAreaSubRule, _1, parser, lefinReader)];

qi::rule<std::string::const_iterator, space_type> LEF58_SPACING = (+(
qi::rule<std::string::const_iterator, space_type> lef58_spacing_rule = (+(
lit("SPACING")
>> double_[boost::bind(&setCutSpacing, _1, parser, layer, lefinReader)]
>> -(lit("MAXXY")[boost::bind(&addMaxXYSubRule, parser)]
Expand All @@ -449,12 +450,13 @@ bool parse(
>> -(lit("SAMENET")[boost::bind(&setSameNet, parser)]
| lit("SAMEMETAL")[boost::bind(&setSameMetal, parser)]
| lit("SAMEVIA")[boost::bind(&setSameVia, parser)])
>> -(LAYER | ADJACENTCUTS | PARALLELOVERLAP | PARALLELWITHIN
| SAMEMETALSHAREDEDGE | AREA))
>> -(layer_rule | adjacent_cuts_rule | parallel_overlap_rule
| parallel_within_rule | same_metal_shared_edge_rule
| area_rule))
>> lit(";")));

bool valid
= qi::phrase_parse(first, last, LEF58_SPACING, space) && first == last;
bool valid = qi::phrase_parse(first, last, lef58_spacing_rule, space)
&& first == last;

if (!valid && parser->curRule != nullptr) {
if (!incomplete_props.empty()
Expand All @@ -479,4 +481,4 @@ bool lefTechLayerCutSpacingParser::parse(
s.begin(), s.end(), this, layer, l, incomplete_props);
}

} // namespace odb
} // namespace odb
39 changes: 21 additions & 18 deletions src/odb/src/lefin/lefTechLayerCutSpacingTableParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,13 @@ bool parse(
odb::lefinReader* lefinReader,
std::vector<std::pair<odb::dbObject*, std::string>>& incomplete_props)
{
qi::rule<std::string::const_iterator, space_type> ORTHOGONAL
qi::rule<std::string::const_iterator, space_type> orthogonal_rule
= (lit("SPACINGTABLE") >> lit("ORTHOGONAL")
>> +(lit("WITHIN") >> double_ >> lit("SPACING") >> double_)
>> lit(";"))[boost::bind(
&createOrthongonalSubRule, _1, parser, lefinReader)];

qi::rule<std::string::const_iterator, space_type> LAYER
qi::rule<std::string::const_iterator, space_type> layer_rule
= (lit("LAYER") >> _string[boost::bind(
&setLayer, _1, parser, boost::ref(incomplete_props))]
>> -lit("NOSTACK")[boost::bind(&setNoStack, parser)]
Expand All @@ -378,46 +378,47 @@ bool parse(
>> +(_string >> lit("TO") >> _string))[boost::bind(
&setPrlForAlignedCut, _1, parser)]));

qi::rule<std::string::const_iterator, space_type> CENTERTOCENTER
qi::rule<std::string::const_iterator, space_type> center_to_center_rule
= (lit("CENTERTOCENTER")
>> +(_string >> lit("TO")
>> _string))[boost::bind(&setCenterToCenter, _1, parser)];

qi::rule<std::string::const_iterator, space_type> CENTERANDEDGE
qi::rule<std::string::const_iterator, space_type> center_and_edge_rule
= (lit("CENTERANDEDGE") >> -lit("NOPRL")[boost::bind(&setNoPrl, parser)]
>> (+(_string >> lit("TO")
>> _string))[boost::bind(&setCenterAndEdge, _1, parser)]);
qi::rule<std::string::const_iterator, space_type> PRL
qi::rule<std::string::const_iterator, space_type> prl_rule
= (lit("PRL") >> double_ >> -(string("HORIZONTAL") | string("VERTICAL"))
>> -string("MAXXY")
>> *(_string >> lit("TO") >> _string
>> double_))[boost::bind(&setPRL, _1, parser, lefinReader)];
qi::rule<std::string::const_iterator, space_type> EXTENSION
qi::rule<std::string::const_iterator, space_type> extension_rule
= ((lit("ENDEXTENSION") >> double_
>> *(lit("TO") >> _string >> double_))[boost::bind(
&setEndExtension, _1, parser, lefinReader)]
>> -(lit("SIDEEXTENSION")
>> +(lit("TO") >> _string >> double_))[boost::bind(
&setSideExtension, _1, parser, lefinReader)]);

qi::rule<std::string::const_iterator, space_type> EXACTALIGNEDSPACING
qi::rule<std::string::const_iterator, space_type> exact_aligned_spacing_rule
= (lit("EXACTALIGNEDSPACING")
>> -(string("HORIZONTAL") | string("VERTICAL"))
>> +(_string >> double_))[boost::bind(
&setExactAlignedSpacing, _1, parser, lefinReader)];

qi::rule<std::string::const_iterator, space_type> NONOPPOSITEENCLOSURESPACING
qi::rule<std::string::const_iterator, space_type>
non_opposite_enclosure_spacing_rule
= (lit("NONOPPOSITEENCLOSURESPACING")
Comment on lines +409 to 411
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This formatting is unconventional. A more standard way to break long declaration lines is to place the = on the same line as the variable name and indent the following lines.

Suggested change
qi::rule<std::string::const_iterator, space_type>
non_opposite_enclosure_spacing_rule
= (lit("NONOPPOSITEENCLOSURESPACING")
qi::rule<std::string::const_iterator, space_type>
non_opposite_enclosure_spacing_rule =
(lit("NONOPPOSITEENCLOSURESPACING")

>> +(_string >> double_))[boost::bind(
&setNonOppositeEnclosureSpacing, _1, parser, lefinReader)];

qi::rule<std::string::const_iterator, space_type>
OPPOSITEENCLOSURERESIZESPACING
opposite_enclosure_resize_spacing_rule
= (lit("OPPOSITEENCLOSURERESIZESPACING")
Comment on lines 415 to 417
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This formatting is unconventional. A more standard way to break long declaration lines is to place the = on the same line as the variable name and indent the following lines.

Suggested change
qi::rule<std::string::const_iterator, space_type>
OPPOSITEENCLOSURERESIZESPACING
opposite_enclosure_resize_spacing_rule
= (lit("OPPOSITEENCLOSURERESIZESPACING")
qi::rule<std::string::const_iterator, space_type>
opposite_enclosure_resize_spacing_rule =
(lit("OPPOSITEENCLOSURERESIZESPACING")

>> +(_string >> double_ >> double_ >> double_))[boost::bind(
&setOppositeEnclosureResizeSpacing, _1, parser, lefinReader)];

qi::rule<std::string::const_iterator, space_type> CUTCLASS
qi::rule<std::string::const_iterator, space_type> cut_class_rule
= (lit("CUTCLASS")
>> +(_string
>> -(string("SIDE")
Expand All @@ -430,21 +431,23 @@ bool parse(
| double_))) // REMAINING ROWS (3rd and below)
)[boost::bind(&setCutClass, _1, parser, lefinReader)];

qi::rule<std::string::const_iterator, space_type> DEFAULT
qi::rule<std::string::const_iterator, space_type> default_rule
= (lit("SPACINGTABLE")[boost::bind(&createDefSubRule, parser)]
>> -(lit("DEFAULT")
>> double_[boost::bind(&setDefault, _1, parser, lefinReader)])
>> -lit("SAMEMASK")[boost::bind(&setSameMask, parser)]
>> -(lit("SAMENET")[boost::bind(&setSameNet, parser)]
| lit("SAMEMETAL")[boost::bind(&setSameMetal, parser)]
| lit("SAMEVIA")[boost::bind(&setSameVia, parser)])
>> -LAYER >> -CENTERTOCENTER >> -CENTERANDEDGE >> -PRL >> -EXTENSION
>> -EXACTALIGNEDSPACING >> -NONOPPOSITEENCLOSURESPACING
>> -OPPOSITEENCLOSURERESIZESPACING >> CUTCLASS >> lit(";"));
>> -layer_rule >> -center_to_center_rule >> -center_and_edge_rule
>> -prl_rule >> -extension_rule >> -exact_aligned_spacing_rule
>> -non_opposite_enclosure_spacing_rule
>> -opposite_enclosure_resize_spacing_rule >> cut_class_rule
>> lit(";"));

qi::rule<std::string::const_iterator, space_type> LEF58_SPACINGTABLE
= (+(ORTHOGONAL | DEFAULT));
bool valid = qi::phrase_parse(first, last, LEF58_SPACINGTABLE, space)
qi::rule<std::string::const_iterator, space_type> lef58_spacing_table_rule
= (+(orthogonal_rule | default_rule));
bool valid = qi::phrase_parse(first, last, lef58_spacing_table_rule, space)
&& first == last;
if (!valid && parser->curRule != nullptr) {
if (!incomplete_props.empty()
Expand All @@ -469,4 +472,4 @@ bool lefTechLayerCutSpacingTableParser::parse(
s.begin(), s.end(), this, l, incomplete_props);
}

} // namespace odb
} // namespace odb
Loading