diff options
Diffstat (limited to 'libbuild2/make-parser.hxx')
-rw-r--r-- | libbuild2/make-parser.hxx | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/libbuild2/make-parser.hxx b/libbuild2/make-parser.hxx index fac2215..f6da7a1 100644 --- a/libbuild2/make-parser.hxx +++ b/libbuild2/make-parser.hxx @@ -17,6 +17,11 @@ namespace build2 // parse one line at a time. This allows the caller to bail out early (for // example, on encountering a non-existent generated file). // + // Note that most tools (MinGW GCC, Qt moc, etc) do not escape `:` in + // absolute Windows paths. To handle such cases the parser recognizes `:` + // that is a part of the driver letter component and does not treat it as + // the target/prerequisite separator. + // class LIBBUILD2_SYMEXPORT make_parser { public: @@ -24,26 +29,24 @@ namespace build2 // Parse next target/prerequisite on a line starting from the specified // position. Update the position to point to the start of the following - // target/prerequisite or l.size() if there is nothing left on this - // line. May return an empty string for a valid if unlikely dependency + // target/prerequisite or line.size() if there is nothing left on this + // line. May return an empty path for a valid if unlikely dependency // declarations (see below) or if passing leading blank lines (both of // which should normally be just skipped). Issue diagnostics and throw - // failed if the declaration is invalid. - // - // If strict is false, then allow unescaped `:` in prerequisites. + // failed if the declaration or path is invalid. // - // Note that the (p != l.size) should be in the do-while rather than in a - // while loop. In other words, except for the leading blank lines, the - // parser needs to see the blank line to correctly identify the end of the - // declaration. See make-parser.test.cxx for a recommended usage. + // Note that the (pos != line.size) should be in the do-while rather than + // in a while loop. In other words, except for the leading blank lines, + // the parser needs to see the blank line to correctly identify the end of + // the declaration. See make-parser.test.cxx for a recommended usage. // // To parse more than one declaration, reset the state to begin after // reaching end. // enum class type {target, prereq}; - pair<type, string> - next (const string&, size_t&, const location&, bool strict); + pair<type, path> + next (const string& line, size_t& pos, const location&); // Lower-level stateless API. // @@ -52,12 +55,7 @@ namespace build2 // position. Return the target/prerequisite as well as an indication of // whether the end of the dependency declaration was reached. Update the // position to point to the start of the following target/prerequisite, - // `:`, or l.size() if there is nothing left on this line. - // - // Note that some broken tools (notably MinGW GCC) do not escape `:` - // properly. To tolerate such cases the caller may specify that what's - // being parsed is the prerequisite list in which case unescaped `:` will - // be treated literally. + // `:`, or line.size() if there is nothing left on this line. // // Note also that this function may return an empty string (with // end=false) for a valid if unlikely dependency declaration, for example @@ -67,8 +65,8 @@ namespace build2 // | // bar // - // It would also return an empty string (with end=true) if passed and - // empty or whitespace-only line. + // It would also return an empty string (with end=true) if passed an empty + // or whitespace-only line. // // Note also that in the make language line continuations introduce a // whitespace rather than just being remove. For example, the following @@ -78,7 +76,7 @@ namespace build2 // baz // static pair<string, bool> - next (const string&, size_t&, optional<bool> prereq = nullopt); + next (const string& line, size_t& pos, type); }; } |