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

Method parse_include

libbuild2/parser.cxx:3818–4012  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3816 }
3817
3818 void parser::
3819 parse_include (token& t, type& tt)
3820 {
3821 // include [<attrs>] <path>+
3822 //
3823
3824 tracer trace ("parser::parse_include", &path_);
3825
3826 if (stage_ == stage::boot)
3827 fail (t) << "inclusion during bootstrap";
3828
3829 // The rest should be a list of buildfiles. Parse them as names in the
3830 // value mode to get variable expansion and directory prefixes. Also
3831 // handle optional attributes.
3832 //
3833 mode (lexer_mode::value, '@');
3834 next_with_attributes (t, tt);
3835 attributes_push (t, tt);
3836
3837 bool acyc (false); // Allow source cycle involving this directive.
3838 {
3839 attributes as (attributes_pop ());
3840 const location& l (as.loc);
3841
3842 for (const attribute& a: as)
3843 {
3844 const string& n (a.name);
3845
3846 if (n == "allow_cycle")
3847 {
3848 acyc = true;
3849 }
3850 else
3851 fail (l) << "unknown include directive attribute " << a;
3852 }
3853 }
3854
3855 const location l (get_location (t));
3856 names ns (tt != type::newline && tt != type::eos
3857 ? parse_names (t, tt, pattern_mode::expand, "path", nullptr)
3858 : names ());
3859
3860 for (name& n: ns)
3861 {
3862 if (n.pair || n.qualified () || n.typed () || n.empty ())
3863 fail (l) << "expected buildfile instead of " << n;
3864
3865 // Construct the buildfile path. If it is a directory, then append
3866 // 'buildfile'.
3867 //
3868 path p (move (n.dir));
3869
3870 bool a;
3871 if (n.value.empty ())
3872 a = true;
3873 else
3874 {
3875 a = path::traits_type::is_separator (n.value.back ());

Callers

nothing calls this directly

Calls 4

modeEnum · 0.85
get_locationFunction · 0.85
parse_namesFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected