Skip to content
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

Lex failed to parse last unterminated directive #114

Open
htv2012 opened this issue Feb 23, 2025 · 0 comments
Open

Lex failed to parse last unterminated directive #114

htv2012 opened this issue Feb 23, 2025 · 0 comments

Comments

@htv2012
Copy link

htv2012 commented Feb 23, 2025

Describe the bug
If the last directive is not terminated by a semicolon ( ; ), then lex drops the last token.

To Reproduce
Steps to reproduce the behavior:

  1. Create an nginx config file with 'user www www;\nworker_processes 2'
  2. Run crossplane lex on nginx config

Output:

["user","www","www",";","worker_processes"]

Expected behavior
I expect to see the "2" token.

Your environment

  • macOS Sequoia 15.3
  • crossplane v0.5.8

Additional context
If I drop the last "2" from the config file, the output becomes:

["user","www","www",";"]

I interpreted this behavior as the lexer always dropping the last token if the last directive is not terminated with a semicolon.

Going down stream to parse: When I feed the above faulty configuration file to parse, here is what I got:

$ crossplane parse samples/faulty.conf | jq .                                                                [nginx-conf-tool:add-tree:]
{
  "status": "failed",
  "errors": [
    {
      "file": "samples/faulty.conf",
      "error": "",
      "line": null
    }
  ],
  "config": [
    {
      "file": "samples/faulty.conf",
      "status": "failed",
      "errors": [
        {
          "error": "",
          "line": null
        }
      ],
      "parsed": []
    }
  ]
}

Notice the empty error. I expect to see better error messages. I also expect to see line number where the error happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant