MCPcopy Create free account
hub / github.com/build2/build2 / parse_variable_block

Method parse_variable_block

libbuild2/parser.cxx:2091–2144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2089 }
2090
2091 void parser::
2092 parse_variable_block (token& t, type& tt,
2093 optional<pattern_type> pt, const target_type* ptt,
2094 string pat, const location& ploc)
2095 {
2096 // Parse a target or prerequisite-specific variable block. If type is not
2097 // NULL, then this is a target type/pattern-specific block.
2098 //
2099 // enter: first token of first line in the block (normal lexer mode)
2100 // leave: rcbrace or eos
2101 //
2102 // This is a more restricted variant of parse_clause() that only allows
2103 // variable assignments.
2104 //
2105 tracer trace ("parser::parse_variable_block", &path_);
2106
2107 while (tt != type::rcbrace && tt != type::eos)
2108 {
2109 attributes_push (t, tt);
2110
2111 // Variable names should not contain patterns so we preserve them here
2112 // and diagnose in parse_variable_name().
2113 //
2114 location nloc (get_location (t));
2115 names ns (parse_names (t, tt, pattern_mode::preserve, "variable name"));
2116
2117 if (tt != type::assign &&
2118 tt != type::prepend &&
2119 tt != type::append)
2120 fail (t) << "expected variable assignment instead of " << t;
2121
2122 const variable& var (parse_variable_name (move (ns), nloc));
2123 apply_variable_attributes (var);
2124
2125 if (prerequisite_ == nullptr &&
2126 var.visibility > variable_visibility::target)
2127 {
2128 fail (t) << "variable " << var << " has " << var.visibility
2129 << " visibility but is assigned on a target";
2130 }
2131
2132 if (pt)
2133 parse_type_pattern_variable (t, tt,
2134 *pt, *ptt, pat, ploc, // Note: can't move.
2135 var, tt, get_location (t));
2136 else
2137 parse_variable (t, tt, var, tt);
2138
2139 if (tt != type::newline)
2140 fail (t) << "expected newline instead of " << t;
2141
2142 next (t, tt);
2143 }
2144 }
2145
2146 void parser::
2147 parse_recipe (token& t, type& tt,

Callers

nothing calls this directly

Calls 2

get_locationFunction · 0.85
parse_namesFunction · 0.70

Tested by

no test coverage detected