-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a good reason to err on tabs in build files after all? #1598
Comments
Silently erring on tabs or confusing error messages are separate issues, it should always say "tabs are not allowed, use spaces".
The manual had a short paragraph on tabs, but it was (mistakenly) removed when
So if there's a way to handle tabs without over-complicating the code, PRs are welcome. |
Allow TAB character to be used for indentation. This is useful to have TAB character used as indentation, especially when parts of build.ninja are hand-written as HEREDOCs in otherwise TAB-indented file (either mandated by style for other part of project, or required by language itself). Changing lexer is easy thanks to the use of re2c, syntax is perhaps a bit too permissive now, but that is job of the parser to reject use of mixed indentation. Let's stop complaining that: ninja: error: build.ninja:3: expected 'command =' line when it is exactly: command = cc $cflags -c $in -o $out Closes ninja-build#1598 Signed-of-by: Przemek Kitszel <[email protected]>
Allow TAB character to be used for indentation. This is useful to have TAB character used as indentation, especially when parts of build.ninja are hand-written as HEREDOCs in otherwise TAB-indented file (either mandated by style for other part of project, or required by language itself). Changing lexer is easy thanks to the use of re2c, syntax is perhaps a bit too permissive now, but that is job of the parser to reject use of mixed indentation. Let's stop complaining that: ninja: error: build.ninja:3: expected 'command =' line when it is exactly: command = cc $cflags -c $in -o $out Closes ninja-build#1598 Signed-of-by: Przemek Kitszel <[email protected]>
Allow TAB character to be used for indentation. This is useful to have TAB character used as indentation, especially when parts of build.ninja are hand-written as HEREDOCs in otherwise TAB-indented file (either mandated by style for other part of project, or required by language itself). Changing lexer is easy thanks to the use of re2c, syntax is perhaps a bit too permissive now, but that is job of the parser to reject use of mixed indentation. Let's stop complaining that: ninja: error: build.ninja:3: expected 'command =' line when it is exactly: command = cc $cflags -c $in -o $out tests: print string instead of int for Lexer::Token Extend C++ tests by a wrapper for Lexer::Token printing, to have string value reported instead of numeric value, that gives "newline" instead of "8" in test results. Original line numbers are kept in error messages as they were before. Extend python functional test to have TABs used in both variable and build statements. Closes ninja-build#1598 Signed-of-by: Przemek Kitszel <[email protected]>
Allow TAB character to be used for indentation. This is useful to have TAB character used as indentation, especially when parts of build.ninja are hand-written as HEREDOCs in otherwise TAB-indented file (either mandated by style for other part of project, or required by language itself). Changing lexer is easy thanks to the use of re2c, syntax is perhaps a bit too permissive now, but that is job of the parser to reject use of mixed indentation. Let's stop complaining that: ninja: error: build.ninja:3: expected 'command =' line when it is exactly: command = cc $cflags -c $in -o $out tests: print string instead of int for Lexer::Token Extend C++ tests by a wrapper for Lexer::Token printing, to have string value reported instead of numeric value, that gives "newline" instead of "8" in test results. Original line numbers are kept in error messages as they were before. Extend python functional test to have TABs used in both variable and build statements. Closes ninja-build#1598 Signed-of-by: Przemek Kitszel <[email protected]>
Allow TAB character to be used for indentation. This is useful to have TAB character used as indentation, especially when parts of build.ninja are hand-written as HEREDOCs in otherwise TAB-indented file (either mandated by style for other part of project, or required by language itself). Changing lexer is easy thanks to the use of re2c, syntax is perhaps a bit too permissive now, but that is job of the parser to reject use of mixed indentation. Let's stop complaining that: ninja: error: build.ninja:3: expected 'command =' line when it is exactly: command = cc $cflags -c $in -o $out tests: print string instead of int for Lexer::Token Extend C++ tests by a wrapper for Lexer::Token printing, to have string value reported instead of numeric value, that gives "newline" instead of "8" in test results. Original line numbers are kept in error messages as they were before. Extend python functional test to have TABs used in both variable and build statements. Closes ninja-build#1598 Signed-of-by: Przemek Kitszel <[email protected]>
Allow TAB character to be used for indentation. This is useful to have TAB character used as indentation, especially when parts of build.ninja are hand-written as HEREDOCs in otherwise TAB-indented file (either mandated by style for other part of project, or required by language itself). Changing lexer is easy thanks to the use of re2c, syntax is perhaps a bit too permissive now, but that is job of the parser to reject use of mixed indentation. Let's stop complaining that: ninja: error: build.ninja:3: expected 'command =' line when it is exactly: command = cc $cflags -c $in -o $out tests: print string instead of int for Lexer::Token Extend C++ tests by a wrapper for Lexer::Token printing, to have string value reported instead of numeric value, that gives "newline" instead of "8" in test results. Original line numbers are kept in error messages as they were before. Extend python functional test to have TABs used in both variable and build statements. Closes ninja-build#1598 Signed-of-by: Przemek Kitszel <[email protected]>
Allow TAB character to be used for indentation. This is useful to have TAB character used as indentation, especially when parts of build.ninja are hand-written as HEREDOCs in otherwise TAB-indented file (either mandated by style for other part of project, or required by language itself). Changing lexer is easy thanks to the use of re2c, syntax is perhaps a bit too permissive now, but that is job of the parser to reject use of mixed indentation. Let's stop complaining that: ninja: error: build.ninja:3: expected 'command =' line when it is exactly: command = cc $cflags -c $in -o $out tests: print string instead of int for Lexer::Token Extend C++ tests by a wrapper for Lexer::Token printing, to have string value reported instead of numeric value, that gives "newline" instead of "8" in test results. Original line numbers are kept in error messages as they were before. Extend python functional test to have TABs used in both variable and build statements. Closes ninja-build#1598 Signed-of-by: Przemek Kitszel <[email protected]>
Allow TAB character to be used for indentation. This is useful to have TAB character used as indentation, especially when parts of build.ninja are hand-written as HEREDOCs in otherwise TAB-indented file (either mandated by style for other part of project, or required by language itself). Changing lexer is easy thanks to the use of re2c, syntax is perhaps a bit too permissive now, but that is job of the parser to reject use of mixed indentation. Let's stop complaining that: ninja: error: build.ninja:3: expected 'command =' line when it is exactly: command = cc $cflags -c $in -o $out tests: print string instead of int for Lexer::Token Extend C++ tests by a wrapper for Lexer::Token printing, to have string value reported instead of numeric value, that gives "newline" instead of "8" in test results. Original line numbers are kept in error messages as they were before. Extend python functional test to have TABs used in both variable and build statements. Closes ninja-build#1598 Signed-of-by: Przemek Kitszel <[email protected]>
Seen the closed issue #394 as "intended behavior", but even more significantly the open one (from 4 years later): #952. Quoting @Alhadis's comment from there:
Yes, please. Or at least avoid "silently" erring on tabs (by "silently" I mean confusing error messages like "a line with 'command =' is expected", for a line that apparently reads just that; it was my first obstacle (well, second, after a "linting error" for a BOM) that I stumbled across in my hello-world attempt to evaluate whether I should consider switching to Ninja (until finally switching to redo some day? :) ).
BTW, realizing that the tab might be the problem was made even less obvious by the explicit notion that Ninja is (trying to be) a close kin of make (where tabs are the rule).
And regarding @Alhadis's other point: "The lexer should raise an error only if tabs and spaces are mixed within the same file, which (of course) should be forbidden." -- considering Evan's comment of
then even mixing tabs and spaces should be none of Ninja's business, as far as I understand. Until e.g. nested scopes may get introduced, of course. But even then, only an indent string of mixed tabs and spaces at line-start should be a problem (not any mixing in general).
Thanks, and a nice job overall!
(Note: I'm all new to Ninja, and ended up here only due to my own tab affair, as the manual is still silent about tabs -- which is fine, as in this case possibly many of us would prefer changing the code, not the docs.)
The text was updated successfully, but these errors were encountered: