Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2337

The lexer can go wrong with @if minimum_version macro

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 3.8.1, 3.7.3, 3.8.0
    • Fix Version/s: 3.9.0, 3.7.4
    • Component/s: Parsing
    • Labels:
      None
    • Platform:
      Any

      Description

      I found the problem and will provide a patch tomorrow. I must change the macro_line. It also eat up the newline chars and does not detect @endif if there is a newline before the @endif. The following code works:

      Unable to find source-code formatter for language: cfengine. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      @if minimum_version(99.9)
      @just a line
      @endif
      

      but this one fails:

      Unable to find source-code formatter for language: cfengine. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      @if minimum_version(99.9)
      @just a line
      
      @endif
      

      I will come with a patch tomorrow. I have to adjust the lexer for the if macro to not include newline char and eat up the left over newline

      I must change the lexer to skip empty lines
      from

      from:
      macro_line ^[^@].*$
      macro_line ^[^@\n\xd\xa].*$
      
      to:
      macro_line ^[^@\n\xd\xa].*$
      
      and add:
      <if_ignore_state>{newline} {
                                 }
      

        Attachments

          Activity

            People

            • Assignee:
              a10040 Kristian Amlie
              Reporter:
              bas Bas van der Vlies
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel