Skip to content
Snippets Groups Projects
  1. Mar 11, 2019
  2. Feb 27, 2019
  3. Feb 13, 2019
  4. Jan 14, 2019
  5. Jan 06, 2019
  6. Dec 28, 2018
  7. Dec 21, 2018
  8. Dec 15, 2018
    • Masahiro Yamada's avatar
      kconfig: remove redundant token defines · a01e5d24
      Masahiro Yamada authored
      
      These are already defined as %left.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      a01e5d24
    • Masahiro Yamada's avatar
      kconfig: rename depends_list to comment_option_list · 4b5ec81b
      Masahiro Yamada authored
      
      Now the comment_stmt is the only user of depends_list. Rename it to
      comment_option_list
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      4b5ec81b
    • Masahiro Yamada's avatar
      kconfig: loosen the order of "visible" and "depends on" in menu entry · 1f31be9e
      Masahiro Yamada authored
      
      Currently, "visible" and "depends on", if defined in a menu entry,
      must appear in that order.
      
      The real example is in drivers/media/tuners/Kconfig:
      
        menu "Customize TV tuners"
                visible if <expr1>
                depends on <expr2>
      
      ... is fine, but you cannot change the property order like this:
      
        menu "Customize TV tuners"
                depends on <expr2>
                visible if <expr1>
      
      Kconfig does not require a specific order of properties. In this case,
      menu_add_visibility(() and menu_add_dep() are orthogonal.
      
      Loosen this unreasonable restriction.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      1f31be9e
    • Masahiro Yamada's avatar
      kconfig: remove redundant menu_block rule · 94d4e1b6
      Masahiro Yamada authored
      
      The code block surrounded by "menu" ... "endmenu" is stmt_list.
      
      Remove the redundant menu_block symbol entirely.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      94d4e1b6
    • Masahiro Yamada's avatar
      kconfig: remove redundant if_block rule · 4891796c
      Masahiro Yamada authored
      
      The code block surrounded by "if" ... "endif" is stmt_list.
      
      Remove the redundant if_block symbol entirely.
      
      Remove "stmt_list: stmt_list end" rule as well since it would
      obviously cause conflicts.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      4891796c
    • Masahiro Yamada's avatar
      kconfig: remove grammatically ambiguous option_error · 2f60e46e
      Masahiro Yamada authored
      
      This commit decreases 6 shift/reduce conflicts, and finally achieves
      conflict-free parser.
      
      Since Kconfig has no terminator for a config block, detecting the end
      of config_stmt is not easy.
      
      For example, there are two ways for handling the error in the following
      code:
      
        1 config FOO
        2         =
      
       [A] Print "unknown option" error, assuming the line 2 is a part of
           config_option_list
      
       [B] Print "invalid statement", assuming the line 1 is reduced into
           a config_stmt by itself
      
      Bison actually chooses [A] because it performs the shift rather than
      the reduction where both are possible.
      
      However, there is no reason to choose one over the other.
      
      Let's remove the option_error, and let it fall back to [B].
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      2f60e46e
    • Masahiro Yamada's avatar
      kconfig: remove grammatically ambiguous "unexpected option" diagnostic · 6900ae9e
      Masahiro Yamada authored
      
      This commit decreases 15 shift/reduce conflicts.
      
      The location of this error recovery is ambiguous.
      
      For example, there are two ways to interpret the following code:
      
        1 config FOO
        2         bool "foo"
      
       [A] Both lines are reduced together into a config_stmt.
      
       [B] The only line 1 is reduced into a config_stmt, and the line 2
           matches to "option_name error T_EOL"
      
      Of course, we expect [A], but [B] could be grammatically possible.
      
      Kconfig has no terminator for a config block. So, we cannot detect its
      end until we see a non-property keyword. People often insert a blank
      line between two config blocks, but it is just a coding convention.
      Blank lines are actually allowed anywhere in Kconfig files.
      
      The real error is when a property keyword appears right after "endif",
      "endchoice", "endmenu",  "source", "comment", or variable assignment.
      
      Instead of fixing the grammatical ambiguity, I chose to simply remove
      this error recovery.
      
      The difference is
      
        unexpected option "bool"
      
      ... is turned into a more generic message:
      
        invalid statement
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      6900ae9e
    • Masahiro Yamada's avatar
      kconfig: warn no new line at end of file · 72367933
      Masahiro Yamada authored
      
      It would be nice to warn if a new line is missing at end of file.
      
      We could do this by checkpatch.pl for arbitrary files, but new line
      is rather essential as a statement terminator in Kconfig.
      
      The warning message looks like this:
      
        kernel/Kconfig.preempt:60:warning: no new line at end of file
      
      Currently, kernel/Kconfig.preempt is the only file with no new line
      at end of file. Fix it.
      
      I know there are some false negative cases. For example, no warning
      is displayed when the last line contains some whitespaces/comments,
      but no new line. Yet, this commit works well for most cases.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      72367933
  9. Dec 12, 2018
    • Masahiro Yamada's avatar
      kconfig: clean up EOF handling in the lexer · 0bcc547e
      Masahiro Yamada authored
      
      A new file should always start in the INITIAL state.
      
      When the lexer bumps into EOF, the lexer must get back to the INITIAL
      state anyway. Remove the redundant <<EOF>> pattern in the PARAM state.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      0bcc547e
    • Masahiro Yamada's avatar
      kconfig: fix ambiguous grammar in terms of new lines · cc66bca7
      Masahiro Yamada authored
      
      This commit decreases 8 shift/reduce conflicts.
      
      A certain amount of grammatical ambiguity comes from how to reduce
      excessive T_EOL tokens.
      
      Let's take a look at the example code below:
      
        1  config A
        2          bool "a"
        3
        4          depends on B
        5
        6  config B
        7          def_bool y
      
      The line 3 is melt into "config_option_list", but the line 5 can be
      either a part of "config_option_list" or "common_stmt" by itself.
      
      Currently, the lexer converts '\n' to T_EOL verbatim. In Kconfig,
      a new line works as a statement terminator, but new lines in empty
      lines are not critical since empty lines (or lines that contain only
      whitespaces/comments) are just no-op.
      
      If the lexer simply discards no-op lines, the parser will not be
      bothered by excessive T_EOL tokens.
      
      Of course, this means we are shifting the complexity from the parser
      to the lexer, but it is much easier than tackling on shift/reduce
      conflicts.
      
      I introduced the second stage lexer to tweak the behavior.
      
      Discard T_EOL if the previous token is T_EOL or T_HELPTEXT.
      Two T_EOL tokens in a row is meaningless. T_HELPTEXT is a special
      token that is reduced without T_EOL.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      cc66bca7
    • Masahiro Yamada's avatar
      kconfig: refactor pattern matching in STRING state · 21c5ecf6
      Masahiro Yamada authored
      
      Here, similar matching patters are duplicated in order to look ahead
      the '\n' character. If the next character is '\n', the lexer returns
      T_WORD_QUOTE because it must be prepared to return T_EOL at the next
      match.
      
      Use unput('\n') trick to reduce the code duplication.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      21c5ecf6
    • Masahiro Yamada's avatar
      kconfig: remove unneeded pattern matching to whitespaces · be3c8075
      Masahiro Yamada authored
      
      Whitespaces are consumed in the COMMAND state anyway.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      be3c8075
    • Masahiro Yamada's avatar
      kconfig: require T_EOL to reduce visible statement · 413cd19d
      Masahiro Yamada authored
      
      All line-oriented statements should be reduced when seeing a T_EOL
      token. I guess missing T_EOL for the "visible" statement is just a
      mistake. This commit decreases one shift/reduce conflict.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      413cd19d
    • Masahiro Yamada's avatar
      kconfig: fix memory leak when EOF is encountered in quotation · fbac5977
      Masahiro Yamada authored
      
      An unterminated string literal followed by new line is passed to the
      parser (with "multi-line strings not supported" warning shown), then
      handled properly there.
      
      On the other hand, an unterminated string literal at end of file is
      never passed to the parser, then results in memory leak.
      
      [Test Code]
      
        ----------(Kconfig begin)----------
        source "Kconfig.inc"
      
        config A
                bool "a"
        -----------(Kconfig end)-----------
      
        --------(Kconfig.inc begin)--------
        config B
                bool "b\No new line at end of file
        ---------(Kconfig.inc end)---------
      
      [Summary from Valgrind]
      
        Before the fix:
      
          LEAK SUMMARY:
             definitely lost: 16 bytes in 1 blocks
             ...
      
        After the fix:
      
          LEAK SUMMARY:
             definitely lost: 0 bytes in 0 blocks
             ...
      
      Eliminate the memory leak path by handling this case. Of course, such
      a Kconfig file is wrong already, so I will add an error message later.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      fbac5977
    • Masahiro Yamada's avatar
      kconfig: fix file name and line number of warn_ignored_character() · 77c1c0fa
      Masahiro Yamada authored
      
      Currently, warn_ignore_character() displays invalid file name and
      line number.
      
      The lexer should use current_file->name and yylineno, while the parser
      should use zconf_curname() and zconf_lineno().
      
      This difference comes from that the lexer is always going ahead
      of the parser. The parser needs to look ahead one token to make a
      shift/reduce decision, so the lexer is requested to scan more text
      from the input file.
      
      This commit fixes the warning message from warn_ignored_character().
      
      [Test Code]
      
        ----(Kconfig begin)----
        /
        -----(Kconfig end)-----
      
      [Output]
      
        Before the fix:
      
        <none>:0:warning: ignoring unsupported character '/'
      
        After the fix:
      
        Kconfig:1:warning: ignoring unsupported character '/'
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      77c1c0fa
  10. Dec 08, 2018
Loading